@ -44,8 +44,8 @@ func init() {
}
}
type reconcileCommand struct {
type reconcileCommand struct {
humanKind string
names
adapter reconcilable
object reconcilable
}
}
type reconcilable interface {
type reconcilable interface {
@ -65,7 +65,7 @@ type reconcilable interface {
func ( reconcile reconcileCommand ) run ( cmd * cobra . Command , args [ ] string ) error {
func ( reconcile reconcileCommand ) run ( cmd * cobra . Command , args [ ] string ) error {
if len ( args ) < 1 {
if len ( args ) < 1 {
return fmt . Errorf ( "%s name is required" , reconcile . humanK ind)
return fmt . Errorf ( "%s name is required" , reconcile . k ind)
}
}
name := args [ 0 ]
name := args [ 0 ]
@ -82,33 +82,33 @@ func (reconcile reconcileCommand) run(cmd *cobra.Command, args []string) error {
Name : name ,
Name : name ,
}
}
err = kubeClient . Get ( ctx , namespacedName , reconcile . adapter . asRuntimeObject ( ) )
err = kubeClient . Get ( ctx , namespacedName , reconcile . object . asRuntimeObject ( ) )
if err != nil {
if err != nil {
return err
return err
}
}
if reconcile . adapter . isSuspended ( ) {
if reconcile . object . isSuspended ( ) {
return fmt . Errorf ( "resource is suspended" )
return fmt . Errorf ( "resource is suspended" )
}
}
logger . Actionf ( "annotating %s %s in %s namespace" , reconcile . humanK ind, name , namespace )
logger . Actionf ( "annotating %s %s in %s namespace" , reconcile . k ind, name , namespace )
if err := requestReconciliation ( ctx , kubeClient , namespacedName , reconcile . adapter ) ; err != nil {
if err := requestReconciliation ( ctx , kubeClient , namespacedName , reconcile . object ) ; err != nil {
return err
return err
}
}
logger . Successf ( "%s annotated" , reconcile . humanK ind)
logger . Successf ( "%s annotated" , reconcile . k ind)
lastHandledReconcileAt := reconcile . adapter . lastHandledReconcileRequest ( )
lastHandledReconcileAt := reconcile . object . lastHandledReconcileRequest ( )
logger . Waitingf ( "waiting for %s reconciliation" , reconcile . humanK ind)
logger . Waitingf ( "waiting for %s reconciliation" , reconcile . k ind)
if err := wait . PollImmediate ( pollInterval , timeout ,
if err := wait . PollImmediate ( pollInterval , timeout ,
reconciliationHandled ( ctx , kubeClient , namespacedName , reconcile . adapter , lastHandledReconcileAt ) ) ; err != nil {
reconciliationHandled ( ctx , kubeClient , namespacedName , reconcile . object , lastHandledReconcileAt ) ) ; err != nil {
return err
return err
}
}
logger . Successf ( "%s reconciliation completed" , reconcile . humanK ind)
logger . Successf ( "%s reconciliation completed" , reconcile . k ind)
if apimeta . IsStatusConditionFalse ( * reconcile . adapter . GetStatusConditions ( ) , meta . ReadyCondition ) {
if apimeta . IsStatusConditionFalse ( * reconcile . object . GetStatusConditions ( ) , meta . ReadyCondition ) {
return fmt . Errorf ( "%s reconciliation failed" , reconcile . humanK ind)
return fmt . Errorf ( "%s reconciliation failed" , reconcile . k ind)
}
}
logger . Successf ( reconcile . adapter . successMessage ( ) )
logger . Successf ( reconcile . object . successMessage ( ) )
return nil
return nil
}
}