Skip to content

Commit a530959

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 0bd48bb commit a530959

File tree

4 files changed

+22
-40
lines changed

4 files changed

+22
-40
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-0.20260125124853-604c56b7251e
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,12 @@ github.com/siderolabs/go-kubeconfig v0.1.1 h1:tZlgpelj/OqrcHVUwISPN0NRgObcflpH9W
661661
github.com/siderolabs/go-kubeconfig v0.1.1/go.mod h1:QaGp4i9L95oDbcU7jDn30aw4gnREkb3O5otgxw8imOk=
662662
github.com/siderolabs/go-kubernetes v0.2.30 h1:sqOulDpkdTRtqTIn7odFAe5tz8ea12kZgNz0BOnxUb0=
663663
github.com/siderolabs/go-kubernetes v0.2.30/go.mod h1:D6b6O6oVFXPUBTN+euLTF3llSw5GmUqP749brODKF5s=
664+
github.com/siderolabs/go-kubernetes v0.2.31-0.20260119110614-4f6ae796c8a1 h1:RWartEyc8fP8bRbW5Pk0ththVxnIPNFLT6/tCyHH5KQ=
665+
github.com/siderolabs/go-kubernetes v0.2.31-0.20260119110614-4f6ae796c8a1/go.mod h1:D6b6O6oVFXPUBTN+euLTF3llSw5GmUqP749brODKF5s=
666+
github.com/siderolabs/go-kubernetes v0.2.31-0.20260122070024-40b7a42c1596 h1:VTVQCP3a5E11sUznEUGKVeJLw1i03ABmAXoaAqbLR8Y=
667+
github.com/siderolabs/go-kubernetes v0.2.31-0.20260122070024-40b7a42c1596/go.mod h1:D6b6O6oVFXPUBTN+euLTF3llSw5GmUqP749brODKF5s=
668+
github.com/siderolabs/go-kubernetes v0.2.31-0.20260125124853-604c56b7251e h1:ygfWK2m0w3HCXnTl02RuQ6Gd922f57aXuq1OT3jVZEM=
669+
github.com/siderolabs/go-kubernetes v0.2.31-0.20260125124853-604c56b7251e/go.mod h1:D6b6O6oVFXPUBTN+euLTF3llSw5GmUqP749brODKF5s=
664670
github.com/siderolabs/go-loadbalancer v0.5.0 h1:0v7E6GrxoONyqwcmHiA+J0vIDPWbkTmevHGCFb4tjdc=
665671
github.com/siderolabs/go-loadbalancer v0.5.0/go.mod h1:tRVouZ9i2R/TRbNUF9MqyBlV2wsjX0cxkYTjPXcI9P0=
666672
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)