Skip to content

Commit b1b703d

Browse files
committed
chore: move sync logging code to go-kubernetes package
so it can be reused in Omni Signed-off-by: Orzelius <33936483+Orzelius@users.noreply.github.com>
1 parent e48c6d7 commit b1b703d

File tree

4 files changed

+18
-42
lines changed

4 files changed

+18
-42
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ init.yaml
99
controlplane.yaml
1010
join.yaml
1111
worker.yaml
12+
machineconfig.yaml
1213
talosconfig
1314
/kubeconfig
1415
hack/test/libvirt/matchbox/assets/*

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ require (
148148
github.com/siderolabs/go-debug v0.6.1
149149
github.com/siderolabs/go-kmsg v0.1.4
150150
github.com/siderolabs/go-kubeconfig v0.1.1
151-
github.com/siderolabs/go-kubernetes v0.2.30
151+
github.com/siderolabs/go-kubernetes v0.2.31
152152
github.com/siderolabs/go-loadbalancer v0.5.0
153153
github.com/siderolabs/go-pcidb v0.3.2
154154
github.com/siderolabs/go-pointer v1.0.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,8 @@ github.com/siderolabs/go-kmsg v0.1.4 h1:RLAa90O9bWuhA3pXPAYAdrI+kzcqTshZASRA5yso
659659
github.com/siderolabs/go-kmsg v0.1.4/go.mod h1:BLkt2N2DHT0wsFMz32lMw6vNEZL90c8ZnBjpIUoBb/M=
660660
github.com/siderolabs/go-kubeconfig v0.1.1 h1:tZlgpelj/OqrcHVUwISPN0NRgObcflpH9WtE41mtQZ0=
661661
github.com/siderolabs/go-kubeconfig v0.1.1/go.mod h1:QaGp4i9L95oDbcU7jDn30aw4gnREkb3O5otgxw8imOk=
662-
github.com/siderolabs/go-kubernetes v0.2.30 h1:sqOulDpkdTRtqTIn7odFAe5tz8ea12kZgNz0BOnxUb0=
663-
github.com/siderolabs/go-kubernetes v0.2.30/go.mod h1:D6b6O6oVFXPUBTN+euLTF3llSw5GmUqP749brODKF5s=
662+
github.com/siderolabs/go-kubernetes v0.2.31 h1:pAYVti2SUnUzXlGAMmZZPqhq2+V8ifg7zhFku4iqeTQ=
663+
github.com/siderolabs/go-kubernetes v0.2.31/go.mod h1:D6b6O6oVFXPUBTN+euLTF3llSw5GmUqP749brODKF5s=
664664
github.com/siderolabs/go-loadbalancer v0.5.0 h1:0v7E6GrxoONyqwcmHiA+J0vIDPWbkTmevHGCFb4tjdc=
665665
github.com/siderolabs/go-loadbalancer v0.5.0/go.mod h1:tRVouZ9i2R/TRbNUF9MqyBlV2wsjX0cxkYTjPXcI9P0=
666666
github.com/siderolabs/go-pcidb v0.3.2 h1:18KMjsc+AO2r6/pl0KLBR9xOXO0ULLCXwmGhIukoAbw=

pkg/cluster/kubernetes/talos_managed.go

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -508,48 +508,23 @@ func syncManifestsSSA(ctx context.Context, objects []*unstructured.Unstructured,
508508
return err
509509
}
510510

511-
ssaOptions := manifests.SSAOptions{
512-
FieldManagerName: constants.KubernetesFieldManagerName,
513-
InventoryNamespace: constants.KubernetesInventoryNamespace,
514-
InventoryName: constants.KubernetesBootstrapManifestsInventoryName,
515-
SSApplyBehaviorOptions: manifests.SSApplyBehaviorOptions{
516-
DryRun: options.DryRun,
517-
InventoryPolicy: options.InventoryPolicy,
518-
ReconcileTimeout: options.ReconcileTimeout,
519-
PruneTimeout: options.PruneTimeout,
520-
ForceConflicts: options.ForceConflicts,
521-
NoPrune: options.NoPrune,
522-
},
523-
}
524-
525-
options.Log("comparing with live objects")
526-
527-
result, err := manifests.DiffSSA(ctx, objects, config, ssaOptions)
528-
if err != nil {
529-
return err
530-
}
531-
532-
if len(result) == 0 {
533-
options.Log("< no changes detected")
534-
}
535-
536-
for _, r := range result {
537-
objPath := fmt.Sprintf("%s %s/%s", r.Object.GroupVersionKind().Kind, r.Object.GetNamespace(), r.Object.GetName())
538-
if r.Object.GetNamespace() == "" {
539-
objPath = fmt.Sprintf("%s %s", r.Object.GroupVersionKind().Kind, r.Object.GetName())
540-
}
541-
542-
options.Log("< %s %s", r.Action, objPath)
543-
options.Log("%s", r.Diff)
544-
}
545-
546-
options.Log("applying manifests")
547-
548-
return manifests.SyncWithLogSSA(
511+
return manifests.SyncAndDiffWithLogSSA(
549512
ctx,
550513
objects,
551514
config,
552-
ssaOptions,
515+
manifests.SSAOptions{
516+
FieldManagerName: constants.KubernetesFieldManagerName,
517+
InventoryNamespace: constants.KubernetesInventoryNamespace,
518+
InventoryName: constants.KubernetesBootstrapManifestsInventoryName,
519+
SSApplyBehaviorOptions: manifests.SSApplyBehaviorOptions{
520+
DryRun: options.DryRun,
521+
InventoryPolicy: options.InventoryPolicy,
522+
ReconcileTimeout: options.ReconcileTimeout,
523+
PruneTimeout: options.PruneTimeout,
524+
ForceConflicts: options.ForceConflicts,
525+
NoPrune: options.NoPrune,
526+
},
527+
},
553528
options.Log,
554529
)
555530
}

0 commit comments

Comments
 (0)