@@ -17,6 +17,7 @@ limitations under the License.
1717package alpha
1818
1919import (
20+ "context"
2021 "fmt"
2122 "strings"
2223
@@ -31,28 +32,28 @@ import (
3132)
3233
3334// ObjectResumer will issue a resume on the specified cluster-api resource.
34- func (r * rollout ) ObjectResumer (proxy cluster.Proxy , ref corev1.ObjectReference ) error {
35+ func (r * rollout ) ObjectResumer (ctx context. Context , proxy cluster.Proxy , ref corev1.ObjectReference ) error {
3536 switch ref .Kind {
3637 case MachineDeployment :
37- deployment , err := getMachineDeployment (proxy , ref .Name , ref .Namespace )
38+ deployment , err := getMachineDeployment (ctx , proxy , ref .Name , ref .Namespace )
3839 if err != nil || deployment == nil {
3940 return errors .Wrapf (err , "failed to fetch %v/%v" , ref .Kind , ref .Name )
4041 }
4142 if ! deployment .Spec .Paused {
4243 return errors .Errorf ("MachineDeployment is not currently paused: %v/%v\n " , ref .Kind , ref .Name ) //nolint:revive // MachineDeployment is intentionally capitalized.
4344 }
44- if err := resumeMachineDeployment (proxy , ref .Name , ref .Namespace ); err != nil {
45+ if err := resumeMachineDeployment (ctx , proxy , ref .Name , ref .Namespace ); err != nil {
4546 return err
4647 }
4748 case KubeadmControlPlane :
48- kcp , err := getKubeadmControlPlane (proxy , ref .Name , ref .Namespace )
49+ kcp , err := getKubeadmControlPlane (ctx , proxy , ref .Name , ref .Namespace )
4950 if err != nil || kcp == nil {
5051 return errors .Wrapf (err , "failed to fetch %v/%v" , ref .Kind , ref .Name )
5152 }
5253 if ! annotations .HasPaused (kcp .GetObjectMeta ()) {
5354 return errors .Errorf ("KubeadmControlPlane is not currently paused: %v/%v\n " , ref .Kind , ref .Name ) //nolint:revive // KubeadmControlPlane is intentionally capitalized.
5455 }
55- if err := resumeKubeadmControlPlane (proxy , ref .Name , ref .Namespace ); err != nil {
56+ if err := resumeKubeadmControlPlane (ctx , proxy , ref .Name , ref .Namespace ); err != nil {
5657 return err
5758 }
5859 default :
@@ -62,17 +63,17 @@ func (r *rollout) ObjectResumer(proxy cluster.Proxy, ref corev1.ObjectReference)
6263}
6364
6465// resumeMachineDeployment sets Paused to true in the MachineDeployment's spec.
65- func resumeMachineDeployment (proxy cluster.Proxy , name , namespace string ) error {
66+ func resumeMachineDeployment (ctx context. Context , proxy cluster.Proxy , name , namespace string ) error {
6667 patch := client .RawPatch (types .MergePatchType , []byte (fmt .Sprintf ("{\" spec\" :{\" paused\" :%t}}" , false )))
6768
68- return patchMachineDeployment (proxy , name , namespace , patch )
69+ return patchMachineDeployment (ctx , proxy , name , namespace , patch )
6970}
7071
7172// resumeKubeadmControlPlane removes paused annotation.
72- func resumeKubeadmControlPlane (proxy cluster.Proxy , name , namespace string ) error {
73+ func resumeKubeadmControlPlane (ctx context. Context , proxy cluster.Proxy , name , namespace string ) error {
7374 // In the paused annotation we must replace slashes to ~1, see https://datatracker.ietf.org/doc/html/rfc6901#section-3.
7475 pausedAnnotation := strings .Replace (clusterv1 .PausedAnnotation , "/" , "~1" , - 1 )
7576 patch := client .RawPatch (types .JSONPatchType , []byte (fmt .Sprintf ("[{\" op\" : \" remove\" , \" path\" : \" /metadata/annotations/%s\" }]" , pausedAnnotation )))
7677
77- return patchKubeadmControlPlane (proxy , name , namespace , patch )
78+ return patchKubeadmControlPlane (ctx , proxy , name , namespace , patch )
7879}
0 commit comments