@@ -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
@@ -84,7 +75,7 @@ func enforceRequirements(flags *applyPlanFlags, dryRun bool, newK8sVersion strin
84
75
fmt .Println ("" )
85
76
err = errors .Errorf ("the ConfigMap %q in the %s namespace used for getting configuration information was not found" , constants .KubeadmConfigConfigMap , metav1 .NamespaceSystem )
86
77
}
87
- return nil , errors .Wrap (err , "[upgrade/config] FATAL" )
78
+ return nil , nil , nil , errors .Wrap (err , "[upgrade/config] FATAL" )
88
79
}
89
80
90
81
// If a new k8s version should be set, apply the change before printing the config
@@ -96,7 +87,7 @@ func enforceRequirements(flags *applyPlanFlags, dryRun bool, newK8sVersion strin
96
87
if flags .featureGatesString != "" {
97
88
cfg .FeatureGates , err = features .NewFeatureGate (& features .InitFeatureGates , flags .featureGatesString )
98
89
if err != nil {
99
- return nil , errors .Wrap (err , "[upgrade/config] FATAL" )
90
+ return nil , nil , nil , errors .Wrap (err , "[upgrade/config] FATAL" )
100
91
}
101
92
}
102
93
@@ -105,22 +96,16 @@ func enforceRequirements(flags *applyPlanFlags, dryRun bool, newK8sVersion strin
105
96
for _ , m := range msg {
106
97
fmt .Printf ("[upgrade/config] %s\n " , m )
107
98
}
108
- return nil , errors .New ("[upgrade/config] FATAL. Unable to upgrade a cluster using deprecated feature-gate flags. Please see the release notes" )
99
+ return nil , nil , nil , errors .New ("[upgrade/config] FATAL. Unable to upgrade a cluster using deprecated feature-gate flags. Please see the release notes" )
109
100
}
110
101
111
102
// If the user told us to print this information out; do it!
112
103
if flags .printConfig {
113
104
printConfiguration (& cfg .ClusterConfiguration , os .Stdout )
114
105
}
115
106
116
- return & upgradeVariables {
117
- client : client ,
118
- cfg : cfg ,
119
- // Use a real version getter interface that queries the API server, the kubeadm client and the Kubernetes CI system for latest versions
120
- versionGetter : upgrade .NewOfflineVersionGetter (upgrade .NewKubeVersionGetter (client , os .Stdout ), newK8sVersion ),
121
- // Use the waiter conditionally based on the dryrunning variable
122
- waiter : getWaiter (dryRun , client ),
123
- }, nil
107
+ // Use a real version getter interface that queries the API server, the kubeadm client and the Kubernetes CI system for latest versions
108
+ return client , upgrade .NewOfflineVersionGetter (upgrade .NewKubeVersionGetter (client , os .Stdout ), cfg .KubernetesVersion ), cfg , nil
124
109
}
125
110
126
111
// printConfiguration prints the external version of the API to yaml
0 commit comments