Skip to content

Commit

Permalink
chore(influx): update setup cmd to allow for duration for retention o…
Browse files Browse the repository at this point in the history
…ption

closes: #17107
  • Loading branch information
jsteenb2 committed Mar 6, 2020
1 parent 037d484 commit 95c72c1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Features
1. [17085](https://github.com/influxdata/influxdb/pull/17085): Clicking on bucket name takes user to Data Explorer with bucket selected
1. [17095](https://github.com/influxdata/influxdb/pull/17095): Extend pkger dashboards with table view support
1. [17114](https://github.com/influxdata/influxdb/pull/17114): Allow for retention to be provided to influx setup command as a duration

### Bug Fixes

Expand Down
4 changes: 2 additions & 2 deletions cmd/influx/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (b *cmdBucketBuilder) cmdCreate() *cobra.Command {
opts.mustRegister(cmd)

cmd.Flags().StringVarP(&b.description, "description", "d", "", "Description of bucket that will be created")
cmd.Flags().DurationVarP(&b.retention, "retention", "r", 0, "Duration in nanoseconds data will live in bucket")
cmd.Flags().DurationVarP(&b.retention, "retention", "r", 0, "Duration bucket will retain data. 0 is infinite. Default is 0.")
b.org.register(cmd, false)

return cmd
Expand Down Expand Up @@ -253,7 +253,7 @@ func (b *cmdBucketBuilder) cmdUpdate() *cobra.Command {
cmd.Flags().StringVarP(&b.id, "id", "i", "", "The bucket ID (required)")
cmd.Flags().StringVarP(&b.description, "description", "d", "", "Description of bucket that will be created")
cmd.MarkFlagRequired("id")
cmd.Flags().DurationVarP(&b.retention, "retention", "r", 0, "New duration data will live in bucket")
cmd.Flags().DurationVarP(&b.retention, "retention", "r", 0, "Duration bucket will retain data. 0 is infinite. Default is 0.")

return cmd
}
Expand Down
19 changes: 11 additions & 8 deletions cmd/influx/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"strconv"
"strings"
"time"

platform "github.com/influxdata/influxdb"
"github.com/influxdata/influxdb/cmd/influx/internal"
Expand All @@ -20,7 +21,7 @@ var setupFlags struct {
token string
org string
bucket string
retention int
retention time.Duration
force bool
}

Expand All @@ -33,7 +34,7 @@ func cmdSetup(f *globalFlags, opt genericCLIOpts) *cobra.Command {
cmd.Flags().StringVarP(&setupFlags.token, "token", "t", "", "token for username, else auto-generated")
cmd.Flags().StringVarP(&setupFlags.org, "org", "o", "", "primary organization name")
cmd.Flags().StringVarP(&setupFlags.bucket, "bucket", "b", "", "primary bucket name")
cmd.Flags().IntVarP(&setupFlags.retention, "retention", "r", -1, "retention period in hours, else infinite")
cmd.Flags().DurationVarP(&setupFlags.retention, "retention", "r", -1, "Duration bucket will retain data. 0 is infinite. Default is 0.")
cmd.Flags().BoolVarP(&setupFlags.force, "force", "f", false, "skip confirmation prompt")

return cmd
Expand Down Expand Up @@ -121,12 +122,14 @@ func onboardingRequest() (*platform.OnboardingRequest, error) {

func nonInteractive() (*platform.OnboardingRequest, error) {
req := &platform.OnboardingRequest{
User: setupFlags.username,
Password: setupFlags.password,
Token: setupFlags.token,
Org: setupFlags.org,
Bucket: setupFlags.bucket,
RetentionPeriod: uint(setupFlags.retention),
User: setupFlags.username,
Password: setupFlags.password,
Token: setupFlags.token,
Org: setupFlags.org,
Bucket: setupFlags.bucket,
// TODO: this manipulation is required by the API, something that
// we should fixup to be a duration instead
RetentionPeriod: uint(setupFlags.retention / time.Hour),
}

if setupFlags.retention < 0 {
Expand Down

0 comments on commit 95c72c1

Please sign in to comment.