Rename asRuntime* -> asClient*
For the avoidance of misdirection. Signed-off-by: Michael Bridgen <michael@weave.works>
This commit is contained in:
@@ -76,7 +76,7 @@ func (names apiType) upsert(ctx context.Context, kubeClient client.Client, objec
|
|||||||
Name: object.GetName(),
|
Name: object.GetName(),
|
||||||
}
|
}
|
||||||
|
|
||||||
op, err := controllerutil.CreateOrUpdate(ctx, kubeClient, object.asRuntimeObject(), mutate)
|
op, err := controllerutil.CreateOrUpdate(ctx, kubeClient, object.asClientObject(), mutate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nsname, err
|
return nsname, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ func (del deleteCommand) run(cmd *cobra.Command, args []string) error {
|
|||||||
Name: name,
|
Name: name,
|
||||||
}
|
}
|
||||||
|
|
||||||
err = kubeClient.Get(ctx, namespacedName, del.object.asRuntimeObject())
|
err = kubeClient.Get(ctx, namespacedName, del.object.asClientObject())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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)
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ func (export exportCommand) run(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if exportAll {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ func (export exportCommand) run(cmd *cobra.Command, args []string) error {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: name,
|
Name: name,
|
||||||
}
|
}
|
||||||
err = kubeClient.Get(ctx, namespacedName, export.object.asRuntimeObject())
|
err = kubeClient.Get(ctx, namespacedName, export.object.asClientObject())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ func (get getCommand) run(cmd *cobra.Command, args []string) error {
|
|||||||
if !allNamespaces {
|
if !allNamespaces {
|
||||||
listOpts = append(listOpts, client.InNamespace(namespace))
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ type imageRepositoryAdapter struct {
|
|||||||
*imagev1.ImageRepository
|
*imagev1.ImageRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a imageRepositoryAdapter) asRuntimeObject() client.Object {
|
func (a imageRepositoryAdapter) asClientObject() client.Object {
|
||||||
return a.ImageRepository
|
return a.ImageRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ type imageRepositoryListAdapter struct {
|
|||||||
*imagev1.ImageRepositoryList
|
*imagev1.ImageRepositoryList
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a imageRepositoryListAdapter) asRuntimeList() client.ObjectList {
|
func (a imageRepositoryListAdapter) asClientList() client.ObjectList {
|
||||||
return a.ImageRepositoryList
|
return a.ImageRepositoryList
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ type imagePolicyAdapter struct {
|
|||||||
*imagev1.ImagePolicy
|
*imagev1.ImagePolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a imagePolicyAdapter) asRuntimeObject() client.Object {
|
func (a imagePolicyAdapter) asClientObject() client.Object {
|
||||||
return a.ImagePolicy
|
return a.ImagePolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ type imagePolicyListAdapter struct {
|
|||||||
*imagev1.ImagePolicyList
|
*imagev1.ImagePolicyList
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a imagePolicyListAdapter) asRuntimeList() client.ObjectList {
|
func (a imagePolicyListAdapter) asClientList() client.ObjectList {
|
||||||
return a.ImagePolicyList
|
return a.ImagePolicyList
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ type imageUpdateAutomationAdapter struct {
|
|||||||
*autov1.ImageUpdateAutomation
|
*autov1.ImageUpdateAutomation
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a imageUpdateAutomationAdapter) asRuntimeObject() client.Object {
|
func (a imageUpdateAutomationAdapter) asClientObject() client.Object {
|
||||||
return a.ImageUpdateAutomation
|
return a.ImageUpdateAutomation
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ type imageUpdateAutomationListAdapter struct {
|
|||||||
*autov1.ImageUpdateAutomationList
|
*autov1.ImageUpdateAutomationList
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a imageUpdateAutomationListAdapter) asRuntimeList() client.ObjectList {
|
func (a imageUpdateAutomationListAdapter) asClientList() client.ObjectList {
|
||||||
return a.ImageUpdateAutomationList
|
return a.ImageUpdateAutomationList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,14 +35,14 @@ type apiType struct {
|
|||||||
// use values of the wrapper with `client.Client`, which only deals
|
// use values of the wrapper with `client.Client`, which only deals
|
||||||
// with types that have been added to the schema.
|
// with types that have been added to the schema.
|
||||||
type adapter interface {
|
type adapter interface {
|
||||||
asRuntimeObject() client.Object
|
asClientObject() client.Object
|
||||||
}
|
}
|
||||||
|
|
||||||
// listAdapater is the analogue to adapter, but for lists; the
|
// listAdapater is the analogue to adapter, but for lists; the
|
||||||
// controller runtime distinguishes between methods dealing with
|
// controller runtime distinguishes between methods dealing with
|
||||||
// objects and lists.
|
// objects and lists.
|
||||||
type listAdapter interface {
|
type listAdapter interface {
|
||||||
asRuntimeList() client.ObjectList
|
asClientList() client.ObjectList
|
||||||
len() int
|
len() int
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ type universalAdapter struct {
|
|||||||
obj client.Object
|
obj client.Object
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c universalAdapter) asRuntimeObject() client.Object {
|
func (c universalAdapter) asClientObject() client.Object {
|
||||||
return c.obj
|
return c.obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ func (reconcile reconcileCommand) run(cmd *cobra.Command, args []string) error {
|
|||||||
Name: name,
|
Name: name,
|
||||||
}
|
}
|
||||||
|
|
||||||
err = kubeClient.Get(ctx, namespacedName, reconcile.object.asRuntimeObject())
|
err = kubeClient.Get(ctx, namespacedName, reconcile.object.asClientObject())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ func (reconcile reconcileCommand) run(cmd *cobra.Command, args []string) error {
|
|||||||
func reconciliationHandled(ctx context.Context, kubeClient client.Client,
|
func reconciliationHandled(ctx context.Context, kubeClient client.Client,
|
||||||
namespacedName types.NamespacedName, obj reconcilable, lastHandledReconcileAt string) wait.ConditionFunc {
|
namespacedName types.NamespacedName, obj reconcilable, lastHandledReconcileAt string) wait.ConditionFunc {
|
||||||
return func() (bool, error) {
|
return func() (bool, error) {
|
||||||
err := kubeClient.Get(ctx, namespacedName, obj.asRuntimeObject())
|
err := kubeClient.Get(ctx, namespacedName, obj.asClientObject())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ func reconciliationHandled(ctx context.Context, kubeClient client.Client,
|
|||||||
func requestReconciliation(ctx context.Context, kubeClient client.Client,
|
func requestReconciliation(ctx context.Context, kubeClient client.Client,
|
||||||
namespacedName types.NamespacedName, obj reconcilable) error {
|
namespacedName types.NamespacedName, obj reconcilable) error {
|
||||||
return retry.RetryOnConflict(retry.DefaultBackoff, func() (err 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
|
return err
|
||||||
}
|
}
|
||||||
if ann := obj.GetAnnotations(); ann == nil {
|
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)
|
ann[meta.ReconcileAtAnnotation] = time.Now().Format(time.RFC3339Nano)
|
||||||
obj.SetAnnotations(ann)
|
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,
|
Name: name,
|
||||||
}
|
}
|
||||||
|
|
||||||
err = kubeClient.Get(ctx, namespacedName, resume.object.asRuntimeObject())
|
err = kubeClient.Get(ctx, namespacedName, resume.object.asClientObject())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Actionf("resuming %s %s in %s namespace", resume.humanKind, name, namespace)
|
logger.Actionf("resuming %s %s in %s namespace", resume.humanKind, name, namespace)
|
||||||
resume.object.setUnsuspended()
|
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
|
return err
|
||||||
}
|
}
|
||||||
logger.Successf("%s resumed", resume.humanKind)
|
logger.Successf("%s resumed", resume.humanKind)
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ type statusable interface {
|
|||||||
func isReady(ctx context.Context, kubeClient client.Client,
|
func isReady(ctx context.Context, kubeClient client.Client,
|
||||||
namespacedName types.NamespacedName, object statusable) wait.ConditionFunc {
|
namespacedName types.NamespacedName, object statusable) wait.ConditionFunc {
|
||||||
return func() (bool, error) {
|
return func() (bool, error) {
|
||||||
err := kubeClient.Get(ctx, namespacedName, object.asRuntimeObject())
|
err := kubeClient.Get(ctx, namespacedName, object.asClientObject())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,14 +65,14 @@ func (suspend suspendCommand) run(cmd *cobra.Command, args []string) error {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: name,
|
Name: name,
|
||||||
}
|
}
|
||||||
err = kubeClient.Get(ctx, namespacedName, suspend.object.asRuntimeObject())
|
err = kubeClient.Get(ctx, namespacedName, suspend.object.asClientObject())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Actionf("suspending %s %s in %s namespace", suspend.humanKind, name, namespace)
|
logger.Actionf("suspending %s %s in %s namespace", suspend.humanKind, name, namespace)
|
||||||
suspend.object.setSuspended()
|
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
|
return err
|
||||||
}
|
}
|
||||||
logger.Successf("%s suspended", suspend.humanKind)
|
logger.Successf("%s suspended", suspend.humanKind)
|
||||||
|
|||||||
Reference in New Issue
Block a user