Skip to content

Commit

Permalink
fix oss handling
Browse files Browse the repository at this point in the history
  • Loading branch information
schoren committed Jan 31, 2024
1 parent 97d89f0 commit a790a12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export VERSION?=dev
export TRACETEST_DEFAULT_CLOUD_ENDPOINT=https://app-stage.tracetest.io
export TRACETEST_DEFAULT_CLOUD_ENDPOINT=https://app.tracetest.io
TAG?=$(VERSION)
GORELEASER_VERSION=1.23.0-pro

Expand Down
19 changes: 12 additions & 7 deletions cli/config/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,16 @@ func (c Configurator) Start(ctx context.Context, prev *Config, flags agentConfig
return err
}

cfg, err = c.populateConfigWithVersionInfo(ctx, cfg)
cfg, err, isOSS := c.populateConfigWithVersionInfo(ctx, cfg)
if err != nil {
return err
}

if isOSS {
// we don't need anything else for OSS
return nil
}

if flags.CI {
err = Save(cfg)
if err != nil {
Expand Down Expand Up @@ -106,32 +111,32 @@ func (c Configurator) createConfig(serverURL string) (Config, error) {
}, nil
}

func (c Configurator) populateConfigWithVersionInfo(ctx context.Context, cfg Config) (Config, error) {
func (c Configurator) populateConfigWithVersionInfo(ctx context.Context, cfg Config) (_ Config, _ error, isOSS bool) {
client := GetAPIClient(cfg)
version, err := getVersionMetadata(ctx, client)
if err != nil {
return Config{}, fmt.Errorf("cannot get version metadata: %w", err)
return Config{}, fmt.Errorf("cannot get version metadata: %w", err), false
}

serverType := version.GetType()
if serverType == "oss" {
err := Save(cfg)
if err != nil {
return Config{}, fmt.Errorf("could not save configuration: %w", err)
return Config{}, fmt.Errorf("could not save configuration: %w", err), false
}

c.ui.Success("Successfully configured Tracetest CLI")
return cfg, nil
return cfg, nil, true
}

cfg.AgentEndpoint = version.GetAgentEndpoint()
cfg.UIEndpoint = version.GetUiEndpoint()
cfg.Scheme, cfg.Endpoint, cfg.ServerPath, err = ParseServerURL(version.GetApiEndpoint())
if err != nil {
return Config{}, fmt.Errorf("cannot parse server url: %w", err)
return Config{}, fmt.Errorf("cannot parse server url: %w", err), false
}

return cfg, nil
return cfg, nil, false
}

func (c Configurator) handleOAuth(ctx context.Context, cfg Config, prev *Config, flags agentConfig.Flags) (Config, error) {
Expand Down

0 comments on commit a790a12

Please sign in to comment.