Skip to content

Commit

Permalink
cli: don't require file flags
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Meyer <[email protected]>
  • Loading branch information
katexochen committed Jan 15, 2024
1 parent 6d5ec44 commit 513c5cb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 2 additions & 0 deletions cli/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const (
coordRootPEMFilename = "coordinator-root.pem"
coordIntermPEMFilename = "mesh-root.pem"
manifestFilename = "manifest.json"
settingsFilename = "settings.json"
rulesFilename = "rules.rego"
policyDir = "."
verifyDir = "./verify"
)

Expand Down
11 changes: 4 additions & 7 deletions cli/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@ const kataPolicyAnnotationKey = "io.katacontainers.config.agent.policy"

func newGenerateCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "generate",
Use: "generate [flags] paths...",
Short: "generate",
RunE: runGenerate,
}

cmd.Flags().StringP("policy", "p", "", "path to policy (.rego) file")
must(cobra.MarkFlagRequired(cmd.Flags(), "policy"))
cmd.Flags().StringP("settings", "s", "", "path to settings (.json) file")
must(cobra.MarkFlagRequired(cmd.Flags(), "settings"))
cmd.Flags().StringP("manifest", "m", "", "path to manifest (.json) file")
must(cobra.MarkFlagRequired(cmd.Flags(), "manifest"))
cmd.Flags().StringP("policy", "p", policyDir, "path to policy (.rego) file")
cmd.Flags().StringP("settings", "s", settingsFilename, "path to settings (.json) file")
cmd.Flags().StringP("manifest", "m", manifestFilename, "path to manifest (.json) file")

return cmd
}
Expand Down
5 changes: 2 additions & 3 deletions cli/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ import (

func newSetCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "set",
Use: "set [flags] paths...",
Short: "Set a manifest",
Long: `Set a manifest.`,
RunE: runSet,
}

cmd.Flags().StringP("manifest", "m", "", "path to manifest (.json) file")
must(cobra.MarkFlagRequired(cmd.Flags(), "manifest"))
cmd.Flags().StringP("manifest", "m", manifestFilename, "path to manifest (.json) file")
cmd.Flags().StringP("coordinator", "c", "", "endpoint the coordinator can be reached at")
must(cobra.MarkFlagRequired(cmd.Flags(), "coordinator"))

Expand Down
4 changes: 2 additions & 2 deletions cli/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import (
func newVerifyCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "verify",
Short: "Verify a manifest",
Short: "Verify a nunki deployment",
Long: `Verify a manifest.`,
RunE: runVerify,
}

cmd.Flags().StringP("output", "o", verifyDir, "directory to write files to")
cmd.Flags().StringP("coordinator", "c", "", "endpoint the coordinator can be reached at")
must(cobra.MarkFlagRequired(cmd.Flags(), "coordinator"))
cmd.Flags().StringP("output", "o", "./verify", "directory to write files to")

return cmd
}
Expand Down

0 comments on commit 513c5cb

Please sign in to comment.