Skip to content

Commit e956610

Browse files
github-actions[bot]alemorcuqmatttrach
authored
feat: add refresh_interval support to catalog_v2 (#2202)
Co-authored-by: Alejandro Moreno <alemorcuq@gmail.com> Co-authored-by: Matt Trachier <matt.trachier@suse.com>
1 parent 296c351 commit e956610

7 files changed

Lines changed: 20 additions & 0 deletions

File tree

docs/data-sources/catalog_v2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ data "rancher2_catalog_v2" "foo" {
2929
* `git_branch` - (Computed) Git Repository branch containing Helm chart definitions. Default `master` (string)
3030
* `git_repo` - (Computed) The url of the catalog v2 repo (string)
3131
* `insecure` - (Computed) Use insecure HTTPS to download the repo's index. Default: `false` (bool)
32+
* `refresh_interval` - (Computed) Interval in seconds at which the Helm repository should be refreshed (int)
3233
* `secret_name` - (Computed) K8s secret name to be used to connect to the repo (string)
3334
* `secret_namespace` - (Computed) K8s secret namespace (string)
3435
* `service_account` - (Computed) K8s service account used to deploy charts instead of the end users credentials (string)

docs/guides/apps_marketplace.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ This resource has the following arguments definition:
2929
* `git_branch` - (Optional) Git Repository branch containing Helm chart definitions. Default `master` (string)
3030
* `git_repo` - (Optional) The url of the catalog v2 repo (string)
3131
* `insecure` - (Optional) Use insecure HTTPS to download the repo's index. Default: `false` (bool)
32+
* `refresh_interval` - (Optional/Computed) Interval in seconds at which the Helm repository should be refreshed (int)
3233
* `secret_name` - (Optional) K8s secret name to be used to connect to the repo (string)
3334
* `secret_namespace` - (Optional) K8s secret namespace (string)
3435
* `service_account` - (Optional) K8s service account used to deploy charts instead of the end users credentials (string)

docs/resources/catalog_v2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ The following arguments are supported:
3535
* `git_branch` - (Optional/Computed) Git Repository branch containing Helm chart definitions. Default `master` (string)
3636
* `git_repo` - (Optional) The url of the catalog v2 repo. Conflicts with `url` (string)
3737
* `insecure` - (Optional) Use insecure HTTPS to download the repo's index. Default: `false` (bool)
38+
* `refresh_interval` - (Optional/Computed) Interval in seconds at which the Helm repository should be refreshed (int)
3839
* `secret_name` - (Optional) K8s secret name to be used to connect to the repo (string)
3940
* `secret_namespace` - (Optional) K8s secret namespace (string)
4041
* `service_account` - (Optional) K8s service account used to deploy charts instead of the end users credentials (string)

rancher2/data_source_rancher2_catalog_v2.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ func dataSourceRancher2CatalogV2() *schema.Resource {
6767
Type: schema.TypeString,
6868
Computed: true,
6969
},
70+
"refresh_interval": {
71+
Type: schema.TypeInt,
72+
Computed: true,
73+
Description: "Interval in seconds at which the Helm repository should be refreshed",
74+
},
7075
"secret_name": {
7176
Type: schema.TypeString,
7277
Computed: true,

rancher2/schema_catalog_v2.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ func catalogV2Fields() map[string]*schema.Schema {
9999
Type: schema.TypeString,
100100
Computed: true,
101101
},
102+
"refresh_interval": {
103+
Type: schema.TypeInt,
104+
Optional: true,
105+
Computed: true,
106+
Description: "Interval in seconds at which the Helm repository should be refreshed",
107+
},
102108
"secret_name": {
103109
Type: schema.TypeString,
104110
Optional: true,

rancher2/structure_catalog_v2.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func flattenCatalogV2(d *schema.ResourceData, in *ClusterRepo) error {
4949
}
5050

5151
d.Set("insecure_plain_http", in.Spec.InsecurePlainHTTP)
52+
d.Set("refresh_interval", in.Spec.RefreshInterval)
5253

5354
d.Set("service_account", in.Spec.ServiceAccount)
5455
d.Set("service_account_namespace", in.Spec.ServiceAccountNamespace)
@@ -155,6 +156,9 @@ func expandCatalogV2(in *schema.ResourceData) (*ClusterRepo, error) {
155156
if v, ok := in.Get("url").(string); ok {
156157
obj.Spec.URL = v
157158
}
159+
if v, ok := in.Get("refresh_interval").(int); ok && v > 0 {
160+
obj.Spec.RefreshInterval = v
161+
}
158162

159163
return obj, nil
160164
}

rancher2/structure_catalog_v2_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func init() {
4646
testCatalogV2Conf.Spec.ServiceAccount = "service_account"
4747
testCatalogV2Conf.Spec.ServiceAccountNamespace = "service_account_namespace"
4848
testCatalogV2Conf.Spec.URL = "url"
49+
testCatalogV2Conf.Spec.RefreshInterval = 300
4950

5051
testCatalogV2Interface = map[string]interface{}{
5152
"name": "name",
@@ -63,6 +64,7 @@ func init() {
6364
"service_account": "service_account",
6465
"service_account_namespace": "service_account_namespace",
6566
"url": "url",
67+
"refresh_interval": 300,
6668
"annotations": map[string]interface{}{
6769
"value1": "one",
6870
"value2": "two",

0 commit comments

Comments
 (0)