@@ -26,8 +26,50 @@ import (
26
26
"sigs.k8s.io/cluster-api/cmd/clusterctl/internal/util"
27
27
)
28
28
29
- // RolloutOptions carries the base set of options supported by rollout command.
30
- type RolloutOptions struct {
29
+ // RolloutRestartOptions carries the options supported by RolloutRestart.
30
+ type RolloutRestartOptions struct {
31
+ // Kubeconfig defines the kubeconfig to use for accessing the management cluster. If empty,
32
+ // default rules for kubeconfig discovery will be used.
33
+ Kubeconfig Kubeconfig
34
+
35
+ // Resources for the rollout command
36
+ Resources []string
37
+
38
+ // Namespace where the resource(s) live. If unspecified, the namespace name will be inferred
39
+ // from the current configuration.
40
+ Namespace string
41
+ }
42
+
43
+ // RolloutPauseOptions carries the options supported by RolloutPause.
44
+ type RolloutPauseOptions struct {
45
+ // Kubeconfig defines the kubeconfig to use for accessing the management cluster. If empty,
46
+ // default rules for kubeconfig discovery will be used.
47
+ Kubeconfig Kubeconfig
48
+
49
+ // Resources for the rollout command
50
+ Resources []string
51
+
52
+ // Namespace where the resource(s) live. If unspecified, the namespace name will be inferred
53
+ // from the current configuration.
54
+ Namespace string
55
+ }
56
+
57
+ // RolloutResumeOptions carries the options supported by RolloutResume.
58
+ type RolloutResumeOptions struct {
59
+ // Kubeconfig defines the kubeconfig to use for accessing the management cluster. If empty,
60
+ // default rules for kubeconfig discovery will be used.
61
+ Kubeconfig Kubeconfig
62
+
63
+ // Resources for the rollout command
64
+ Resources []string
65
+
66
+ // Namespace where the resource(s) live. If unspecified, the namespace name will be inferred
67
+ // from the current configuration.
68
+ Namespace string
69
+ }
70
+
71
+ // RolloutUndoOptions carries the options supported by RolloutUndo.
72
+ type RolloutUndoOptions struct {
31
73
// Kubeconfig defines the kubeconfig to use for accessing the management cluster. If empty,
32
74
// default rules for kubeconfig discovery will be used.
33
75
Kubeconfig Kubeconfig
@@ -40,16 +82,15 @@ type RolloutOptions struct {
40
82
Namespace string
41
83
42
84
// Revision number to rollback to when issuing the undo command.
43
- // Revision number of a specific revision when issuing the history command.
44
85
ToRevision int64
45
86
}
46
87
47
- func (c * clusterctlClient ) RolloutRestart (options RolloutOptions ) error {
88
+ func (c * clusterctlClient ) RolloutRestart (options RolloutRestartOptions ) error {
48
89
clusterClient , err := c .clusterClientFactory (ClusterClientFactoryInput {Kubeconfig : options .Kubeconfig })
49
90
if err != nil {
50
91
return err
51
92
}
52
- objRefs , err := getObjectRefs (clusterClient , options )
93
+ objRefs , err := getObjectRefs (clusterClient , options . Namespace , options . Resources )
53
94
if err != nil {
54
95
return err
55
96
}
@@ -61,12 +102,12 @@ func (c *clusterctlClient) RolloutRestart(options RolloutOptions) error {
61
102
return nil
62
103
}
63
104
64
- func (c * clusterctlClient ) RolloutPause (options RolloutOptions ) error {
105
+ func (c * clusterctlClient ) RolloutPause (options RolloutPauseOptions ) error {
65
106
clusterClient , err := c .clusterClientFactory (ClusterClientFactoryInput {Kubeconfig : options .Kubeconfig })
66
107
if err != nil {
67
108
return err
68
109
}
69
- objRefs , err := getObjectRefs (clusterClient , options )
110
+ objRefs , err := getObjectRefs (clusterClient , options . Namespace , options . Resources )
70
111
if err != nil {
71
112
return err
72
113
}
@@ -78,12 +119,12 @@ func (c *clusterctlClient) RolloutPause(options RolloutOptions) error {
78
119
return nil
79
120
}
80
121
81
- func (c * clusterctlClient ) RolloutResume (options RolloutOptions ) error {
122
+ func (c * clusterctlClient ) RolloutResume (options RolloutResumeOptions ) error {
82
123
clusterClient , err := c .clusterClientFactory (ClusterClientFactoryInput {Kubeconfig : options .Kubeconfig })
83
124
if err != nil {
84
125
return err
85
126
}
86
- objRefs , err := getObjectRefs (clusterClient , options )
127
+ objRefs , err := getObjectRefs (clusterClient , options . Namespace , options . Resources )
87
128
if err != nil {
88
129
return err
89
130
}
@@ -95,12 +136,12 @@ func (c *clusterctlClient) RolloutResume(options RolloutOptions) error {
95
136
return nil
96
137
}
97
138
98
- func (c * clusterctlClient ) RolloutUndo (options RolloutOptions ) error {
139
+ func (c * clusterctlClient ) RolloutUndo (options RolloutUndoOptions ) error {
99
140
clusterClient , err := c .clusterClientFactory (ClusterClientFactoryInput {Kubeconfig : options .Kubeconfig })
100
141
if err != nil {
101
142
return err
102
143
}
103
- objRefs , err := getObjectRefs (clusterClient , options )
144
+ objRefs , err := getObjectRefs (clusterClient , options . Namespace , options . Resources )
104
145
if err != nil {
105
146
return err
106
147
}
@@ -112,21 +153,21 @@ func (c *clusterctlClient) RolloutUndo(options RolloutOptions) error {
112
153
return nil
113
154
}
114
155
115
- func getObjectRefs (clusterClient cluster.Client , options RolloutOptions ) ([]corev1.ObjectReference , error ) {
156
+ func getObjectRefs (clusterClient cluster.Client , namespace string , resources [] string ) ([]corev1.ObjectReference , error ) {
116
157
// If the option specifying the Namespace is empty, try to detect it.
117
- if options . Namespace == "" {
158
+ if namespace == "" {
118
159
currentNamespace , err := clusterClient .Proxy ().CurrentNamespace ()
119
160
if err != nil {
120
161
return []corev1.ObjectReference {}, err
121
162
}
122
- options . Namespace = currentNamespace
163
+ namespace = currentNamespace
123
164
}
124
165
125
- if len (options . Resources ) == 0 {
166
+ if len (resources ) == 0 {
126
167
return []corev1.ObjectReference {}, fmt .Errorf ("required resource not specified" )
127
168
}
128
- normalized := normalizeResources (options . Resources )
129
- objRefs , err := util .GetObjectReferences (options . Namespace , normalized ... )
169
+ normalized := normalizeResources (resources )
170
+ objRefs , err := util .GetObjectReferences (namespace , normalized ... )
130
171
if err != nil {
131
172
return []corev1.ObjectReference {}, err
132
173
}
0 commit comments