MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / NewCmd

Function NewCmd

internal/cmd/plugin/certificate/cmd.go:31–72  ·  view source on GitHub ↗

NewCmd creates the new "certificate" subcommand

()

Source from the content-addressed store, hash-verified

29
30// NewCmd creates the new "certificate" subcommand
31func NewCmd() *cobra.Command {
32 certificateCmd := &cobra.Command{
33 Use: "certificate [secretName]",
34 Short: `Create a client certificate to connect to PostgreSQL using TLS and Certificate authentication`,
35 Long: `This command creates a new Kubernetes secret containing the crypto-material.
36This is needed to configure TLS with Certificate authentication access for an application to
37connect to the PostgreSQL cluster.`,
38 GroupID: plugin.GroupIDDatabase,
39 Args: plugin.RequiresArguments(1),
40 RunE: func(cmd *cobra.Command, args []string) error {
41 ctx := context.Background()
42 secretName := args[0]
43
44 user, _ := cmd.Flags().GetString("cnpg-user")
45 cluster, _ := cmd.Flags().GetString("cnpg-cluster")
46 dryRun, _ := cmd.Flags().GetBool("dry-run")
47 output, _ := cmd.Flags().GetString("output")
48
49 params := Params{
50 Name: secretName,
51 Namespace: plugin.Namespace,
52 User: user,
53 ClusterName: cluster,
54 }
55
56 return Generate(ctx, params, dryRun, plugin.OutputFormat(output))
57 },
58 }
59
60 certificateCmd.Flags().String(
61 "cnpg-user", "", "The name of the PostgreSQL user")
62 _ = certificateCmd.MarkFlagRequired("cnpg-user")
63 certificateCmd.Flags().String(
64 "cnpg-cluster", "", "The name of the PostgreSQL cluster")
65 _ = certificateCmd.MarkFlagRequired("cnpg-cluster")
66 certificateCmd.Flags().StringP(
67 "output", "o", "", "Output format. One of json|yaml")
68 certificateCmd.Flags().Bool(
69 "dry-run", false, "If specified, the secret is not created")
70
71 return certificateCmd
72}

Callers 1

mainFunction · 0.92

Calls 4

RequiresArgumentsFunction · 0.92
OutputFormatTypeAlias · 0.92
GenerateFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected