Skip to content

Commit

Permalink
Remove PersistentPreRun
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 committed Nov 13, 2024
1 parent f2f47ac commit d4f099a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
33 changes: 16 additions & 17 deletions cmd/ocp.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func openShiftCmd() *cobra.Command {
ocpCmd.PersistentFlags().BoolVar(&gcMetrics, "gc-metrics", false, "Collect metrics during garbage collection")
ocpCmd.PersistentFlags().StringVar(&workloadConfig.UserMetadata, "user-metadata", "", "User provided metadata file, in YAML format")
ocpCmd.PersistentFlags().BoolVar(&extract, "extract", false, "Extract workload in the current directory")
ocpCmd.PersistentFlags().SortFlags = false
ocpCmd.MarkFlagsRequiredTogether("es-server", "es-index")
ocpCmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
if cmd.Name() == "version" {
Expand Down Expand Up @@ -104,22 +103,22 @@ func openShiftCmd() *cobra.Command {
}
}
ocpCmd.AddCommand(
ocp.NewWorkload(ocp.NewClusterDensity(&wh, "cluster-density-v2"), wh),
ocp.NewWorkload(ocp.NewClusterDensity(&wh, "cluster-density-ms"), wh),
ocp.NewWorkload(ocp.NewCrdScale(), wh),
ocp.NewWorkload(ocp.NewNetworkPolicy("networkpolicy-multitenant"), wh),
ocp.NewWorkload(ocp.NewNetworkPolicy("networkpolicy-matchlabels"), wh),
ocp.NewWorkload(ocp.NewNetworkPolicy("networkpolicy-matchexpressions"), wh),
ocp.NewWorkload(ocp.NewNodeDensity(&wh), wh),
ocp.NewWorkload(ocp.NewNodeDensityHeavy(&wh), wh),
ocp.NewWorkload(ocp.NewNodeDensityCNI(&wh), wh),
ocp.NewWorkload(ocp.NewPVCDensity(), wh),
ocp.NewWorkload(ocp.NewRDSCore(&wh), wh),
ocp.NewWorkload(ocp.NewWebBurner("web-burner-init"), wh),
ocp.NewWorkload(ocp.NewWebBurner("web-burner-node-density"), wh),
ocp.NewWorkload(ocp.NewWebBurner("web-burner-cluster-density"), wh),
ocp.NewWorkload(ocp.NewEgressIP("egressip"), wh),
ocp.NewWorkload(ocp.NewUDNDensityPods(&wh), wh),
ocp.NewWorkload(ocp.NewClusterDensity(&wh, "cluster-density-v2"), &wh),
ocp.NewWorkload(ocp.NewClusterDensity(&wh, "cluster-density-ms"), &wh),
ocp.NewWorkload(ocp.NewCrdScale(), &wh),
ocp.NewWorkload(ocp.NewNetworkPolicy("networkpolicy-multitenant"), &wh),
ocp.NewWorkload(ocp.NewNetworkPolicy("networkpolicy-matchlabels"), &wh),
ocp.NewWorkload(ocp.NewNetworkPolicy("networkpolicy-matchexpressions"), &wh),
ocp.NewWorkload(ocp.NewNodeDensity(&wh), &wh),
ocp.NewWorkload(ocp.NewNodeDensityHeavy(&wh), &wh),
ocp.NewWorkload(ocp.NewNodeDensityCNI(&wh), &wh),
ocp.NewWorkload(ocp.NewPVCDensity(), &wh),
ocp.NewWorkload(ocp.NewRDSCore(&wh), &wh),
ocp.NewWorkload(ocp.NewWebBurner("web-burner-init"), &wh),
ocp.NewWorkload(ocp.NewWebBurner("web-burner-node-density"), &wh),
ocp.NewWorkload(ocp.NewWebBurner("web-burner-cluster-density"), &wh),
ocp.NewWorkload(ocp.NewEgressIP("egressip"), &wh),
ocp.NewWorkload(ocp.NewUDNDensityPods(&wh), &wh),
ocp.CustomWorkload(&wh),
ocp.NewWorkersScale(&wh.MetricsEndpoint, &wh.MetadataAgent),
ocp.NewIndex(&wh.MetricsEndpoint, &wh.MetadataAgent),
Expand Down
6 changes: 2 additions & 4 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,10 @@ func GatherMetadata(wh *workloads.WorkloadHelper, alerting bool) error {
return nil
}

func NewWorkload(cmd *cobra.Command, wh workloads.WorkloadHelper) *cobra.Command {
cmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
func NewWorkload(cmd *cobra.Command, wh *workloads.WorkloadHelper) *cobra.Command {
cmd.Run = func(cmd *cobra.Command, args []string) {
metricsProfiles, _ := cmd.Flags().GetStringSlice("metrics-profile")
os.Setenv("METRICS", strings.Join(metricsProfiles, ","))
}
cmd.Run = func(cmd *cobra.Command, args []string) {
rc := wh.Run(cmd.Name())
os.Exit(rc)
}
Expand Down

0 comments on commit d4f099a

Please sign in to comment.