diff --git a/rancher2/data_source_rancher2_catalog_v2.go b/rancher2/data_source_rancher2_catalog_v2.go index 028548e0..c7b81361 100644 --- a/rancher2/data_source_rancher2_catalog_v2.go +++ b/rancher2/data_source_rancher2_catalog_v2.go @@ -27,6 +27,24 @@ func dataSourceRancher2CatalogV2() *schema.Resource { Type: schema.TypeBool, Computed: true, }, + "exponential_backoff_max_wait": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Maximum amount of seconds to wait before retrying", + }, + "exponential_backoff_min_wait": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Minimum amount of seconds to wait before retrying", + }, + "exponential_backoff_max_retries": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Maximum number of retries before returning error", + }, "git_branch": { Type: schema.TypeString, Computed: true, @@ -35,6 +53,12 @@ func dataSourceRancher2CatalogV2() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "insecure_plain_http": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Only valid for OCI URL's. Allows insecure connections to registries without enforcing TLS checks", + }, "insecure": { Type: schema.TypeBool, Computed: true, diff --git a/rancher2/schema_catalog_v2.go b/rancher2/schema_catalog_v2.go index 4362c46a..d1af1239 100644 --- a/rancher2/schema_catalog_v2.go +++ b/rancher2/schema_catalog_v2.go @@ -53,6 +53,24 @@ func catalogV2Fields() map[string]*schema.Schema { Default: true, Description: "If disabled the repo clone will not be updated or allowed to be installed from", }, + "exponential_backoff_max_wait": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Maximum amount of seconds to wait before retrying", + }, + "exponential_backoff_min_wait": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Minimum amount of seconds to wait before retrying", + }, + "exponential_backoff_max_retries": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Maximum number of retries before returning error", + }, "git_branch": { Type: schema.TypeString, Optional: true, @@ -65,6 +83,12 @@ func catalogV2Fields() map[string]*schema.Schema { Description: "Git Repository containing Helm chart definitions", ConflictsWith: []string{"url"}, }, + "insecure_plain_http": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Only valid for OCI URL's. Allows insecure connections to registries without enforcing TLS checks", + }, "insecure": { Type: schema.TypeBool, Optional: true, diff --git a/rancher2/structure_catalog_v2.go b/rancher2/structure_catalog_v2.go index 32bd2fcc..8f345b11 100644 --- a/rancher2/structure_catalog_v2.go +++ b/rancher2/structure_catalog_v2.go @@ -41,6 +41,15 @@ func flattenCatalogV2(d *schema.ResourceData, in *ClusterRepo) error { d.Set("secret_name", in.Spec.ClientSecret.Name) d.Set("secret_namespace", in.Spec.ClientSecret.Namespace) } + + if in.Spec.ExponentialBackOffValues != nil { + d.Set("exponential_backoff_min_wait", in.Spec.ExponentialBackOffValues.MinWait) + d.Set("exponential_backoff_max_wait", in.Spec.ExponentialBackOffValues.MaxWait) + d.Set("exponential_backoff_max_retries", in.Spec.ExponentialBackOffValues.MaxRetries) + } + + d.Set("insecure_plain_http", in.Spec.InsecurePlainHTTP) + d.Set("service_account", in.Spec.ServiceAccount) d.Set("service_account_namespace", in.Spec.ServiceAccountNamespace) d.Set("url", in.Spec.URL) @@ -96,6 +105,39 @@ func expandCatalogV2(in *schema.ResourceData) (*ClusterRepo, error) { if v, ok := in.Get("insecure").(bool); ok { obj.Spec.InsecureSkipTLSverify = v } + if v, ok := in.Get("insecure_plain_http").(bool); ok { + obj.Spec.InsecurePlainHTTP = v + } + if v, ok := in.Get("exponential_backoff_min_wait").(int); ok { + if obj.Spec.ExponentialBackOffValues != nil { + obj.Spec.ExponentialBackOffValues.MinWait = v + } else { + obj.Spec.ExponentialBackOffValues = &v1.ExponentialBackOffValues{ + MinWait: v, + } + } + } + + if v, ok := in.Get("exponential_backoff_max_wait").(int); ok { + if obj.Spec.ExponentialBackOffValues != nil { + obj.Spec.ExponentialBackOffValues.MaxWait = v + } else { + obj.Spec.ExponentialBackOffValues = &v1.ExponentialBackOffValues{ + MaxWait: v, + } + } + } + + if v, ok := in.Get("exponential_backoff_max_retries").(int); ok { + if obj.Spec.ExponentialBackOffValues != nil { + obj.Spec.ExponentialBackOffValues.MaxRetries = v + } else { + obj.Spec.ExponentialBackOffValues = &v1.ExponentialBackOffValues{ + MaxRetries: v, + } + } + } + sName, nok := in.Get("secret_name").(string) sNamespace, nsok := in.Get("secret_namespace").(string) if nok && nsok && len(sName) > 0 { diff --git a/rancher2/structure_catalog_v2_test.go b/rancher2/structure_catalog_v2_test.go index 5b717528..bd54bcbe 100644 --- a/rancher2/structure_catalog_v2_test.go +++ b/rancher2/structure_catalog_v2_test.go @@ -28,10 +28,16 @@ func init() { "label1": "one", "label2": "two", } + testCatalogV2Conf.Spec.ExponentialBackOffValues = &managementClient.ExponentialBackOffValues{ + MinWait: 2, + MaxWait: 10, + MaxRetries: 5, + } testCatalogV2Conf.Spec.CABundle = []byte("test DER data") testCatalogV2Conf.Spec.Enabled = newTrue() testCatalogV2Conf.Spec.GitBranch = "git_branch" testCatalogV2Conf.Spec.GitRepo = "git_repo" + testCatalogV2Conf.Spec.InsecurePlainHTTP = false testCatalogV2Conf.Spec.InsecureSkipTLSverify = false testCatalogV2Conf.Spec.ClientSecret = &managementClient.SecretReference{ Name: "secret_name", @@ -42,17 +48,21 @@ func init() { testCatalogV2Conf.Spec.URL = "url" testCatalogV2Interface = map[string]interface{}{ - "name": "name", - "ca_bundle": "dGVzdCBERVIgZGF0YQ==", - "enabled": true, - "git_branch": "git_branch", - "git_repo": "git_repo", - "insecure": false, - "secret_name": "secret_name", - "secret_namespace": "secret_namespace", - "service_account": "service_account", - "service_account_namespace": "service_account_namespace", - "url": "url", + "name": "name", + "ca_bundle": "dGVzdCBERVIgZGF0YQ==", + "enabled": true, + "exponential_backoff_min_wait": 2, + "exponential_backoff_max_wait": 10, + "exponential_backoff_max_retries": 5, + "git_branch": "git_branch", + "git_repo": "git_repo", + "insecure": false, + "insecure_plain_http": false, + "secret_name": "secret_name", + "secret_namespace": "secret_namespace", + "service_account": "service_account", + "service_account_namespace": "service_account_namespace", + "url": "url", "annotations": map[string]interface{}{ "value1": "one", "value2": "two",