Skip to content

Commit 20676d0

Browse files
author
Moritz Clasmeier
committed
Added comments for clarity
1 parent 5680d58 commit 20676d0

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

internal/clusterdefaults/clusterdefaults.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ func ApplyClusterDefaults(
3737
return defaultsCopy, nil
3838
}
3939

40+
// getDefaultsForClusterType returns a deployer.Config filled with the defaults for the given
41+
// cluster type.
42+
// Note that to be able to differentiate "not set" from "set specifically to the empty value",
43+
// any fields set specifically to the empty value (e.g. false booleans), must be of pointer type
44+
// in the Config struct. Otherwise, `ApplyClusterDefaults` would not apply those to the caller-provided
45+
// configuration.
4046
func getDefaultsForClusterType(clusterType types.ClusterType) *deployer.Config {
4147
switch clusterType {
4248
case types.ClusterTypeKind, types.ClusterTypeMinikube, types.ClusterTypeK3s, types.ClusterTypeCRC:

internal/deployer/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ func NewConfig() Config {
2727
}
2828
}
2929

30+
// DeepCopy creates a deep-copy of the provided config using a YAML marshaling/unmarshaling roundtrip.
31+
// Due the `omitempty`, this causes empty values (e.g. empty maps) from being discarded (replace with nil
32+
// in the resulting copy).
3033
func (c *Config) DeepCopy() (*Config, error) {
3134
data, err := yaml.Marshal(c)
3235
if err != nil {

0 commit comments

Comments
 (0)