Skip to content

Commit e3c65d5

Browse files
committed
add documentation and cleanup the code
1 parent 2547918 commit e3c65d5

5 files changed

Lines changed: 13 additions & 19 deletions

File tree

community/modules/management/dependencies-installer/kubernetes_manifest/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
| Name | Version |
55
|------|---------|
6-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
6+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
77
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | ~> 2.23 |
88

99
## Providers
@@ -29,7 +29,7 @@ No modules.
2929
| <a name="input_content"></a> [content](#input\_content) | The YAML body to apply to gke cluster. | `string` | `null` | no |
3030
| <a name="input_field_manager"></a> [field\_manager](#input\_field\_manager) | (Optional) Configure field manager options. The `name` is the name of the field manager. The `force_conflicts` flag allows overriding conflicts. | <pre>object({<br/> name = optional(string, null)<br/> force_conflicts = optional(bool, false)<br/> })</pre> | `null` | no |
3131
| <a name="input_resource_timeouts"></a> [resource\_timeouts](#input\_resource\_timeouts) | (Optional) Configure custom timeouts for the create, update, and delete operations of the resource. These timeouts also govern the duration for any 'wait' conditions to be met. | <pre>object({<br/> create = optional(string, null)<br/> update = optional(string, null)<br/> delete = optional(string, null)<br/> })</pre> | <pre>{<br/> "create": "15m",<br/> "delete": "5m",<br/> "update": "10m"<br/>}</pre> | no |
32-
| <a name="input_source_path"></a> [source\_path](#input\_source\_path) | The source for manifest(s) to apply to gke cluster. Acceptable sources are a local yaml or template (.tftpl) file path, a directory (ends with '/') containing yaml or template files, and a url for a yaml file. | `string` | `null` | no |
32+
| <a name="input_source_path"></a> [source\_path](#input\_source\_path) | The source for manifest(s) to apply to gke cluster. Acceptable sources are a local yaml or template (.tftpl) file path, a directory (ends with '/') containing yaml or template files, and a url for a yaml file. | `string` | `""` | no |
3333
| <a name="input_template_vars"></a> [template\_vars](#input\_template\_vars) | The values to populate template file(s) with. | `any` | `null` | no |
3434
| <a name="input_wait_for_fields"></a> [wait\_for\_fields](#input\_wait\_for\_fields) | (Optional) A map of attribute paths and desired patterns to be matched. After each apply the provider will wait for all attributes listed here to reach a value that matches the desired pattern. | `map(string)` | `{}` | no |
3535
| <a name="input_wait_for_rollout"></a> [wait\_for\_rollout](#input\_wait\_for\_rollout) | Wait or not for Deployments and APIService to complete rollout. See [kubectl wait](https://kubernetes.io/docs/reference/kubectl/generated/kubectl_wait/) for more details. | `bool` | `true` | no |

community/modules/management/dependencies-installer/kubernetes_manifest/main.tf

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,21 @@ locals {
1919
# Prioritize 'content' variable if provided
2020
primary_content_body = var.content != "" ? var.content : null
2121

22-
# Prepare a null-safe version of var.source_path for conditional checks
23-
null_safe_source_path = coalesce(var.source_path, "")
24-
2522
# --- 2. Handle 'source_path' based on its type (File vs. Directory) ---
2623

2724
# Check if source_path is a directory (indicated by trailing slash)
28-
is_directory = endswith(local.null_safe_source_path, "/")
29-
directory_absolute_path = local.is_directory ? abspath(local.null_safe_source_path) : null
25+
is_directory = endswith(var.source_path, "/")
26+
directory_absolute_path = local.is_directory ? abspath(var.source_path) : null
3027

3128
# Check if source_path is a single yaml or tftpl file (only if not a directory)
3229
is_single_file = !local.is_directory && (
33-
length(regexall("\\.yaml$", lower(local.null_safe_source_path))) > 0 ||
34-
length(regexall("\\.tftpl$", lower(local.null_safe_source_path))) > 0
30+
length(regexall("\\.yaml$", lower(var.source_path))) > 0 ||
31+
length(regexall("\\.tftpl$", lower(var.source_path))) > 0
3532
)
3633
single_file_raw_content = local.is_single_file ? (
37-
length(regexall("\\.tftpl$", lower(local.null_safe_source_path))) > 0 ?
38-
templatefile(abspath(local.null_safe_source_path), var.template_vars) :
39-
file(abspath(local.null_safe_source_path))
34+
length(regexall("\\.tftpl$", lower(var.source_path))) > 0 ?
35+
templatefile(abspath(var.source_path), var.template_vars) :
36+
file(abspath(var.source_path))
4037
) : null
4138

4239
# Docs from primary_content_body
@@ -78,8 +75,6 @@ locals {
7875
})
7976
}
8077

81-
82-
8378
# Apply all manifest files dynamically
8479
resource "kubernetes_manifest" "apply_manifests" {
8580
for_each = local.docs_map
@@ -106,5 +101,4 @@ resource "kubernetes_manifest" "apply_manifests" {
106101
force_conflicts = field_manager.value.force_conflicts
107102
}
108103
}
109-
110104
}

community/modules/management/dependencies-installer/kubernetes_manifest/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 "Google LLC"
1+
# Copyright 2025 "Google LLC"
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

community/modules/management/dependencies-installer/kubernetes_manifest/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ variable "content" {
2323
variable "source_path" {
2424
description = "The source for manifest(s) to apply to gke cluster. Acceptable sources are a local yaml or template (.tftpl) file path, a directory (ends with '/') containing yaml or template files, and a url for a yaml file."
2525
type = string
26-
default = null
26+
default = ""
2727
}
2828

2929
variable "template_vars" {

community/modules/management/dependencies-installer/kubernetes_manifest/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
# limitations under the License.
1414

1515
terraform {
16-
required_version = ">= 1.0.0"
1716
# Defines the providers that this module depends on and their versions.
1817
required_providers {
1918
kubernetes = {
2019
source = "hashicorp/kubernetes"
21-
version = "~> 2.23" #
20+
version = "~> 2.23"
2221
}
2322
}
23+
required_version = ">= 1.3"
2424
}

0 commit comments

Comments
 (0)