Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tool: rename flags in type updater #3367

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import (
type UpdateTypeOptions struct {
*options.GenerateOptions

parentNessage string // The fully qualified name of the parent prroto message of the field to be inserted
fieldToInsert string
ignoredFields string // TODO: could be part of GenerateOptions
apiDirectory string
goPackagePath string
parentMessage string // The fully qualified name of the parent proto message of the field to be inserted
insertField string
ignoredFields string // TODO: could be part of GenerateOptions
apiDirectory string
apiGoPackagePath string
}

func (o *UpdateTypeOptions) InitDefaults() error {
Expand All @@ -41,17 +41,17 @@ func (o *UpdateTypeOptions) InitDefaults() error {
return nil
}
o.apiDirectory = root + "/apis/"
o.goPackagePath = "github.com/GoogleCloudPlatform/k8s-config-connector/apis/"
o.apiGoPackagePath = "github.com/GoogleCloudPlatform/k8s-config-connector/apis/"
return nil
}

func (o *UpdateTypeOptions) BindFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(&o.parentNessage, "parent-message", o.parentNessage, "Fully qualified name of the proto message holding the new field. e.g. `google.cloud.bigquery.datatransfer.v1.TransferConfig`")
cmd.Flags().StringVar(&o.fieldToInsert, "field-to-insert", o.fieldToInsert, "Name of the new field to be inserted, e.g. `schedule_options_v2`")
cmd.Flags().StringVar(&o.parentMessage, "parent", o.parentMessage, "Fully qualified name of the proto message holding the new field. e.g. `google.cloud.bigquery.datatransfer.v1.TransferConfig`")
cmd.Flags().StringVar(&o.insertField, "insert-field", o.insertField, "Name of the new field to be inserted, e.g. `schedule_options_v2`")
// TODO: Update this flag to accept a file path pointing to the ignored fields YAML file.
cmd.Flags().StringVar(&o.ignoredFields, "ignored-fields", o.ignoredFields, "Comma-separated list of fields to ignore")
cmd.Flags().StringVar(&o.apiDirectory, "api-dir", o.apiDirectory, "Base directory for APIs")
cmd.Flags().StringVar(&o.goPackagePath, "api-go-package-path", o.goPackagePath, "Package path")
cmd.Flags().StringVar(&o.apiGoPackagePath, "api-go-package-path", o.apiGoPackagePath, "API Go package path")
}

func BuildCommand(baseOptions *options.GenerateOptions) *cobra.Command {
Expand Down Expand Up @@ -88,11 +88,11 @@ func runTypeUpdater(ctx context.Context, opt *UpdateTypeOptions) error {

typeUpdaterOpts := &typeupdater.UpdaterOptions{
ProtoSourcePath: opt.GenerateOptions.ProtoSourcePath,
ParentMessageFullName: opt.parentNessage,
FieldToInsert: opt.fieldToInsert,
ParentMessageFullName: opt.parentMessage,
FieldToInsert: opt.insertField,
IgnoredFields: opt.ignoredFields,
APIDirectory: opt.apiDirectory,
GoPackagePath: opt.goPackagePath,
GoPackagePath: opt.apiGoPackagePath,
}
updater := typeupdater.NewTypeUpdater(typeUpdaterOpts)
if err := updater.Run(); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions dev/tools/controllerbuilder/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cd ${REPO_ROOT}/dev/tools/controllerbuilder

# example usage
go run . update-types \
--parent-message "google.monitoring.dashboard.v1.Dashboard" \
--field-to-insert "row_layout" \
--parent "google.monitoring.dashboard.v1.Dashboard" \
--insert-field "row_layout" \
--api-dir ${REPO_ROOT}/apis/monitoring/v1beta1 \
--ignored-fields "google.monitoring.dashboard.v1.PickTimeSeriesFilter.interval"
4 changes: 2 additions & 2 deletions docs/develop-resources/scenarios/new-field.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ REPO_ROOT="$(git rev-parse --show-toplevel)"
cd $REPO_ROOT/dev/tools/controllerbuilder

go run . update-types \
--parent-message "google.monitoring.dashboard.v1.Dashboard" \
--field-to-insert "row_layout" \
--parent "google.monitoring.dashboard.v1.Dashboard" \
--insert-field "row_layout" \
--api-dir ${REPO_ROOT}/apis/monitoring/v1beta1
```

Expand Down
Loading