Skip to content

Commit

Permalink
feat: Set negative cache fields as required options (#458)
Browse files Browse the repository at this point in the history
* feat: Set negative cache fields as required options

following the Nexus API definition

* fix: Fix all tests for data sources repository proxy
  • Loading branch information
anmoel authored Aug 8, 2024
1 parent e0ec59f commit fcc6686
Show file tree
Hide file tree
Showing 36 changed files with 87 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docs/resources/repository_apt_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Optional:
<a id="nestedblock--negative_cache"></a>
### Nested Schema for `negative_cache`

Optional:
Required:

- `enabled` (Boolean) Whether to cache responses for content not present in the proxied repository
- `ttl` (Number) How long to cache the fact that a file was not found in the repository (in minutes)
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/repository_bower_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Optional:
<a id="nestedblock--negative_cache"></a>
### Nested Schema for `negative_cache`

Optional:
Required:

- `enabled` (Boolean) Whether to cache responses for content not present in the proxied repository
- `ttl` (Number) How long to cache the fact that a file was not found in the repository (in minutes)
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/repository_cocoapods_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Optional:
<a id="nestedblock--negative_cache"></a>
### Nested Schema for `negative_cache`

Optional:
Required:

- `enabled` (Boolean) Whether to cache responses for content not present in the proxied repository
- `ttl` (Number) How long to cache the fact that a file was not found in the repository (in minutes)
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/repository_conan_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Optional:
<a id="nestedblock--negative_cache"></a>
### Nested Schema for `negative_cache`

Optional:
Required:

- `enabled` (Boolean) Whether to cache responses for content not present in the proxied repository
- `ttl` (Number) How long to cache the fact that a file was not found in the repository (in minutes)
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/repository_conda_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Optional:
<a id="nestedblock--negative_cache"></a>
### Nested Schema for `negative_cache`

Optional:
Required:

- `enabled` (Boolean) Whether to cache responses for content not present in the proxied repository
- `ttl` (Number) How long to cache the fact that a file was not found in the repository (in minutes)
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/repository_docker_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Optional:
<a id="nestedblock--negative_cache"></a>
### Nested Schema for `negative_cache`

Optional:
Required:

- `enabled` (Boolean) Whether to cache responses for content not present in the proxied repository
- `ttl` (Number) How long to cache the fact that a file was not found in the repository (in minutes)
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/repository_go_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Optional:
<a id="nestedblock--negative_cache"></a>
### Nested Schema for `negative_cache`

Optional:
Required:

- `enabled` (Boolean) Whether to cache responses for content not present in the proxied repository
- `ttl` (Number) How long to cache the fact that a file was not found in the repository (in minutes)
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/repository_helm_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Optional:
<a id="nestedblock--negative_cache"></a>
### Nested Schema for `negative_cache`

Optional:
Required:

- `enabled` (Boolean) Whether to cache responses for content not present in the proxied repository
- `ttl` (Number) How long to cache the fact that a file was not found in the repository (in minutes)
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/repository_maven_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Optional:
<a id="nestedblock--negative_cache"></a>
### Nested Schema for `negative_cache`

Optional:
Required:

- `enabled` (Boolean) Whether to cache responses for content not present in the proxied repository
- `ttl` (Number) How long to cache the fact that a file was not found in the repository (in minutes)
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/repository_npm_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Optional:
<a id="nestedblock--negative_cache"></a>
### Nested Schema for `negative_cache`

Optional:
Required:

- `enabled` (Boolean) Whether to cache responses for content not present in the proxied repository
- `ttl` (Number) How long to cache the fact that a file was not found in the repository (in minutes)
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/repository_nuget_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Optional:
<a id="nestedblock--negative_cache"></a>
### Nested Schema for `negative_cache`

Optional:
Required:

- `enabled` (Boolean) Whether to cache responses for content not present in the proxied repository
- `ttl` (Number) How long to cache the fact that a file was not found in the repository (in minutes)
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/repository_p2_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Optional:
<a id="nestedblock--negative_cache"></a>
### Nested Schema for `negative_cache`

Optional:
Required:

- `enabled` (Boolean) Whether to cache responses for content not present in the proxied repository
- `ttl` (Number) How long to cache the fact that a file was not found in the repository (in minutes)
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/repository_pypi_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Optional:
<a id="nestedblock--negative_cache"></a>
### Nested Schema for `negative_cache`

Optional:
Required:

- `enabled` (Boolean) Whether to cache responses for content not present in the proxied repository
- `ttl` (Number) How long to cache the fact that a file was not found in the repository (in minutes)
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/repository_r_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Optional:
<a id="nestedblock--negative_cache"></a>
### Nested Schema for `negative_cache`

Optional:
Required:

- `enabled` (Boolean) Whether to cache responses for content not present in the proxied repository
- `ttl` (Number) How long to cache the fact that a file was not found in the repository (in minutes)
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/repository_raw_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Optional:
<a id="nestedblock--negative_cache"></a>
### Nested Schema for `negative_cache`

Optional:
Required:

- `enabled` (Boolean) Whether to cache responses for content not present in the proxied repository
- `ttl` (Number) How long to cache the fact that a file was not found in the repository (in minutes)
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/repository_rubygems_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Optional:
<a id="nestedblock--negative_cache"></a>
### Nested Schema for `negative_cache`

Optional:
Required:

- `enabled` (Boolean) Whether to cache responses for content not present in the proxied repository
- `ttl` (Number) How long to cache the fact that a file was not found in the repository (in minutes)
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/repository_yum_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Optional:
<a id="nestedblock--negative_cache"></a>
### Nested Schema for `negative_cache`

Optional:
Required:

- `enabled` (Boolean) Whether to cache responses for content not present in the proxied repository
- `ttl` (Number) How long to cache the fact that a file was not found in the repository (in minutes)
Expand Down
6 changes: 0 additions & 6 deletions internal/acceptance/template-strings-repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,10 @@ group {
`

TemplateStringNegativeCache = `
{{ if .NegativeCache }}
negative_cache {
{{ if .NegativeCache.Enabled }}
enabled = {{ .NegativeCache.Enabled }}
{{ end -}}
{{ if .NegativeCache.TTL }}
ttl = {{ .NegativeCache.TTL }}
{{ end }}
}
{{ end -}}
`

TemplateStringProxy = `
Expand Down
6 changes: 2 additions & 4 deletions internal/schema/repository/schema_negative_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ var (
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Default: false,
Description: "Whether to cache responses for content not present in the proxied repository",
Optional: true,
Required: true,
Type: schema.TypeBool,
},
"ttl": {
Default: 1440,
Description: "How long to cache the fact that a file was not found in the repository (in minutes)",
Optional: true,
Required: true,
Type: schema.TypeInt,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ func TestAccDataSourceRepositoryAptProxy(t *testing.T) {
BlobStoreName: "default",
StrictContentTypeValidation: true,
},
NegativeCache: repository.NegativeCache{
Enabled: true,
TTL: 5,
},
}

dataSourceName := "data.nexus_repository_apt_proxy.acceptance"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func TestAccDataSourceRepositoryBowerProxy(t *testing.T) {
BlobStoreName: "default",
StrictContentTypeValidation: true,
},
NegativeCache: repository.NegativeCache{
Enabled: true,
TTL: 5,
},
Bower: repository.Bower{
RewritePackageUrls: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func TestAccDataSourceRepositoryCocoapodsProxy(t *testing.T) {
BlobStoreName: "default",
StrictContentTypeValidation: true,
},
NegativeCache: repository.NegativeCache{
Enabled: true,
TTL: 5,
},
}

dataSourceName := "data.nexus_repository_cocoapods_proxy.acceptance"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func TestAccDataSourceRepositoryConanProxy(t *testing.T) {
BlobStoreName: "default",
StrictContentTypeValidation: true,
},
NegativeCache: repository.NegativeCache{
Enabled: true,
TTL: 5,
},
}

dataSourceName := "data.nexus_repository_conan_proxy.acceptance"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func TestAccDataSourceRepositoryCondaProxy(t *testing.T) {
BlobStoreName: "default",
StrictContentTypeValidation: true,
},
NegativeCache: repository.NegativeCache{
Enabled: true,
TTL: 5,
},
}

dataSourceName := "data.nexus_repository_conda_proxy.acceptance"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func TestAccDataSourceRepositoryDockerProxy(t *testing.T) {
BlobStoreName: "default",
StrictContentTypeValidation: true,
},
NegativeCache: repository.NegativeCache{
Enabled: true,
TTL: 5,
},
}
repo.Docker.Subdomain = &subdomain
dataSourceName := "data.nexus_repository_docker_proxy.acceptance"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func TestAccDataSourceRepositoryGoProxy(t *testing.T) {
BlobStoreName: "default",
StrictContentTypeValidation: true,
},
NegativeCache: repository.NegativeCache{
Enabled: true,
TTL: 5,
},
}

dataSourceName := "data.nexus_repository_go_proxy.acceptance"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func TestAccDataSourceRepositoryHelmProxy(t *testing.T) {
BlobStoreName: "default",
StrictContentTypeValidation: true,
},
NegativeCache: repository.NegativeCache{
Enabled: true,
TTL: 5,
},
}

dataSourceName := "data.nexus_repository_helm_proxy.acceptance"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func TestAccDataSourceRepositoryMavenProxy(t *testing.T) {
BlobStoreName: "default",
StrictContentTypeValidation: true,
},
NegativeCache: repository.NegativeCache{
Enabled: true,
TTL: 5,
},
Maven: repository.Maven{
VersionPolicy: repository.MavenVersionPolicyRelease,
LayoutPolicy: repository.MavenLayoutPolicyStrict,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func TestAccDataSourceRepositoryNpmProxy(t *testing.T) {
BlobStoreName: "default",
StrictContentTypeValidation: true,
},
NegativeCache: repository.NegativeCache{
Enabled: true,
TTL: 5,
},
Npm: &repository.Npm{
RemoveNonCataloged: false,
RemoveQuarantined: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func TestAccDataSourceRepositoryNugetProxy(t *testing.T) {
BlobStoreName: "default",
StrictContentTypeValidation: true,
},
NegativeCache: repository.NegativeCache{
Enabled: true,
TTL: 5,
},
NugetProxy: repository.NugetProxy{
NugetVersion: repository.NugetVersion2,
QueryCacheItemMaxAge: 300,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func TestAccDataSourceRepositoryP2Proxy(t *testing.T) {
BlobStoreName: "default",
StrictContentTypeValidation: true,
},
NegativeCache: repository.NegativeCache{
Enabled: true,
TTL: 5,
},
}

dataSourceName := "data.nexus_repository_p2_proxy.acceptance"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func TestAccDataSourceRepositoryPypiProxy(t *testing.T) {
BlobStoreName: "default",
StrictContentTypeValidation: true,
},
NegativeCache: repository.NegativeCache{
Enabled: true,
TTL: 5,
},
}

dataSourceName := "data.nexus_repository_pypi_proxy.acceptance"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func TestAccDataSourceRepositoryRProxy(t *testing.T) {
BlobStoreName: "default",
StrictContentTypeValidation: true,
},
NegativeCache: repository.NegativeCache{
Enabled: true,
TTL: 5,
},
}

dataSourceName := "data.nexus_repository_r_proxy.acceptance"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func TestAccDataSourceRepositoryRawProxy(t *testing.T) {
BlobStoreName: "default",
StrictContentTypeValidation: true,
},
NegativeCache: repository.NegativeCache{
Enabled: true,
TTL: 5,
},
}

dataSourceName := "data.nexus_repository_raw_proxy.acceptance"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func TestAccDataSourceRepositoryRubygemsProxy(t *testing.T) {
BlobStoreName: "default",
StrictContentTypeValidation: true,
},
NegativeCache: repository.NegativeCache{
Enabled: true,
TTL: 5,
},
}

dataSourceName := "data.nexus_repository_rubygems_proxy.acceptance"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func TestAccDataSourceRepositoryYumProxy(t *testing.T) {
BlobStoreName: "default",
StrictContentTypeValidation: true,
},
NegativeCache: repository.NegativeCache{
Enabled: true,
TTL: 5,
},
}

dataSourceName := "data.nexus_repository_yum_proxy.acceptance"
Expand Down

0 comments on commit fcc6686

Please sign in to comment.