Generate Openbao Ruby client through Open API
This adds the OpenbaoClient
gem that is generated from the OpenBao OpenAPI spec. We need this to start work on #469580 (closed).
How was this ruby client generated
- Clone https://github.com/openbao/openbao locally.
- Make sure
bao
is in$PATH
. - Run
scripts/gen_openapi.sh
.- This would generate
scripts/openapi.json
.
- This would generate
- Install
openapi-generator
(homebrew) from https://openapi-generator.tech. - Generate the ruby client:
openapi-generator generate -g ruby -i scripts/openapi.json -o ~/gitlab-development-kit/gitlab/gems/openbao_client --additional-properties=gemName=openbao_client
Sample usage
Make sure OpenBao proxy is running, for example at http://127.0.0.1:8100
. Sample configuration can be found in #470143 (comment 1984247205).
OpenbaoClient.configure { |c| c.host = 'http://127.0.0.1:8100'; c.base_path = 'v1' }
system_api = OpenbaoClient::SystemApi.new
system_api.mounts_enable_secrets_engine('projects/56/ci', OpenbaoClient::MountsEnableSecretsEngineRequest.new(type: 'kv-v2'))
This will enable the secret engine at the given path.
Notes
- Due to https://github.com/openbao/openbao/issues/407, I had to manually edit the
logical_system_paths.go
file locally for now, and recompiled (i.e.make
) abao
binary and replaced the one I have in$PATH
.- Upstream PR to fix the issue: https://github.com/openbao/openbao/pull/408
- For now, we will have this ruby client under our
gems
directory as per guidelines. But eventually, this might be moved under theopenbao
namespace as a 3rd party gem. This is also why I skipped the gem validation in the CI config, or else it would require us to reserve the gem name under the RubyGems GitLab account. - Given this ruby client is generated by OpenAPI generator, we are not using the GitLab rubocop config, but rather we are using the OpenAPI generated one.
Edited by Erick Bajao