A very high level list of things to do when you're adding an additional field to an existing API and corresponding CLI command.
Once you've figured out that you need an additional field in Boundary's domain model, then you need to build in support for your new field from the bottom up starting with a repository's database schema.
Make schema changes:
internal/db/schema/migrations/oss/postgres
Add the new field to the storage protobuf
internal/proto/controller/storage
@gotags
(@inject_tag
has been deprecated)custom_options.v1.mask_mapping
for the field
which maps the storage this
field to the API that
field
(yes, it's the opposite of how it's defined for the API protobuf)make proto
after modifying storage protobufExtend the existing repository function for Updating the resource to incorporate the new field. This could/may entail defining new options for the Update function.
Check the repository's Create function for the resource, since you may need to incorporate the new field here as well.
Now that the repository supports the new field, you can move on to adding this new field to Boundary's API layer and the generated SDK. The first step in the process is to add it to the API/SDK protobufs.
API protobufs are under: internal/proto/controller/api/resources
Define a custom_options.v1.mask_mapping
tag for the field
which maps the API this
field to the storage that
field
(yes, it's the opposite of how it's defined for a storage protobuf)
Define a custom_options.v1.generate_sdk_option
tag to change the SDK and add
API options (DefaultX, WithX functions).
Define a data classification/filter tag for the field via @gotags
which specifies how sensitive/secret/public data
will be handled for the API's audit events.
See the classification rubric
for guidelines on classification.
Please write unit tests to verify the audit event is properly "redacted"
(see the unit tests of TestAuthMethod_Tags
for examples).
Run make proto
and make api
after modifying the API/SDK protobufs
Now that the API protobufs have been updated, you can move on to adding this new field to the API service handler.
internal/daemon/controller/handlers
updateInRepo
func.
You'll need to incorporate the inbound protobuf's field with the repository's update function.
This could include adding repository options to the Update function call
or passing the new field as a parameter to the call.
This work will be based on how you extended the repository in the previous steps.ToProto
function.At this point, the new field is available via Boundary's API. All that's left is to incorporate it into Boundary's CLI for the appropriate command.
internal/cmd/commands
funcs.go
.
Just a suggestion here: you may want to define a const for the new field name
and reuse it everywhere it's required (which is several places)make cli
and make install
, before attempting to test cli changesinputStructs
for API generation: internal/api/genapi
then run make api
or make gen
inputStructs
for CLI generation:
internal/cmd/gencli
then run make cli
or make gen
cli.CommandFactory
to the cmd.initCommands(...)
:
internal/cmd
then run make cli
or make gen
func.go
following the same
suggestion to define consts for field names and reuse them everywhere they are
required.make cli
and make install
, before attempting to test cli changesВы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Опубликовать ( 0 )