@@ -42,31 +42,22 @@ import (
42
42
kubeconfigutil "k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig"
43
43
)
44
44
45
- // upgradeVariables holds variables needed for performing an upgrade or planning to do so
46
- // TODO - Restructure or rename upgradeVariables
47
- type upgradeVariables struct {
48
- client clientset.Interface
49
- cfg * kubeadmapi.InitConfiguration
50
- versionGetter upgrade.VersionGetter
51
- waiter apiclient.Waiter
52
- }
53
-
54
45
// enforceRequirements verifies that it's okay to upgrade and then returns the variables needed for the rest of the procedure
55
- func enforceRequirements (flags * applyPlanFlags , dryRun bool , newK8sVersion string ) (* upgradeVariables , error ) {
46
+ func enforceRequirements (flags * applyPlanFlags , dryRun bool , newK8sVersion string ) (clientset. Interface , upgrade. VersionGetter , * kubeadmapi. InitConfiguration , error ) {
56
47
57
48
client , err := getClient (flags .kubeConfigPath , dryRun )
58
49
if err != nil {
59
- return nil , errors .Wrapf (err , "couldn't create a Kubernetes client from file %q" , flags .kubeConfigPath )
50
+ return nil , nil , nil , errors .Wrapf (err , "couldn't create a Kubernetes client from file %q" , flags .kubeConfigPath )
60
51
}
61
52
62
53
// Check if the cluster is self-hosted
63
54
if upgrade .IsControlPlaneSelfHosted (client ) {
64
- return nil , errors .Errorf ("cannot upgrade a self-hosted control plane" )
55
+ return nil , nil , nil , errors .Errorf ("cannot upgrade a self-hosted control plane" )
65
56
}
66
57
67
58
// Run healthchecks against the cluster
68
59
if err := upgrade .CheckClusterHealth (client , flags .ignorePreflightErrorsSet ); err != nil {
69
- return nil , errors .Wrap (err , "[upgrade/health] FATAL" )
60
+ return nil , nil , nil , errors .Wrap (err , "[upgrade/health] FATAL" )
70
61
}
71
62
72
63
// Fetch the configuration from a file or ConfigMap and validate it
@@ -91,7 +82,7 @@ func enforceRequirements(flags *applyPlanFlags, dryRun bool, newK8sVersion strin
91
82
fmt .Println ("" )
92
83
err = errors .Errorf ("the ConfigMap %q in the %s namespace used for getting configuration information was not found" , constants .KubeadmConfigConfigMap , metav1 .NamespaceSystem )
93
84
}
94
- return nil , errors .Wrap (err , "[upgrade/config] FATAL" )
85
+ return nil , nil , nil , errors .Wrap (err , "[upgrade/config] FATAL" )
95
86
}
96
87
97
88
// If a new k8s version should be set, apply the change before printing the config
@@ -103,7 +94,7 @@ func enforceRequirements(flags *applyPlanFlags, dryRun bool, newK8sVersion strin
103
94
if flags .featureGatesString != "" {
104
95
cfg .FeatureGates , err = features .NewFeatureGate (& features .InitFeatureGates , flags .featureGatesString )
105
96
if err != nil {
106
- return nil , errors .Wrap (err , "[upgrade/config] FATAL" )
97
+ return nil , nil , nil , errors .Wrap (err , "[upgrade/config] FATAL" )
107
98
}
108
99
}
109
100
@@ -112,22 +103,16 @@ func enforceRequirements(flags *applyPlanFlags, dryRun bool, newK8sVersion strin
112
103
for _ , m := range msg {
113
104
fmt .Printf ("[upgrade/config] %s\n " , m )
114
105
}
115
- return nil , errors .New ("[upgrade/config] FATAL. Unable to upgrade a cluster using deprecated feature-gate flags. Please see the release notes" )
106
+ return nil , nil , nil , errors .New ("[upgrade/config] FATAL. Unable to upgrade a cluster using deprecated feature-gate flags. Please see the release notes" )
116
107
}
117
108
118
109
// If the user told us to print this information out; do it!
119
110
if flags .printConfig {
120
111
printConfiguration (& cfg .ClusterConfiguration , os .Stdout )
121
112
}
122
113
123
- return & upgradeVariables {
124
- client : client ,
125
- cfg : cfg ,
126
- // Use a real version getter interface that queries the API server, the kubeadm client and the Kubernetes CI system for latest versions
127
- versionGetter : upgrade .NewOfflineVersionGetter (upgrade .NewKubeVersionGetter (client , os .Stdout ), newK8sVersion ),
128
- // Use the waiter conditionally based on the dryrunning variable
129
- waiter : getWaiter (dryRun , client ),
130
- }, nil
114
+ // Use a real version getter interface that queries the API server, the kubeadm client and the Kubernetes CI system for latest versions
115
+ return client , upgrade .NewOfflineVersionGetter (upgrade .NewKubeVersionGetter (client , os .Stdout ), cfg .KubernetesVersion ), cfg , nil
131
116
}
132
117
133
118
// printConfiguration prints the external version of the API to yaml
0 commit comments