Skip to content

Commit

Permalink
Change logic to use a service account
Browse files Browse the repository at this point in the history
Signed-off-by: Vicente Zepeda Mas <[email protected]>
  • Loading branch information
chentex committed Jul 1, 2024
1 parent 14b4ad4 commit 94c8782
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 815 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# DevEnv
.vscode
.go-version
/env*
# App
ocm-load-test
Expand Down
26 changes: 15 additions & 11 deletions cmd/ocm-load-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ func init() {
rootCmd.Flags().Int("ramp-steps", 0, "Number of stepts to get from start rate to end rate. (Minimum 2 steps)")
rootCmd.Flags().Int("ramp-duration", 0, "Duration of ramp in minutes, before normal execution")

//Required flags
// Deprecated flags
rootCmd.Flags().String("ocm-token", "", "OCM Authorization token")

//Required flags
rootCmd.Flags().String("client-id", "", "OCM Service Account client ID")
rootCmd.Flags().String("client-secret", "", "OCM Service Account cliient secret")
// AWS config
// If multiple AWS account are needed use the config file
rootCmd.Flags().String("aws-region", "us-west-1", "AWS region")
Expand Down Expand Up @@ -168,20 +172,20 @@ func configES() error {

func run(cmd *cobra.Command, args []string) error {
logger, err := logging.NewGoLoggerBuilder().
Debug(viper.GetBool("verbose")).
LogFile(viper.GetString("log-file")).
Build()
if err != nil {
fmt.Fprintf(os.Stderr, "Can't build logger: %v\n", err)
os.Exit(1)
}
Debug(viper.GetBool("verbose")).
LogFile(viper.GetString("log-file")).
Build()
if err != nil {
fmt.Fprintf(os.Stderr, "Can't build logger: %v\n", err)
os.Exit(1)
}

if viper.Sub("ocm") == nil && viper.GetString("ocm-token") == "" {
logger.Fatal(cmd.Context(), "ocm section or ocm-token is necessary configuration")
if viper.Sub("ocm") == nil && (viper.GetString("ocm-token") == "" && (viper.GetString("client-id") == "" && viper.GetString("client-secret") == "")) {
logger.Fatal(cmd.Context(), "ocm-credentials are necessary configuration")
}
err = helpers.CreateFolder(cmd.Context(), viper.GetString("output-path"), logger)
if err != nil {
logger.Fatal(cmd.Context(), "creating api connection: %v", err)
logger.Fatal(cmd.Context(), "creating output folder: %v", err)
}
logger.Info(cmd.Context(), "Using output directory: %s", viper.GetString("output-path"))

Expand Down
73 changes: 40 additions & 33 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,64 +1,71 @@
module github.com/cloud-bulldozer/ocm-api-load

go 1.17
go 1.20

require (
github.com/Rican7/retry v0.3.1
github.com/cloud-bulldozer/go-commons v1.0.6
github.com/openshift-online/ocm-sdk-go v0.1.320
github.com/cloud-bulldozer/go-commons v1.0.16
github.com/openshift-online/ocm-sdk-go v0.1.428
github.com/satori/go.uuid v1.2.0
github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.15.0
github.com/tsenart/vegeta/v12 v12.8.4
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/tsenart/vegeta/v12 v12.11.1
github.com/zgalor/weberr v0.8.2
)

require (
github.com/elastic/go-elasticsearch/v7 v7.13.1 // indirect
github.com/opensearch-project/opensearch-go v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
)

require (
github.com/aymerick/douceur v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/golang-jwt/jwt/v4 v4.4.1 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/glog v1.2.1 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/influxdata/tdigest v0.0.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/microcosm-cc/bluemonday v1.0.18 // indirect
github.com/microcosm-cc/bluemonday v1.0.26 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.15.1 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/sirupsen/logrus v1.6.0 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rs/dnscache v0.0.0-20230804202142-fc85eb664529 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Expand Down
Loading

0 comments on commit 94c8782

Please sign in to comment.