Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: documentation for kubectl_path_documents resource #52

Merged
merged 1 commit into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions docs/data-sources/kubectl_path_documents.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
# Data Source: kubectl_path_documents

This provider provides a `data` resource `kubectl_path_documents` to enable ease of splitting multi-document yaml content, from a collection of matching files.
This provider provides a `data` resource `kubectl_path_documents` to enable ease of splitting multi-document yaml content,
from a collection of matching files.
Think of is as a combination of both `kubectl_filename_list` and `kubectl_file_documents`

`kubectl_path_documents` also supports rendering of Terraform Templates (similar to the template provider).
This gives you the flexibility of parameterizing your manifests, and loading & templating in a single command.

## Example Usage

### Load all manifest documents via for_each (recommended)
### Load all manifest documents from a folder via for_each (recommended)

The recommended approach is to use the `manifests` attribute and a `for_each` expression to apply the found manifests.
This ensures that any additional yaml documents or removals do not cause a large amount of terraform changes.

```hcl
data "kubectl_path_documents" "docs" {
pattern = "./manifests/*.yaml"
data "kubectl_path_documents" "manifests-directory-yaml" {
pattern = "./manifests/*.yaml"
}

resource "kubectl_manifest" "test" {
for_each = toset(data.kubectl_path_documents.docs.documents)
yaml_body = each.value
resource "kubectl_manifest" "directory-yaml" {
for_each = data.kubectl_path_documents.manifests-directory-yaml.manifests
yaml_body = each.value
}
```

### Load all manifest documents via count

Raw documents can also be accessed via the `documents` attribute.
Raw documents can also be accessed via the `documents` attribute. Not that if the document order is changed (i.e. a new file is added),
then it would trigger destruction and recreation of related documents.

```hcl
data "kubectl_path_documents" "docs" {
Expand Down Expand Up @@ -163,7 +164,6 @@ metadata:
## Argument Reference

* `pattern` - Required. Glob pattern to search for.
* `force_new` - Optional. Forces delete & create of resources if the `yaml_body` changes. Default `false`.
* `vars` - Optional. Map of variables to use when rendering the loaded documents as templates. Currently only strings are supported.
* `sensitive_vars` - Optional. Map of sensitive variables to use when rendering the loaded documents as templates. Merged with the `vars` attribute. Currently only strings are supported.
* `disable_template` - Optional. Flag to disable template parsing of the loaded documents.
Expand Down
5 changes: 3 additions & 2 deletions kubernetes/data_source_kubectl_path_documents.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ func dataSourceKubectlPathDocuments() *schema.Resource {
ReadContext: dataSourceKubectlPathDocumentsRead,
Schema: map[string]*schema.Schema{
"pattern": &schema.Schema{
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Required: true,
Description: "Glob pattern to search for",
},
"documents": &schema.Schema{
Type: schema.TypeList,
Expand Down