NewCmd initializes the pgBench command
()
| 29 | |
| 30 | // NewCmd initializes the pgBench command |
| 31 | func NewCmd() *cobra.Command { |
| 32 | run := &pgBenchRun{} |
| 33 | |
| 34 | pgBenchCmd := &cobra.Command{ |
| 35 | Use: "pgbench CLUSTER [-- PGBENCH_COMMAND_ARGS...]", |
| 36 | Short: "Creates a pgbench job", |
| 37 | Args: validateCommandArgs, |
| 38 | Long: "Creates a pgbench job to run against the specified Postgres Cluster.", |
| 39 | GroupID: plugin.GroupIDMiscellaneous, |
| 40 | Example: jobExample, |
| 41 | RunE: func(cmd *cobra.Command, args []string) error { |
| 42 | run.clusterName = args[0] |
| 43 | run.pgBenchCommandArgs = args[1:] |
| 44 | |
| 45 | return run.execute(cmd.Context()) |
| 46 | }, |
| 47 | } |
| 48 | |
| 49 | pgBenchCmd.Flags().StringVar( |
| 50 | &run.jobName, |
| 51 | "job-name", |
| 52 | "", |
| 53 | "Name of the job, defaulting to: CLUSTER-pgbench-xxxx", |
| 54 | ) |
| 55 | |
| 56 | pgBenchCmd.Flags().StringVar( |
| 57 | &run.jobName, |
| 58 | "pgbench-job-name", |
| 59 | "", |
| 60 | "Name of the job, defaulting to: CLUSTER-pgbench-xxxx", |
| 61 | ) |
| 62 | |
| 63 | pgBenchCmd.Flags().StringVar( |
| 64 | &run.dbName, |
| 65 | "db-name", |
| 66 | "app", |
| 67 | "The name of the database that will be used by pgbench. Defaults to: app", |
| 68 | ) |
| 69 | |
| 70 | pgBenchCmd.Flags().Int32Var( |
| 71 | &run.ttlSecondsAfterFinished, |
| 72 | "ttl", |
| 73 | 0, |
| 74 | "Time to live of the pgbench job. Defaults to no TTL.", |
| 75 | ) |
| 76 | |
| 77 | pgBenchCmd.Flags().BoolVar( |
| 78 | &run.dryRun, |
| 79 | "dry-run", |
| 80 | false, |
| 81 | "When true prints the job manifest instead of creating it", |
| 82 | ) |
| 83 | |
| 84 | pgBenchCmd.Flags().StringSliceVar( |
| 85 | &run.nodeSelector, |
| 86 | "node-selector", |
| 87 | []string{}, |
| 88 | "Node label selector in the <labelName>=<labelValue> format.", |
no test coverage detected