Skip to content

Commit

Permalink
fix(cluster): fix cannot merge bool type with false as zero value
Browse files Browse the repository at this point in the history
  • Loading branch information
JacieChao authored and orangedeng committed Aug 21, 2023
1 parent 2ac6f02 commit 76d571b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/cluster/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,8 @@ func (p *ProviderBase) overwriteMetadata(matched *common.ClusterState) {
p.DockerMirror = matched.DockerMirror
p.InstallScript = matched.InstallScript
p.Network = matched.Network
p.Cluster = matched.Cluster
p.Rollback = matched.Rollback
// needed to be overwrite.
if p.K3sChannel == "" {
p.K3sChannel = matched.K3sChannel
Expand Down
2 changes: 1 addition & 1 deletion pkg/types/autok3s.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type Metadata struct {
DataStoreCAFileContent string `json:"datastore-cafile-content,omitempty" yaml:"datastore-cafile-content,omitempty"`
DataStoreCertFileContent string `json:"datastore-certfile-content,omitempty" yaml:"datastore-certfile-content,omitempty"`
DataStoreKeyFileContent string `json:"datastore-keyfile-content,omitempty" yaml:"datastore-keyfile-content,omitempty"`
Rollback bool `json:"rollback,omitempty" yaml:"rollback,omitempty" gorm:"type:bool"`
Rollback bool `json:"rollback" yaml:"rollback" gorm:"type:bool"`
Values StringMap `json:"values,omitempty" yaml:"values,omitempty" gorm:"type:stringMap"`
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/utils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ func MergeConfig(source, target reflect.Value) {
source.Type().Field(i).Name == target.Type().Field(j).Name {
if sField.Type().Kind() == reflect.Struct {
MergeConfig(sField, tField)
} else if sField.Type().Kind() == reflect.Bool {
sField.Set(tField)
} else {
// only merge non empty value
if !tField.IsZero() {
Expand Down

0 comments on commit 76d571b

Please sign in to comment.