MCPcopy
hub / github.com/kubesphere/kubekey / syncSource

Method syncSource

pkg/variable/variable.go:212–230  ·  view source on GitHub ↗

syncSource sync hosts vars to source.

(newVal value)

Source from the content-addressed store, hash-verified

210
211// syncSource sync hosts vars to source.
212func (v *variable) syncSource(newVal value) error {
213 v.value.Result = newVal.Result
214 for hn, hv := range v.value.Hosts {
215 if reflect.DeepEqual(newVal.Hosts[hn], hv) {
216 // nothing change skip.
217 continue
218 }
219 if err := v.source.Write(map[string]any{
220 "remote": newVal.Hosts[hn].RemoteVars,
221 "runtime": newVal.Hosts[hn].RuntimeVars,
222 }, hn); err != nil {
223 return errors.Wrapf(err, "failed to write host %s variable to source", hn)
224 }
225 // update new value to variable
226 v.value.Hosts[hn] = newVal.Hosts[hn]
227 }
228
229 return nil
230}

Callers 1

MergeMethod · 0.95

Calls 1

WriteMethod · 0.65

Tested by

no test coverage detected