Skip to content

Commit

Permalink
CLOUDP-62053: It is not possible to unack an alert (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaangiolillo committed May 7, 2020
1 parent 7e36678 commit edf3235
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/cli/atlas_alerts_acknowledge.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type atlasAlertsAcknowledgeOpts struct {
alertID string
until string
comment string
forever bool
store store.AlertAcknowledger
}

Expand All @@ -52,20 +53,18 @@ func (opts *atlasAlertsAcknowledgeOpts) Run() error {
}

func (opts *atlasAlertsAcknowledgeOpts) newAcknowledgeRequest() *atlas.AcknowledgeRequest {
until := opts.until

// To acknowledge an alert “forever”, set the field value to 100 years in the future.
if until == "" {
until = time.Now().AddDate(100, 1, 1).Format(time.RFC3339)
if opts.forever {
opts.until = time.Now().AddDate(100, 1, 1).Format(time.RFC3339)
}

return &atlas.AcknowledgeRequest{
AcknowledgedUntil: until,
AcknowledgedUntil: opts.until,
AcknowledgementComment: opts.comment,
}
}

// mongocli atlas alerts acknowledge alertID --projectId projectId
// mongocli atlas alerts acknowledge alertID --projectId projectId --forever
func AtlasAlertsAcknowledgeBuilder() *cobra.Command {
opts := new(atlasAlertsAcknowledgeOpts)
cmd := &cobra.Command{
Expand All @@ -82,6 +81,7 @@ func AtlasAlertsAcknowledgeBuilder() *cobra.Command {
},
}

cmd.Flags().BoolVarP(&opts.forever, flags.Forever, flags.ForeverShort, false, usage.Forever)
cmd.Flags().StringVar(&opts.until, flags.Until, "", usage.Until)
cmd.Flags().StringVar(&opts.comment, flags.Comment, "", usage.Comment)

Expand Down
2 changes: 2 additions & 0 deletions internal/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const (
Members = "members" // Members flag
MembersShort = "m" // MembersShort flag
Tier = "tier" // Tier flag
Forever = "forever" // Forever flag
ForeverShort = "F" // ForeverShort flag
DiskSizeGB = "diskSizeGB" // DiskSizeGB flag
MDBVersion = "mdbVersion" // MDBVersion flag
Backup = "backup" // Backup flag
Expand Down
1 change: 1 addition & 0 deletions internal/usage/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
AuthDB = "Authentication database name."
Granularity = "Duration in ISO 8601 notation that specifies the interval between measurement data points."
Page = "Page number."
Forever = "Acknowledge an alert “forever”."
Status = "Alert's status."
Until = "Acknowledged until a date."
Limit = "Number of items per page."
Expand Down

0 comments on commit edf3235

Please sign in to comment.