-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
feat(cmd): bucket create to accept org name as flag #16187
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ type cmdPkgBuilder struct { | |
hasTableBorders bool | ||
meta pkger.Metadata | ||
orgID string | ||
org string | ||
quiet bool | ||
|
||
applyOpts struct { | ||
|
@@ -95,8 +96,8 @@ func (b *cmdPkgBuilder) cmdPkgApply() *cobra.Command { | |
cmd.Flags().IntVarP(&b.applyReqLimit, "req-limit", "r", 0, "Request limit for applying a pkg, defaults to 5(recommended for OSS).") | ||
cmd.Flags().StringVar(&b.applyOpts.force, "force", "", `TTY input, if package will have destructive changes, proceed if set "true".`) | ||
|
||
cmd.Flags().StringVarP(&b.orgID, "org-id", "o", "", "The ID of the organization that owns the bucket") | ||
cmd.MarkFlagRequired("org-id") | ||
cmd.Flags().StringVarP(&b.orgID, "org-id", "", "", "The ID of the organization that owns the bucket") | ||
cmd.Flags().StringVarP(&b.org, "org", "o", "", "The name of the organization that owns the bucket") | ||
|
||
cmd.Flags().BoolVarP(&b.hasColor, "color", "c", true, "Enable color in output, defaults true") | ||
cmd.Flags().BoolVar(&b.hasTableBorders, "table-borders", true, "Enable table borders, defaults true") | ||
|
@@ -108,11 +109,32 @@ func (b *cmdPkgBuilder) cmdPkgApply() *cobra.Command { | |
|
||
func (b *cmdPkgBuilder) pkgApplyRunEFn() func(*cobra.Command, []string) error { | ||
return func(cmd *cobra.Command, args []string) (e error) { | ||
if b.orgID == "" && b.org == "" { | ||
return fmt.Errorf("must specify org-id, or org name") | ||
} else if b.orgID != "" && b.org != "" { | ||
return fmt.Errorf("must specify org-id, or org name not both") | ||
} | ||
color.NoColor = !b.hasColor | ||
var influxOrgID *influxdb.ID | ||
|
||
influxOrgID, err := influxdb.IDFromString(b.orgID) | ||
if err != nil { | ||
return fmt.Errorf("invalid org ID provided: %s", err.Error()) | ||
if b.orgID != "" { | ||
var err error | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this isn't going to work, breaks the pattern for the builder... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any SVC dep needs to be provided through DI not dumped in here globally needs fixup There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for catching, we'll fix in the morning. |
||
influxOrgID, err = influxdb.IDFromString(b.orgID) | ||
if err != nil { | ||
return fmt.Errorf("invalid org ID provided: %s", err.Error()) | ||
} | ||
} else if b.org != "" { | ||
orgSvc, err := newOrganizationService() | ||
if err != nil { | ||
return fmt.Errorf("failed to initialize organization service client: %v", err) | ||
} | ||
|
||
filter := influxdb.OrganizationFilter{Name: &b.org} | ||
org, err := orgSvc.FindOrganization(context.Background(), filter) | ||
if err != nil { | ||
return fmt.Errorf("%v", err) | ||
} | ||
influxOrgID = &org.ID | ||
} | ||
|
||
svc, err := b.svcFn(flags.httpClientOpts(), pkger.WithApplyReqLimit(b.applyReqLimit)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just caught this. will patch this up