Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
diogoasouza committed Jul 18, 2024
1 parent f7e2ae9 commit 47cfb68
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
29 changes: 29 additions & 0 deletions rancher2/schema_catalog_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
27 changes: 26 additions & 1 deletion rancher2/structure_catalog_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 47cfb68

Please sign in to comment.