Skip to content

Commit

Permalink
feat: add timezone option to sync window (argoproj#7442)
Browse files Browse the repository at this point in the history
* feat: add timezone option to sync window

Signed-off-by: ishitasequeira <[email protected]>

* Retrigger CI pipeline

Signed-off-by: ishitasequeira <[email protected]>

* Addressed PR comments

Signed-off-by: ishitasequeira <[email protected]>

* feat: add timezone option to sync window

Signed-off-by: ishitasequeira <[email protected]>

* Addressed PR comments

Signed-off-by: ishitasequeira <[email protected]>

* Addressed PR comments

Signed-off-by: ishitasequeira <[email protected]>
  • Loading branch information
ishitasequeira authored Nov 4, 2021
1 parent 0d4e40e commit ff45418
Show file tree
Hide file tree
Showing 19 changed files with 711 additions and 485 deletions.
4 changes: 4 additions & 0 deletions assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -6648,6 +6648,10 @@
"schedule": {
"type": "string",
"title": "Schedule is the time the window will begin, specified in cron format"
},
"timeZone": {
"type": "string",
"title": "TimeZone of the sync that will be applied to the schedule"
}
}
},
Expand Down
8 changes: 6 additions & 2 deletions cmd/argocd/commands/projectwindows.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func NewProjectWindowsAddWindowCommand(clientOpts *argocdclient.ClientOptions) *
namespaces []string
clusters []string
manualSync bool
timeZone string
)
var command = &cobra.Command{
Use: "add PROJECT",
Expand All @@ -132,7 +133,7 @@ func NewProjectWindowsAddWindowCommand(clientOpts *argocdclient.ClientOptions) *
proj, err := projIf.Get(context.Background(), &projectpkg.ProjectQuery{Name: projName})
errors.CheckError(err)

err = proj.Spec.AddWindow(kind, schedule, duration, applications, namespaces, clusters, manualSync)
err = proj.Spec.AddWindow(kind, schedule, duration, applications, namespaces, clusters, manualSync, timeZone)
errors.CheckError(err)

_, err = projIf.Update(context.Background(), &projectpkg.ProjectUpdateRequest{Project: proj})
Expand All @@ -146,6 +147,7 @@ func NewProjectWindowsAddWindowCommand(clientOpts *argocdclient.ClientOptions) *
command.Flags().StringSliceVar(&namespaces, "namespaces", []string{}, "Namespaces that the schedule will be applied to. Comma separated, wildcards supported (e.g. --namespaces default,\\*-prod)")
command.Flags().StringSliceVar(&clusters, "clusters", []string{}, "Clusters that the schedule will be applied to. Comma separated, wildcards supported (e.g. --clusters prod,staging)")
command.Flags().BoolVar(&manualSync, "manual-sync", false, "Allow manual syncs for both deny and allow windows")
command.Flags().StringVar(&timeZone, "time-zone", "UTC", "Time zone of the sync window")

return command
}
Expand Down Expand Up @@ -189,6 +191,7 @@ func NewProjectWindowsUpdateCommand(clientOpts *argocdclient.ClientOptions) *cob
applications []string
namespaces []string
clusters []string
timeZone string
)
var command = &cobra.Command{
Use: "update PROJECT ID",
Expand All @@ -212,7 +215,7 @@ func NewProjectWindowsUpdateCommand(clientOpts *argocdclient.ClientOptions) *cob

for i, window := range proj.Spec.SyncWindows {
if id == i {
err := window.Update(schedule, duration, applications, namespaces, clusters)
err := window.Update(schedule, duration, applications, namespaces, clusters, timeZone)
if err != nil {
errors.CheckError(err)
}
Expand All @@ -228,6 +231,7 @@ func NewProjectWindowsUpdateCommand(clientOpts *argocdclient.ClientOptions) *cob
command.Flags().StringSliceVar(&applications, "applications", []string{}, "Applications that the schedule will be applied to. Comma separated, wildcards supported (e.g. --applications prod-\\*,website)")
command.Flags().StringSliceVar(&namespaces, "namespaces", []string{}, "Namespaces that the schedule will be applied to. Comma separated, wildcards supported (e.g. --namespaces default,\\*-prod)")
command.Flags().StringSliceVar(&clusters, "clusters", []string{}, "Clusters that the schedule will be applied to. Comma separated, wildcards supported (e.g. --clusters prod,staging)")
command.Flags().StringVar(&timeZone, "time-zone", "UTC", "Time zone of the sync window. (e.g. --time-zone \"America/New_York\")")
return command
}

Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/commands/argocd_proj_windows_add.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ argocd proj windows add PROJECT [flags]
--manual-sync Allow manual syncs for both deny and allow windows
--namespaces strings Namespaces that the schedule will be applied to. Comma separated, wildcards supported (e.g. --namespaces default,\*-prod)
--schedule string Sync window schedule in cron format. (e.g. --schedule "0 22 * * *")
--time-zone string Time zone of the sync window (default "UTC")
```

### Options inherited from parent commands
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/commands/argocd_proj_windows_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ argocd proj windows update PROJECT ID [flags]
-h, --help help for update
--namespaces strings Namespaces that the schedule will be applied to. Comma separated, wildcards supported (e.g. --namespaces default,\*-prod)
--schedule string Sync window schedule in cron format. (e.g. --schedule "0 22 * * *")
--time-zone string Time zone of the sync window. (e.g. --time-zone "America/New_York") (default "UTC")
```

### Options inherited from parent commands
Expand Down
4 changes: 4 additions & 0 deletions manifests/core-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2511,6 +2511,10 @@ spec:
description: Schedule is the time the window will begin, specified
in cron format
type: string
timeZone:
description: TimeZone of the sync that will be applied to the
schedule
type: string
type: object
type: array
type: object
Expand Down
4 changes: 4 additions & 0 deletions manifests/crds/appproject-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ spec:
description: Schedule is the time the window will begin, specified
in cron format
type: string
timeZone:
description: TimeZone of the sync that will be applied to the
schedule
type: string
type: object
type: array
type: object
Expand Down
4 changes: 4 additions & 0 deletions manifests/ha/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2511,6 +2511,10 @@ spec:
description: Schedule is the time the window will begin, specified
in cron format
type: string
timeZone:
description: TimeZone of the sync that will be applied to the
schedule
type: string
type: object
type: array
type: object
Expand Down
4 changes: 4 additions & 0 deletions manifests/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2511,6 +2511,10 @@ spec:
description: Schedule is the time the window will begin, specified
in cron format
type: string
timeZone:
description: TimeZone of the sync that will be applied to the
schedule
type: string
type: object
type: array
type: object
Expand Down
Loading

0 comments on commit ff45418

Please sign in to comment.