Skip to content

Commit

Permalink
🚸 Lookup QODANA_TOKEN in the environment
Browse files Browse the repository at this point in the history
  • Loading branch information
tiulpin committed Jun 24, 2022
1 parent bc96d38 commit b163d2a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions core/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ var (
Timestamps: false,
}
containerName = "qodana-cli"
qodanaEnv = "QODANA_ENV"
qodanaToken = "QODANA_TOKEN"
)

// CheckDockerHost checks if the host is ready to run Qodana Docker images.
Expand Down Expand Up @@ -209,14 +211,24 @@ func GetCmdOptions(opts *QodanaOptions) []string {

// getDockerOptions returns qodana docker container options.
func getDockerOptions(opts *QodanaOptions) *types.ContainerCreateConfig {
tokenConfigured := false
for _, env := range opts.Env {
if strings.HasPrefix(env, qodanaToken+"=") {
tokenConfigured = true
}
}
if !tokenConfigured {
opts.Env = append(opts.Env, fmt.Sprintf("%s=%s", qodanaToken, os.Getenv(qodanaToken)))
}

envConfigured := false
for _, env := range opts.Env {
if strings.HasPrefix(env, "QODANA_ENV=") {
if strings.HasPrefix(env, qodanaEnv+"=") {
envConfigured = true
}
}
if !envConfigured {
opts.Env = append(opts.Env, "QODANA_ENV=cli:"+Version)
opts.Env = append(opts.Env, qodanaEnv+"=cli:"+Version)
}

cachePath, err := filepath.Abs(opts.CacheDir)
Expand Down

0 comments on commit b163d2a

Please sign in to comment.