Skip to content

Commit

Permalink
Merge pull request #263 from tenstad/helm-remote-external-dependencies
Browse files Browse the repository at this point in the history
Add external dependencies fields to helm remote
  • Loading branch information
alexhung authored Jan 10, 2022
2 parents 6729986 + 447d579 commit 7272931
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
10 changes: 8 additions & 2 deletions docs/resources/artifactory_remote_helm_repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Provides an Artifactory remote `helm` repository resource. This provides helm sp
Official documentation can be found [here](https://www.jfrog.com/confluence/display/JFROG/Package+Management),
although helm is (currently) not listed as a supported format


## Example Usage
## Example Usage
Includes only new and relevant fields, for anything else, see: [generic repo](artifactory_remote_docker_repository.md).
```hcl
Expand All @@ -14,6 +12,10 @@ resource "artifactory_remote_helm_repository" "helm-remote" {
key = "helm-remote-foo25"
url = "https://repo.chartcenter.io/"
helm_charts_base_url = "https://foo.com"
external_dependencies_enabled = true
external_dependencies_patterns = [
"**github.com**"
]
}
```

Expand All @@ -24,3 +26,7 @@ All generic repo arguments are supported, in addition to:

* `key` - (Required) The repository identifier. Must be unique system-wide
* `helm_charts_base_url` - (Optional) - No documentation is available. Hopefully you know what this means
* `external_dependencies_enabled` - (Optional) When set, external dependencies are rewritten.
* `external_dependencies_patterns` - (Optional) An Allow List of Ant-style path expressions that specify where external
dependencies may be downloaded from. By default, this is set to ** which means that dependencies may be downloaded
from any external source.
27 changes: 24 additions & 3 deletions pkg/artifactory/resource_artifactory_remote_helm_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,30 @@ var helmRemoteSchema = mergeSchema(baseRemoteSchema, map[string]*schema.Schema{
Description: "Base URL for the translation of chart source URLs in the index.yaml of virtual repos. " +
"Artifactory will only translate URLs matching the index.yamls hostname or URLs starting with this base url.",
},
"external_dependencies_enabled": {
Type: schema.TypeBool,
Default: false,
Optional: true,
Description: "When set, external dependencies are rewritten.",
},
"external_dependencies_patterns": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
RequiredWith: []string{"external_dependencies_enabled"},
Description: "An Allow List of Ant-style path expressions that specify where external dependencies may be downloaded from. " +
"By default, this is set to ** which means that dependencies may be downloaded from any external source.",
},
})

type HelmRemoteRepo struct {
RemoteRepositoryBaseParams
HelmChartsBaseURL string `hcl:"helm_charts_base_url" json:"chartsBaseUrl,omitempty"`
HelmChartsBaseURL string `hcl:"helm_charts_base_url" json:"chartsBaseUrl"`
ExternalDependenciesEnabled bool `hcl:"external_dependencies_enabled" json:"externalDependenciesEnabled"`
ExternalDependenciesPatterns []string `hcl:"external_dependencies_patterns" json:"externalDependenciesPatterns"`
}

func resourceArtifactoryRemoteHelmRepository() *schema.Resource {
Expand All @@ -34,8 +53,10 @@ func resourceArtifactoryRemoteHelmRepository() *schema.Resource {
func unpackhelmRemoteRepo(s *schema.ResourceData) (interface{}, string, error) {
d := &ResourceData{s}
repo := HelmRemoteRepo{
RemoteRepositoryBaseParams: unpackBaseRemoteRepo(s, "helm"),
HelmChartsBaseURL: d.getString("helm_charts_base_url", false),
RemoteRepositoryBaseParams: unpackBaseRemoteRepo(s, "helm"),
HelmChartsBaseURL: d.getString("helm_charts_base_url", false),
ExternalDependenciesEnabled: d.getBool("external_dependencies_enabled", false),
ExternalDependenciesPatterns: d.getList("external_dependencies_patterns"),
}
return repo, repo.Id(), nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ func TestAccRemoteCargoRepository(t *testing.T) {

func TestAccRemoteHelmRepository(t *testing.T) {
resource.Test(mkNewRemoteTestCase("helm", t, map[string]interface{}{
"helm_charts_base_url": "https://github.com/rust-lang/foo.index",
"missed_cache_period_seconds": 1800, // https://github.com/jfrog/terraform-provider-artifactory/issues/225
"helm_charts_base_url": "https://github.com/rust-lang/foo.index",
"missed_cache_period_seconds": 1800, // https://github.com/jfrog/terraform-provider-artifactory/issues/225
"external_dependencies_enabled": true,
"external_dependencies_patterns": []interface{}{"**github.com**"},
}))
}

Expand Down

0 comments on commit 7272931

Please sign in to comment.