Rename asRuntime* -> asClient*

For the avoidance of misdirection.

Signed-off-by: Michael Bridgen <michael@weave.works>
pull/696/head
Michael Bridgen 4 years ago
parent d03280a12f
commit cafce536bb

@ -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
}

@ -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
}

@ -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
}

@ -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
}

@ -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
}

@ -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
}

@ -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())
})
}

@ -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)

@ -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
}

@ -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)

Loading…
Cancel
Save