Skip to content

Commit dc2ec98

Browse files
docs: DOC-1208 updated the documentation for the pack data resources (#464)
* docs: DOC-1208 updated the documentation for the pack data resources * chore: fixed resource name in example * docs: added types definition
1 parent a9d784a commit dc2ec98

File tree

6 files changed

+113
-24
lines changed

6 files changed

+113
-24
lines changed

docs/data-sources/pack.md

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,52 @@
11
---
2-
# generated by https://github.com/hashicorp/terraform-plugin-docs
32
page_title: "spectrocloud_pack Data Source - terraform-provider-spectrocloud"
43
subcategory: ""
54
description: |-
6-
5+
This data resource provides the ability to search for a pack in the Palette registries. It supports more advanced search criteria than the pack_simple data source.
76
---
87

98
# spectrocloud_pack (Data Source)
109

10+
This data resource provides the ability to search for a pack in the Palette registries. It supports more advanced search criteria than the pack_simple data source.
1111

1212

13+
14+
~> Starting with version 0.21.0 the attribute `registry_uid` is required.
15+
1316
## Example Usage
1417

15-
```terraform
16-
data "spectrocloud_pack" "cni-calico" {
17-
name = "cni-calico"
18-
version = "3.16.0"
1918

20-
# (alternatively)
21-
# id = "5fd0ca727c411c71b55a359c"
22-
# name = "cni-calico-azure"
23-
# cloud = ["azure"]
19+
An example of how to use this data source to retrieve a specific pack from the community registry.
20+
21+
```hcl
22+
data "spectrocloud_registry" "community_registry" {
23+
name = "Palette Community Registry"
24+
}
25+
26+
27+
data "spectrocloud_pack" "hellouniverse" {
28+
name = "hello-universe"
29+
version = "1.1.2"
30+
registry_uid = data.spectrocloud_registry.community_registry.id
2431
}
32+
```
33+
34+
35+
In this example, a filter is applied to retrieve a Calico CNI pack from the Palette OCI registry that is compatible with Edge clusters and has a version greater than 3.26.9.
36+
37+
-> The filter attribute is a string that can contain multiple filters separated by the `AND`, `OR` operator. You can filter for a pack by using the attributes retured in the `spec` object of the payload provided by the `v1/packs/search` endpoint.
38+
Refer to the Palette Pack Search API endpoint [documentation](https://docs.spectrocloud.com/api/v1/v-1-packs-search/) for more information on the available filters.
39+
40+
41+
42+
```hcl
43+
data "spectrocloud_registry" "palette_registry_oci" {
44+
name = "Palette Registry"
45+
}
46+
2547
26-
output "same" {
27-
value = data.spectrocloud_pack.cni-calico
48+
data "spectrocloud_pack" "cni" {
49+
filters = "spec.cloudTypes=edge-nativeANDspec.layer=cniANDspec.displayName=CalicoANDspec.version>3.26.9ANDspec.registryUid=${data.spectrocloud_registry.palette_registry_oci.id}"
2850
}
2951
```
3052

@@ -33,14 +55,14 @@ output "same" {
3355

3456
### Optional
3557

36-
- `cloud` (Set of String)
37-
- `filters` (String)
38-
- `name` (String)
39-
- `registry_uid` (String)
40-
- `type` (String)
41-
- `version` (String)
58+
- `cloud` (Set of String) Filter results by cloud type. If not provided, all cloud types are returned.
59+
- `filters` (String) Filters to apply when searching for a pack. This is a string of the form 'key1=value1' with 'AND', 'OR` operators. Refer to the Palette API [pack search API endpoint documentation](https://docs.spectrocloud.com/api/v1/v-1-packs-search/) for filter examples..
60+
- `id` (String) The UID of the pack returned.
61+
- `name` (String) The name of the pack to search for.
62+
- `registry_uid` (String) The UID of the registry to search for the pack in. This is a required parameter starting from version 0.21.0.
63+
- `type` (String) The type of pack to search for. Supported values are `helm`, `manifest`, `container`, `operator-instance`.
64+
- `version` (String) The version of the pack to search for.
4265

4366
### Read-Only
4467

45-
- `id` (String) The ID of this resource.
46-
- `values` (String)
68+
- `values` (String) The YAML values of the pack returned as string.

docs/data-sources/pack_simple.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
page_title: "spectrocloud_pack_simple Data Source - terraform-provider-spectrocloud"
33
subcategory: ""
44
description: |-
5-
5+
This data resource provides a simpler user experience for searching for a pack in Palette registries.
66
---
77

88
# spectrocloud_pack_simple (Data Source)
99

10-
10+
This data resource provides a simpler user experience for searching for a pack in Palette registries.
1111

1212
## Example Usage
1313

14+
~> Starting with version 0.21.0 the attribute `registry_uid` is required.
15+
1416
```hcl
1517
data "spectrocloud_registry" "registry" {
1618
name = "Public Repo"
@@ -36,7 +38,7 @@ data "spectrocloud_pack_simple" "pack" {
3638
### Optional
3739

3840
- `context` (String) Indicates in which context registry should be searched for the pack values. Allowed values are `system`, `project` or `tenant`. Defaults to `project`.If the `project` context is specified, the project name will sourced from the provider configuration parameter [`project_name`](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs#schema).
39-
- `registry_uid` (String) The unique identifier of the registry the pack belongs to.
41+
- `registry_uid` (String) The unique identifier of the registry the pack belongs to. This is a required parameter starting from version 0.21.0
4042
- `version` (String) The version of the pack.
4143

4244
### Read-Only

spectrocloud/data_source_pack.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,50 +14,59 @@ import (
1414
func dataSourcePack() *schema.Resource {
1515
return &schema.Resource{
1616
ReadContext: dataSourcePackRead,
17+
Description: "This data resource provides the ability to search for a pack in the Palette registries. It supports more advanced search criteria than the `pack_simple` data source.",
1718

1819
Schema: map[string]*schema.Schema{
1920
"filters": {
2021
Type: schema.TypeString,
2122
Optional: true,
23+
Description: "Filters to apply when searching for a pack. This is a string of the form 'key1=value1' with 'AND', 'OR` operators. Refer to the Palette API [pack search API endpoint documentation](https://docs.spectrocloud.com/api/v1/v-1-packs-search/) for filter examples..",
2224
ConflictsWith: []string{"id", "cloud", "name", "version", "registry_uid"},
2325
},
2426
"id": {
2527
Type: schema.TypeString,
2628
Computed: true,
2729
Optional: true,
30+
Description: "The UID of the pack returned.",
2831
ConflictsWith: []string{"filters", "cloud", "name", "version", "registry_uid"},
2932
},
3033
"name": {
3134
Type: schema.TypeString,
35+
Description: "The name of the pack to search for.",
3236
Computed: true,
3337
Optional: true,
3438
},
3539
"cloud": {
3640
Type: schema.TypeSet,
3741
Optional: true,
3842
Computed: true,
43+
Description: "Filter results by cloud type. If not provided, all cloud types are returned.",
3944
Set: schema.HashString,
4045
Elem: &schema.Schema{
4146
Type: schema.TypeString,
4247
},
4348
},
4449
"version": {
4550
Type: schema.TypeString,
51+
Description: "The version of the pack to search for.",
4652
Computed: true,
4753
Optional: true,
4854
},
4955
"registry_uid": {
5056
Type: schema.TypeString,
57+
Description: "The UID of the registry to search for the pack in. This is a required parameter starting from version 0.21.0.",
5158
Computed: true,
5259
Optional: true,
5360
},
5461
"type": {
5562
Type: schema.TypeString,
63+
Description: "The type of pack to search for. Supported values are `helm`, `manifest`, `container`, `operator-instance`.",
5664
Computed: true,
5765
Optional: true,
5866
},
5967
"values": {
6068
Type: schema.TypeString,
69+
Description: "The YAML values of the pack returned as string.",
6170
Computed: true,
6271
},
6372
},

spectrocloud/data_source_pack_simple.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
func dataSourcePackSimple() *schema.Resource {
1717
return &schema.Resource{
1818
ReadContext: dataSourcePackReadSimple,
19+
Description: "This data resource provides a simpler user experience for searching for a pack in Palette registries.",
1920

2021
Schema: map[string]*schema.Schema{
2122
"name": {
@@ -39,7 +40,7 @@ func dataSourcePackSimple() *schema.Resource {
3940
"registry_uid": {
4041
Type: schema.TypeString,
4142
Optional: true,
42-
Description: "The unique identifier of the registry the pack belongs to.",
43+
Description: "The unique identifier of the registry the pack belongs to. This is a required parameter starting from version 0.21.0",
4344
},
4445
"type": {
4546
Type: schema.TypeString,
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}"
3+
subcategory: ""
4+
description: |-
5+
{{ .Description | plainmarkdown | trimspace | prefixlines " " }}
6+
---
7+
8+
# {{.Name}} ({{.Type}})
9+
10+
{{ .Description | plainmarkdown | trimspace | prefixlines " " }}
11+
12+
13+
14+
~> Starting with version 0.21.0 the attribute `registry_uid` is required.
15+
16+
## Example Usage
17+
18+
19+
An example of how to use this data source to retrieve a specific pack from the community registry.
20+
21+
```hcl
22+
data "spectrocloud_registry" "community_registry" {
23+
name = "Palette Community Registry"
24+
}
25+
26+
27+
data "spectrocloud_pack" "hellouniverse" {
28+
name = "hello-universe"
29+
version = "1.1.2"
30+
registry_uid = data.spectrocloud_registry.community_registry.id
31+
}
32+
```
33+
34+
35+
In this example, a filter is applied to retrieve a Calico CNI pack from the Palette OCI registry that is compatible with Edge clusters and has a version greater than 3.26.9.
36+
37+
-> The filter attribute is a string that can contain multiple filters separated by the `AND`, `OR` operator. You can filter for a pack by using the attributes retured in the `spec` object of the payload provided by the `v1/packs/search` endpoint.
38+
Refer to the Palette Pack Search API endpoint [documentation](https://docs.spectrocloud.com/api/v1/v-1-packs-search/) for more information on the available filters.
39+
40+
41+
42+
```hcl
43+
data "spectrocloud_registry" "palette_registry_oci" {
44+
name = "Palette Registry"
45+
}
46+
47+
48+
data "spectrocloud_pack" "cni" {
49+
filters = "spec.cloudTypes=edge-nativeANDspec.layer=cniANDspec.displayName=CalicoANDspec.version>3.26.9ANDspec.registryUid=${data.spectrocloud_registry.palette_registry_oci.id}"
50+
}
51+
```
52+
53+
{{ .SchemaMarkdown | trimspace }}

templates/data-sources/pack_simple.md.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ description: |-
1111

1212
## Example Usage
1313

14+
~> Starting with version 0.21.0 the attribute `registry_uid` is required.
15+
1416
```hcl
1517
data "spectrocloud_registry" "registry" {
1618
name = "Public Repo"

0 commit comments

Comments
 (0)