Skip to content

Commit

Permalink
chore: default talos_machine_configuration docs and examples to false
Browse files Browse the repository at this point in the history
Generating talos machine configs with docs and examples enabled makes them too large.

Fixes #181

Signed-off-by: Noel Georgi <[email protected]>
  • Loading branch information
hh authored and frezbo committed Aug 5, 2024
1 parent 80c5534 commit eac7ca7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
4 changes: 2 additions & 2 deletions docs/data-sources/machine_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ data "talos_machine_configuration" "this" {
### Optional

- `config_patches` (List of String) The list of config patches to apply to the generated configuration
- `docs` (Boolean) Whether to generate documentation for the generated configuration
- `examples` (Boolean) Whether to generate examples for the generated configuration
- `docs` (Boolean) Whether to generate documentation for the generated configuration. Defaults to false
- `examples` (Boolean) Whether to generate examples for the generated configuration. DFaults to false
- `kubernetes_version` (String) The version of kubernetes to use
- `talos_version` (String) The version of talos features to use in generated machine configuration

Expand Down
13 changes: 2 additions & 11 deletions pkg/talos/talos_machine_configuration_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ func (d *talosMachineConfigurationDataSource) Schema(_ context.Context, _ dataso
},
},
"docs": schema.BoolAttribute{
Description: "Whether to generate documentation for the generated configuration",
Description: "Whether to generate documentation for the generated configuration. Defaults to false",
Optional: true,
},
"examples": schema.BoolAttribute{
Description: "Whether to generate examples for the generated configuration",
Description: "Whether to generate examples for the generated configuration. DFaults to false",
Optional: true,
},
"machine_configuration": schema.StringAttribute{
Expand All @@ -197,15 +197,6 @@ func (d *talosMachineConfigurationDataSource) Read(ctx context.Context, req data
return
}

// set default values
if !state.Docs.IsUnknown() && state.Docs.IsNull() {
state.Docs = basetypes.NewBoolValue(true)
}

if !state.Examples.IsUnknown() && state.Examples.IsNull() {
state.Examples = basetypes.NewBoolValue(true)
}

if !state.KubernetesVersion.IsUnknown() && state.KubernetesVersion.IsNull() {
state.KubernetesVersion = basetypes.NewStringValue(constants.DefaultKubernetesVersion)
}
Expand Down
14 changes: 9 additions & 5 deletions pkg/talos/talos_machine_configuration_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ func TestAccTalosMachineConfigurationDataSource(t *testing.T) {
constants.DefaultKubernetesVersion,
"controlplane",
value,
true,
false,
true,
func(t *testing.T, config v1alpha1.Config) error {
assert.NotEmpty(t, config.Cluster().AESCBCEncryptionSecret())
assert.Empty(t, config.Cluster().SecretboxEncryptionSecret())
Expand Down Expand Up @@ -351,14 +351,18 @@ func validateGeneratedTalosMachineConfig(
if examples {
// verifying there's examples
assert.Contains(t, mc, (`
# diskSelector:
# size: 4GB # Disk size.
# # Uncomment this to enable SANs.
# - 10.0.0.10
# - 172.16.0.10
# - 192.168.0.10
`))
} else {
// verifying there's no examples
assert.NotContains(t, mc, (`
# diskSelector:
# size: 4GB # Disk size.
# # Uncomment this to enable SANs.
# - 10.0.0.10
# - 172.16.0.10
# - 192.168.0.10
`))
}

Expand Down

0 comments on commit eac7ca7

Please sign in to comment.