Skip to content

Commit

Permalink
Merge branch 'main' into restore-hooks-functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
mcalhoun authored Feb 4, 2025
2 parents baf5b92 + 18197b9 commit 9aa02a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
19 changes: 8 additions & 11 deletions pkg/store/artifactory_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ func NewArtifactoryStore(options ArtifactoryStoreOptions) (Store, error) {
if err != nil {
return nil, err
}
rtDetails.SetAccessToken(token)

// If the token is set to "anonymous", we don't need to set the access token.
if token != "anonymous" {
rtDetails.SetAccessToken(token)
}

serviceConfig, err := config.NewConfigBuilder().
SetServiceDetails(rtDetails).
Expand All @@ -89,7 +93,6 @@ func NewArtifactoryStore(options ArtifactoryStoreOptions) (Store, error) {
SetOverallRequestTimeout(1 * time.Minute).
SetHttpRetries(0).
Build()

if err != nil {
return nil, err
}
Expand All @@ -112,15 +115,9 @@ func (s *ArtifactoryStore) getKey(stack string, component string, key string) (s
return "", fmt.Errorf("stack delimiter is not set")
}

stackParts := strings.Split(stack, *s.stackDelimiter)
componentParts := strings.Split(component, "/")

parts := []string{s.repoName, s.prefix}
parts = append(parts, stackParts...)
parts = append(parts, componentParts...)
parts = append(parts, key)

return strings.ReplaceAll(strings.Join(parts, "/"), "//", "/"), nil
prefixParts := []string{s.repoName, s.prefix}
prefix := strings.Join(prefixParts, "/")
return getKey(prefix, *s.stackDelimiter, stack, component, key, "/")
}

func (s *ArtifactoryStore) Get(stack string, component string, key string) (interface{}, error) {
Expand Down
7 changes: 4 additions & 3 deletions website/docs/core-concepts/projects/configuration/stores.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ stores:
The Artifactory store supports using an access token for authentication. The access token can be set directly in the
`atmos.yaml` or via the `JFROG_ACCESS_TOKEN` or `ARTIFACTORY_ACCESS_TOKEN` environment variables.

NOTE: It is not recommended to set the access token in plain text in `atmos.yaml` as it is not secure. Specifying the
access token via config is allowed so that you can support the use case where you have multiple Artifactory stores
in `atmos.yaml` and you need to specify different access tokens for each. In this case, you can use the `!env`
It is also possible to specify the access token as `anonymous` to use the anonymous user to access the Artifactory
repository if the repository is configured to allow anonymous access.

**NOTE:** Storing sensitive access tokens in plain text in `atmos.yaml` is not secure and should be avoided. However, it's recommended for the `anonymous` use case or when managing multiple Artifactory stores with different access tokens. In such cases, use [`!env`](/core-concepts/stacks/yaml-functions/env) function to reference tokens securely.
YAML function to set the access token from an environment variable.

### AWS SSM Parameter Store
Expand Down

0 comments on commit 9aa02a6

Please sign in to comment.