-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(apply): add deck gateway apply command
The `deck gateway apply` command allows you to apply partial configuration to a running Gateway instance. To do this, it runs a `sync` with the NoDeletes flag enabled. This means that only new and existing resources are updated. Existing resources that do not exist in the declarative configuration file are left untouched.
- Loading branch information
Showing
7 changed files
with
64 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
applyCmdParallelism int | ||
applyCmdDBUpdateDelay int | ||
applyWorkspace string | ||
applyJSONOutput bool | ||
) | ||
|
||
var applyCmdKongStateFile []string | ||
|
||
func executeApply(cmd *cobra.Command, _ []string) error { | ||
return syncMain(cmd.Context(), applyCmdKongStateFile, false, | ||
applyCmdParallelism, applyCmdDBUpdateDelay, applyWorkspace, applyJSONOutput, true) | ||
} | ||
|
||
func newApplyCmd() *cobra.Command { | ||
short := "Apply configuration to Kong without deleting existing entities" | ||
execute := executeApply | ||
|
||
applyCmd := &cobra.Command{ | ||
Use: "apply [flags] [kong-state-files...]", | ||
Short: short, | ||
Long: `The apply command allows you to apply partial Kong configuration files without deleting existing entities.`, | ||
Args: cobra.MinimumNArgs(0), | ||
RunE: execute, | ||
PreRunE: func(_ *cobra.Command, args []string) error { | ||
applyCmdKongStateFile = args | ||
if len(applyCmdKongStateFile) == 0 { | ||
applyCmdKongStateFile = []string{"-"} | ||
} | ||
return preRunSilenceEventsFlag() | ||
}, | ||
} | ||
|
||
applyCmd.Flags().StringVarP(&applyWorkspace, "workspace", "w", "", | ||
"Apply configuration to a specific workspace "+ | ||
"(Kong Enterprise only).\n"+ | ||
"This takes precedence over _workspace fields in state files.") | ||
applyCmd.Flags().IntVar(&applyCmdParallelism, "parallelism", | ||
10, "Maximum number of concurrent operations.") | ||
applyCmd.Flags().IntVar(&applyCmdDBUpdateDelay, "db-update-propagation-delay", | ||
0, "artificial delay (in seconds) that is injected between insert operations \n"+ | ||
"for related entities (usually for Cassandra deployments).\n"+ | ||
"See `db_update_propagation` in kong.conf.") | ||
applyCmd.Flags().BoolVar(&syncJSONOutput, "json-output", | ||
false, "generate command execution report in a JSON format") | ||
addSilenceEventsFlag(applyCmd.Flags()) | ||
|
||
return applyCmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters