From 47cfb685c139d1075c19f2dd19b432c5f5372553 Mon Sep 17 00:00:00 2001 From: Diogo Souza Date: Tue, 16 Jul 2024 19:35:59 -0300 Subject: [PATCH] testing --- go.mod | 2 +- rancher2/schema_catalog_v2.go | 29 +++++++++++++++++++++++++++++ rancher2/structure_catalog_v2.go | 27 ++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index ba5d7556..35a259c4 100644 --- a/go.mod +++ b/go.mod @@ -207,4 +207,4 @@ replace ( k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.30.1 k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.30.1 launchpad.net/gocheck => github.com/go-check/check v0.0.0-20200227125254-8fa46927fb4f -) +) \ No newline at end of file diff --git a/rancher2/schema_catalog_v2.go b/rancher2/schema_catalog_v2.go index 4362c46a..70f093e0 100644 --- a/rancher2/schema_catalog_v2.go +++ b/rancher2/schema_catalog_v2.go @@ -53,6 +53,29 @@ 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_values": { + Type: schema.TypeMap, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "min_wait": { + Type: schema.TypeInt, + Optional: true, + Description: "Minimum amount of seconds to wait before retrying", + }, + "max_wait": { + Type: schema.TypeInt, + Optional: true, + Description: "Maximum amount of seconds to wait before retrying", + }, + "max_retries": { + Type: schema.TypeInt, + Optional: true, + Description: "Maximum number of retries before returning error", + }, + }, + }, + }, "git_branch": { Type: schema.TypeString, Optional: true, @@ -65,6 +88,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..4ba418d8 100644 --- a/rancher2/structure_catalog_v2.go +++ b/rancher2/structure_catalog_v2.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/rancher/rancher/pkg/apis/catalog.cattle.io/v1" + v1 "github.com/rancher/rancher/pkg/apis/catalog.cattle.io/v1" ) // Flatteners @@ -41,6 +41,17 @@ 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_values", map[string]interface{}{ + "min_wait": in.Spec.ExponentialBackOffValues.MinWait, + "max_wait": in.Spec.ExponentialBackOffValues.MaxWait, + "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 +107,20 @@ 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_values").(map[string]interface{}); ok { + if v, ok := v["min_wait"]; ok { + obj.Spec.ExponentialBackOffValues.MinWait = v.(int) + } + if v, ok := v["max_wait"]; ok { + obj.Spec.ExponentialBackOffValues.MaxWait = v.(int) + } + if v, ok := v["max_retries"]; ok { + obj.Spec.ExponentialBackOffValues.MaxRetries = v.(int) + } + } sName, nok := in.Get("secret_name").(string) sNamespace, nsok := in.Get("secret_namespace").(string) if nok && nsok && len(sName) > 0 {