From fcc66866988f433efab45d4922e069b36ac40785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20M=C3=B6ller?= Date: Thu, 8 Aug 2024 16:23:20 +0200 Subject: [PATCH] feat: Set negative cache fields as required options (#458) * feat: Set negative cache fields as required options following the Nexus API definition * fix: Fix all tests for data sources repository proxy --- docs/resources/repository_apt_proxy.md | 2 +- docs/resources/repository_bower_proxy.md | 2 +- docs/resources/repository_cocoapods_proxy.md | 2 +- docs/resources/repository_conan_proxy.md | 2 +- docs/resources/repository_conda_proxy.md | 2 +- docs/resources/repository_docker_proxy.md | 2 +- docs/resources/repository_go_proxy.md | 2 +- docs/resources/repository_helm_proxy.md | 2 +- docs/resources/repository_maven_proxy.md | 2 +- docs/resources/repository_npm_proxy.md | 2 +- docs/resources/repository_nuget_proxy.md | 2 +- docs/resources/repository_p2_proxy.md | 2 +- docs/resources/repository_pypi_proxy.md | 2 +- docs/resources/repository_r_proxy.md | 2 +- docs/resources/repository_raw_proxy.md | 2 +- docs/resources/repository_rubygems_proxy.md | 2 +- docs/resources/repository_yum_proxy.md | 2 +- internal/acceptance/template-strings-repository.go | 6 ------ internal/schema/repository/schema_negative_cache.go | 6 ++---- .../repository/data_source_repository_apt_proxy_test.go | 4 ++++ .../repository/data_source_repository_bower_proxy_test.go | 4 ++++ .../data_source_repository_cocoapods_proxy_test.go | 4 ++++ .../repository/data_source_repository_conan_proxy_test.go | 4 ++++ .../repository/data_source_repository_conda_proxy_test.go | 4 ++++ .../repository/data_source_repository_docker_proxy_test.go | 4 ++++ .../repository/data_source_repository_go_proxy_test.go | 4 ++++ .../repository/data_source_repository_helm_proxy_test.go | 4 ++++ .../repository/data_source_repository_maven_proxy_test.go | 4 ++++ .../repository/data_source_repository_npm_proxy_test.go | 4 ++++ .../repository/data_source_repository_nuget_proxy_test.go | 4 ++++ .../repository/data_source_repository_p2_proxy_test.go | 4 ++++ .../repository/data_source_repository_pypi_proxy_test.go | 4 ++++ .../repository/data_source_repository_r_proxy_test.go | 4 ++++ .../repository/data_source_repository_raw_proxy_test.go | 4 ++++ .../data_source_repository_rubygems_proxy_test.go | 4 ++++ .../repository/data_source_repository_yum_proxy_test.go | 4 ++++ 36 files changed, 87 insertions(+), 27 deletions(-) diff --git a/docs/resources/repository_apt_proxy.md b/docs/resources/repository_apt_proxy.md index 7284196b..dd3a9bff 100644 --- a/docs/resources/repository_apt_proxy.md +++ b/docs/resources/repository_apt_proxy.md @@ -121,7 +121,7 @@ Optional: ### 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) diff --git a/docs/resources/repository_bower_proxy.md b/docs/resources/repository_bower_proxy.md index dcb147f6..00427b27 100644 --- a/docs/resources/repository_bower_proxy.md +++ b/docs/resources/repository_bower_proxy.md @@ -103,7 +103,7 @@ Optional: ### 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) diff --git a/docs/resources/repository_cocoapods_proxy.md b/docs/resources/repository_cocoapods_proxy.md index b89b4942..8d70a8a3 100644 --- a/docs/resources/repository_cocoapods_proxy.md +++ b/docs/resources/repository_cocoapods_proxy.md @@ -100,7 +100,7 @@ Optional: ### 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) diff --git a/docs/resources/repository_conan_proxy.md b/docs/resources/repository_conan_proxy.md index 200810c3..396dc7fe 100644 --- a/docs/resources/repository_conan_proxy.md +++ b/docs/resources/repository_conan_proxy.md @@ -100,7 +100,7 @@ Optional: ### 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) diff --git a/docs/resources/repository_conda_proxy.md b/docs/resources/repository_conda_proxy.md index bf128041..62a8b79d 100644 --- a/docs/resources/repository_conda_proxy.md +++ b/docs/resources/repository_conda_proxy.md @@ -100,7 +100,7 @@ Optional: ### 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) diff --git a/docs/resources/repository_docker_proxy.md b/docs/resources/repository_docker_proxy.md index 80eedf60..ee99365c 100644 --- a/docs/resources/repository_docker_proxy.md +++ b/docs/resources/repository_docker_proxy.md @@ -139,7 +139,7 @@ Optional: ### 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) diff --git a/docs/resources/repository_go_proxy.md b/docs/resources/repository_go_proxy.md index 3a150560..b140a97a 100644 --- a/docs/resources/repository_go_proxy.md +++ b/docs/resources/repository_go_proxy.md @@ -101,7 +101,7 @@ Optional: ### 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) diff --git a/docs/resources/repository_helm_proxy.md b/docs/resources/repository_helm_proxy.md index ec65c833..fd168a85 100644 --- a/docs/resources/repository_helm_proxy.md +++ b/docs/resources/repository_helm_proxy.md @@ -101,7 +101,7 @@ Optional: ### 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) diff --git a/docs/resources/repository_maven_proxy.md b/docs/resources/repository_maven_proxy.md index 24d4cfe0..39f76035 100644 --- a/docs/resources/repository_maven_proxy.md +++ b/docs/resources/repository_maven_proxy.md @@ -120,7 +120,7 @@ Optional: ### 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) diff --git a/docs/resources/repository_npm_proxy.md b/docs/resources/repository_npm_proxy.md index 9e08947f..1276c511 100644 --- a/docs/resources/repository_npm_proxy.md +++ b/docs/resources/repository_npm_proxy.md @@ -102,7 +102,7 @@ Optional: ### 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) diff --git a/docs/resources/repository_nuget_proxy.md b/docs/resources/repository_nuget_proxy.md index 2aed8ea8..04d3d56a 100644 --- a/docs/resources/repository_nuget_proxy.md +++ b/docs/resources/repository_nuget_proxy.md @@ -105,7 +105,7 @@ Optional: ### 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) diff --git a/docs/resources/repository_p2_proxy.md b/docs/resources/repository_p2_proxy.md index c1ada7f0..d70b4a00 100644 --- a/docs/resources/repository_p2_proxy.md +++ b/docs/resources/repository_p2_proxy.md @@ -100,7 +100,7 @@ Optional: ### 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) diff --git a/docs/resources/repository_pypi_proxy.md b/docs/resources/repository_pypi_proxy.md index 66f4a6b1..34a825d7 100644 --- a/docs/resources/repository_pypi_proxy.md +++ b/docs/resources/repository_pypi_proxy.md @@ -100,7 +100,7 @@ Optional: ### 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) diff --git a/docs/resources/repository_r_proxy.md b/docs/resources/repository_r_proxy.md index 75d0487b..4082003f 100644 --- a/docs/resources/repository_r_proxy.md +++ b/docs/resources/repository_r_proxy.md @@ -100,7 +100,7 @@ Optional: ### 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) diff --git a/docs/resources/repository_raw_proxy.md b/docs/resources/repository_raw_proxy.md index c0e500ee..0cecd465 100644 --- a/docs/resources/repository_raw_proxy.md +++ b/docs/resources/repository_raw_proxy.md @@ -101,7 +101,7 @@ Optional: ### 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) diff --git a/docs/resources/repository_rubygems_proxy.md b/docs/resources/repository_rubygems_proxy.md index afca4834..9e753b55 100644 --- a/docs/resources/repository_rubygems_proxy.md +++ b/docs/resources/repository_rubygems_proxy.md @@ -100,7 +100,7 @@ Optional: ### 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) diff --git a/docs/resources/repository_yum_proxy.md b/docs/resources/repository_yum_proxy.md index 56b14150..5a98833f 100644 --- a/docs/resources/repository_yum_proxy.md +++ b/docs/resources/repository_yum_proxy.md @@ -101,7 +101,7 @@ Optional: ### 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) diff --git a/internal/acceptance/template-strings-repository.go b/internal/acceptance/template-strings-repository.go index c5c76cba..d35b10f6 100644 --- a/internal/acceptance/template-strings-repository.go +++ b/internal/acceptance/template-strings-repository.go @@ -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 = ` diff --git a/internal/schema/repository/schema_negative_cache.go b/internal/schema/repository/schema_negative_cache.go index db374b7b..0fd5d24e 100644 --- a/internal/schema/repository/schema_negative_cache.go +++ b/internal/schema/repository/schema_negative_cache.go @@ -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, }, }, diff --git a/internal/services/repository/data_source_repository_apt_proxy_test.go b/internal/services/repository/data_source_repository_apt_proxy_test.go index 5b63b238..d6c56c02 100644 --- a/internal/services/repository/data_source_repository_apt_proxy_test.go +++ b/internal/services/repository/data_source_repository_apt_proxy_test.go @@ -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" diff --git a/internal/services/repository/data_source_repository_bower_proxy_test.go b/internal/services/repository/data_source_repository_bower_proxy_test.go index 4878e0db..249236c5 100644 --- a/internal/services/repository/data_source_repository_bower_proxy_test.go +++ b/internal/services/repository/data_source_repository_bower_proxy_test.go @@ -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, }, diff --git a/internal/services/repository/data_source_repository_cocoapods_proxy_test.go b/internal/services/repository/data_source_repository_cocoapods_proxy_test.go index 4e02a6eb..65557251 100644 --- a/internal/services/repository/data_source_repository_cocoapods_proxy_test.go +++ b/internal/services/repository/data_source_repository_cocoapods_proxy_test.go @@ -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" diff --git a/internal/services/repository/data_source_repository_conan_proxy_test.go b/internal/services/repository/data_source_repository_conan_proxy_test.go index 1b7beb8f..a84dd947 100644 --- a/internal/services/repository/data_source_repository_conan_proxy_test.go +++ b/internal/services/repository/data_source_repository_conan_proxy_test.go @@ -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" diff --git a/internal/services/repository/data_source_repository_conda_proxy_test.go b/internal/services/repository/data_source_repository_conda_proxy_test.go index e9f800a3..9bb50739 100644 --- a/internal/services/repository/data_source_repository_conda_proxy_test.go +++ b/internal/services/repository/data_source_repository_conda_proxy_test.go @@ -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" diff --git a/internal/services/repository/data_source_repository_docker_proxy_test.go b/internal/services/repository/data_source_repository_docker_proxy_test.go index 837ca11c..3bf5fa26 100644 --- a/internal/services/repository/data_source_repository_docker_proxy_test.go +++ b/internal/services/repository/data_source_repository_docker_proxy_test.go @@ -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" diff --git a/internal/services/repository/data_source_repository_go_proxy_test.go b/internal/services/repository/data_source_repository_go_proxy_test.go index 02827a13..73c7367f 100644 --- a/internal/services/repository/data_source_repository_go_proxy_test.go +++ b/internal/services/repository/data_source_repository_go_proxy_test.go @@ -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" diff --git a/internal/services/repository/data_source_repository_helm_proxy_test.go b/internal/services/repository/data_source_repository_helm_proxy_test.go index af7d7fa3..2f285f0b 100644 --- a/internal/services/repository/data_source_repository_helm_proxy_test.go +++ b/internal/services/repository/data_source_repository_helm_proxy_test.go @@ -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" diff --git a/internal/services/repository/data_source_repository_maven_proxy_test.go b/internal/services/repository/data_source_repository_maven_proxy_test.go index ac3d657c..50fc61a8 100644 --- a/internal/services/repository/data_source_repository_maven_proxy_test.go +++ b/internal/services/repository/data_source_repository_maven_proxy_test.go @@ -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, diff --git a/internal/services/repository/data_source_repository_npm_proxy_test.go b/internal/services/repository/data_source_repository_npm_proxy_test.go index 22253643..6b707185 100644 --- a/internal/services/repository/data_source_repository_npm_proxy_test.go +++ b/internal/services/repository/data_source_repository_npm_proxy_test.go @@ -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, diff --git a/internal/services/repository/data_source_repository_nuget_proxy_test.go b/internal/services/repository/data_source_repository_nuget_proxy_test.go index 63cab994..db0277c1 100644 --- a/internal/services/repository/data_source_repository_nuget_proxy_test.go +++ b/internal/services/repository/data_source_repository_nuget_proxy_test.go @@ -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, diff --git a/internal/services/repository/data_source_repository_p2_proxy_test.go b/internal/services/repository/data_source_repository_p2_proxy_test.go index 81ee08ea..6d5bc13d 100644 --- a/internal/services/repository/data_source_repository_p2_proxy_test.go +++ b/internal/services/repository/data_source_repository_p2_proxy_test.go @@ -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" diff --git a/internal/services/repository/data_source_repository_pypi_proxy_test.go b/internal/services/repository/data_source_repository_pypi_proxy_test.go index 49443aae..b1283d84 100644 --- a/internal/services/repository/data_source_repository_pypi_proxy_test.go +++ b/internal/services/repository/data_source_repository_pypi_proxy_test.go @@ -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" diff --git a/internal/services/repository/data_source_repository_r_proxy_test.go b/internal/services/repository/data_source_repository_r_proxy_test.go index c8d6e63e..de417fa9 100644 --- a/internal/services/repository/data_source_repository_r_proxy_test.go +++ b/internal/services/repository/data_source_repository_r_proxy_test.go @@ -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" diff --git a/internal/services/repository/data_source_repository_raw_proxy_test.go b/internal/services/repository/data_source_repository_raw_proxy_test.go index a5c602ce..d23d1fda 100644 --- a/internal/services/repository/data_source_repository_raw_proxy_test.go +++ b/internal/services/repository/data_source_repository_raw_proxy_test.go @@ -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" diff --git a/internal/services/repository/data_source_repository_rubygems_proxy_test.go b/internal/services/repository/data_source_repository_rubygems_proxy_test.go index ece69c13..f989c516 100644 --- a/internal/services/repository/data_source_repository_rubygems_proxy_test.go +++ b/internal/services/repository/data_source_repository_rubygems_proxy_test.go @@ -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" diff --git a/internal/services/repository/data_source_repository_yum_proxy_test.go b/internal/services/repository/data_source_repository_yum_proxy_test.go index 8620aff0..0fc9502c 100644 --- a/internal/services/repository/data_source_repository_yum_proxy_test.go +++ b/internal/services/repository/data_source_repository_yum_proxy_test.go @@ -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"