From cafce536bb71c36a58de5c37d4f760651e075d0e Mon Sep 17 00:00:00 2001 From: Michael Bridgen Date: Wed, 13 Jan 2021 11:38:02 +0000 Subject: [PATCH] Rename asRuntime* -> asClient* For the avoidance of misdirection. Signed-off-by: Michael Bridgen --- cmd/flux/create.go | 2 +- cmd/flux/delete.go | 4 ++-- cmd/flux/export.go | 4 ++-- cmd/flux/get.go | 2 +- cmd/flux/image.go | 12 ++++++------ cmd/flux/object.go | 6 +++--- cmd/flux/reconcile.go | 8 ++++---- cmd/flux/resume.go | 4 ++-- cmd/flux/status.go | 2 +- cmd/flux/suspend.go | 4 ++-- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/cmd/flux/create.go b/cmd/flux/create.go index 10ef64c2..5cdf2f61 100644 --- a/cmd/flux/create.go +++ b/cmd/flux/create.go @@ -76,7 +76,7 @@ func (names apiType) upsert(ctx context.Context, kubeClient client.Client, objec Name: object.GetName(), } - op, err := controllerutil.CreateOrUpdate(ctx, kubeClient, object.asRuntimeObject(), mutate) + op, err := controllerutil.CreateOrUpdate(ctx, kubeClient, object.asClientObject(), mutate) if err != nil { return nsname, err } diff --git a/cmd/flux/delete.go b/cmd/flux/delete.go index ae6e3d31..d03ea43a 100644 --- a/cmd/flux/delete.go +++ b/cmd/flux/delete.go @@ -68,7 +68,7 @@ func (del deleteCommand) run(cmd *cobra.Command, args []string) error { Name: name, } - err = kubeClient.Get(ctx, namespacedName, del.object.asRuntimeObject()) + err = kubeClient.Get(ctx, namespacedName, del.object.asClientObject()) if err != nil { return err } @@ -84,7 +84,7 @@ func (del deleteCommand) run(cmd *cobra.Command, args []string) error { } logger.Actionf("deleting %s %s in %s namespace", del.humanKind, name, namespace) - err = kubeClient.Delete(ctx, del.object.asRuntimeObject()) + err = kubeClient.Delete(ctx, del.object.asClientObject()) if err != nil { return err } diff --git a/cmd/flux/export.go b/cmd/flux/export.go index f33534b3..ec475306 100644 --- a/cmd/flux/export.go +++ b/cmd/flux/export.go @@ -78,7 +78,7 @@ func (export exportCommand) run(cmd *cobra.Command, args []string) error { } if exportAll { - err = kubeClient.List(ctx, export.list.asRuntimeList(), client.InNamespace(namespace)) + err = kubeClient.List(ctx, export.list.asClientList(), client.InNamespace(namespace)) if err != nil { return err } @@ -99,7 +99,7 @@ func (export exportCommand) run(cmd *cobra.Command, args []string) error { Namespace: namespace, Name: name, } - err = kubeClient.Get(ctx, namespacedName, export.object.asRuntimeObject()) + err = kubeClient.Get(ctx, namespacedName, export.object.asClientObject()) if err != nil { return err } diff --git a/cmd/flux/get.go b/cmd/flux/get.go index 60b6ed50..580d807b 100644 --- a/cmd/flux/get.go +++ b/cmd/flux/get.go @@ -86,7 +86,7 @@ func (get getCommand) run(cmd *cobra.Command, args []string) error { if !allNamespaces { listOpts = append(listOpts, client.InNamespace(namespace)) } - err = kubeClient.List(ctx, get.list.asRuntimeList(), listOpts...) + err = kubeClient.List(ctx, get.list.asClientList(), listOpts...) if err != nil { return err } diff --git a/cmd/flux/image.go b/cmd/flux/image.go index 8e54078b..4bf6e57b 100644 --- a/cmd/flux/image.go +++ b/cmd/flux/image.go @@ -38,7 +38,7 @@ type imageRepositoryAdapter struct { *imagev1.ImageRepository } -func (a imageRepositoryAdapter) asRuntimeObject() client.Object { +func (a imageRepositoryAdapter) asClientObject() client.Object { return a.ImageRepository } @@ -48,7 +48,7 @@ type imageRepositoryListAdapter struct { *imagev1.ImageRepositoryList } -func (a imageRepositoryListAdapter) asRuntimeList() client.ObjectList { +func (a imageRepositoryListAdapter) asClientList() client.ObjectList { return a.ImageRepositoryList } @@ -67,7 +67,7 @@ type imagePolicyAdapter struct { *imagev1.ImagePolicy } -func (a imagePolicyAdapter) asRuntimeObject() client.Object { +func (a imagePolicyAdapter) asClientObject() client.Object { return a.ImagePolicy } @@ -77,7 +77,7 @@ type imagePolicyListAdapter struct { *imagev1.ImagePolicyList } -func (a imagePolicyListAdapter) asRuntimeList() client.ObjectList { +func (a imagePolicyListAdapter) asClientList() client.ObjectList { return a.ImagePolicyList } @@ -96,7 +96,7 @@ type imageUpdateAutomationAdapter struct { *autov1.ImageUpdateAutomation } -func (a imageUpdateAutomationAdapter) asRuntimeObject() client.Object { +func (a imageUpdateAutomationAdapter) asClientObject() client.Object { return a.ImageUpdateAutomation } @@ -106,7 +106,7 @@ type imageUpdateAutomationListAdapter struct { *autov1.ImageUpdateAutomationList } -func (a imageUpdateAutomationListAdapter) asRuntimeList() client.ObjectList { +func (a imageUpdateAutomationListAdapter) asClientList() client.ObjectList { return a.ImageUpdateAutomationList } diff --git a/cmd/flux/object.go b/cmd/flux/object.go index 6bacf890..39998167 100644 --- a/cmd/flux/object.go +++ b/cmd/flux/object.go @@ -35,14 +35,14 @@ type apiType struct { // use values of the wrapper with `client.Client`, which only deals // with types that have been added to the schema. type adapter interface { - asRuntimeObject() client.Object + asClientObject() client.Object } // listAdapater is the analogue to adapter, but for lists; the // controller runtime distinguishes between methods dealing with // objects and lists. type listAdapter interface { - asRuntimeList() client.ObjectList + asClientList() client.ObjectList len() int } @@ -52,7 +52,7 @@ type universalAdapter struct { obj client.Object } -func (c universalAdapter) asRuntimeObject() client.Object { +func (c universalAdapter) asClientObject() client.Object { return c.obj } diff --git a/cmd/flux/reconcile.go b/cmd/flux/reconcile.go index 3418e789..c348be0d 100644 --- a/cmd/flux/reconcile.go +++ b/cmd/flux/reconcile.go @@ -82,7 +82,7 @@ func (reconcile reconcileCommand) run(cmd *cobra.Command, args []string) error { Name: name, } - err = kubeClient.Get(ctx, namespacedName, reconcile.object.asRuntimeObject()) + err = kubeClient.Get(ctx, namespacedName, reconcile.object.asClientObject()) if err != nil { return err } @@ -115,7 +115,7 @@ func (reconcile reconcileCommand) run(cmd *cobra.Command, args []string) error { func reconciliationHandled(ctx context.Context, kubeClient client.Client, namespacedName types.NamespacedName, obj reconcilable, lastHandledReconcileAt string) wait.ConditionFunc { return func() (bool, error) { - err := kubeClient.Get(ctx, namespacedName, obj.asRuntimeObject()) + err := kubeClient.Get(ctx, namespacedName, obj.asClientObject()) if err != nil { return false, err } @@ -126,7 +126,7 @@ func reconciliationHandled(ctx context.Context, kubeClient client.Client, func requestReconciliation(ctx context.Context, kubeClient client.Client, namespacedName types.NamespacedName, obj reconcilable) error { return retry.RetryOnConflict(retry.DefaultBackoff, func() (err error) { - if err := kubeClient.Get(ctx, namespacedName, obj.asRuntimeObject()); err != nil { + if err := kubeClient.Get(ctx, namespacedName, obj.asClientObject()); err != nil { return err } if ann := obj.GetAnnotations(); ann == nil { @@ -137,6 +137,6 @@ func requestReconciliation(ctx context.Context, kubeClient client.Client, ann[meta.ReconcileAtAnnotation] = time.Now().Format(time.RFC3339Nano) obj.SetAnnotations(ann) } - return kubeClient.Update(ctx, obj.asRuntimeObject()) + return kubeClient.Update(ctx, obj.asClientObject()) }) } diff --git a/cmd/flux/resume.go b/cmd/flux/resume.go index f1688a7a..35522456 100644 --- a/cmd/flux/resume.go +++ b/cmd/flux/resume.go @@ -68,14 +68,14 @@ func (resume resumeCommand) run(cmd *cobra.Command, args []string) error { Name: name, } - err = kubeClient.Get(ctx, namespacedName, resume.object.asRuntimeObject()) + err = kubeClient.Get(ctx, namespacedName, resume.object.asClientObject()) if err != nil { return err } logger.Actionf("resuming %s %s in %s namespace", resume.humanKind, name, namespace) resume.object.setUnsuspended() - if err := kubeClient.Update(ctx, resume.object.asRuntimeObject()); err != nil { + if err := kubeClient.Update(ctx, resume.object.asClientObject()); err != nil { return err } logger.Successf("%s resumed", resume.humanKind) diff --git a/cmd/flux/status.go b/cmd/flux/status.go index f9dc7615..1e421e3e 100644 --- a/cmd/flux/status.go +++ b/cmd/flux/status.go @@ -42,7 +42,7 @@ type statusable interface { func isReady(ctx context.Context, kubeClient client.Client, namespacedName types.NamespacedName, object statusable) wait.ConditionFunc { return func() (bool, error) { - err := kubeClient.Get(ctx, namespacedName, object.asRuntimeObject()) + err := kubeClient.Get(ctx, namespacedName, object.asClientObject()) if err != nil { return false, err } diff --git a/cmd/flux/suspend.go b/cmd/flux/suspend.go index 5e6a9f34..89a661bf 100644 --- a/cmd/flux/suspend.go +++ b/cmd/flux/suspend.go @@ -65,14 +65,14 @@ func (suspend suspendCommand) run(cmd *cobra.Command, args []string) error { Namespace: namespace, Name: name, } - err = kubeClient.Get(ctx, namespacedName, suspend.object.asRuntimeObject()) + err = kubeClient.Get(ctx, namespacedName, suspend.object.asClientObject()) if err != nil { return err } logger.Actionf("suspending %s %s in %s namespace", suspend.humanKind, name, namespace) suspend.object.setSuspended() - if err := kubeClient.Update(ctx, suspend.object.asRuntimeObject()); err != nil { + if err := kubeClient.Update(ctx, suspend.object.asClientObject()); err != nil { return err } logger.Successf("%s suspended", suspend.humanKind)