kubeadm: add default paths to 'upgrade diff'

After the flags to control manifest paths were removed,
the variables in diff.go remained empty and the validation
fails with "empty manifest path".

Always populate the paths with the kubeadm defaults under
/etc/kubernetes/manifest and remove the empty path validation.
This commit is contained in:
Lubomir I. Ivanov 2024-09-12 11:49:56 +03:00
parent 8e3adc4df6
commit 914fd40712
2 changed files with 5 additions and 12 deletions

View File

@ -57,8 +57,11 @@ type diffFlags struct {
// newCmdDiff returns the cobra command for `kubeadm upgrade diff`
func newCmdDiff(out io.Writer) *cobra.Command {
flags := &diffFlags{
kubeConfigPath: constants.GetAdminKubeConfigPath(),
out: out,
kubeConfigPath: constants.GetAdminKubeConfigPath(),
out: out,
apiServerManifestPath: constants.GetStaticPodFilepath(constants.KubeAPIServer, constants.GetStaticPodDirectory()),
controllerManagerManifestPath: constants.GetStaticPodFilepath(constants.KubeControllerManager, constants.GetStaticPodDirectory()),
schedulerManifestPath: constants.GetStaticPodFilepath(constants.KubeScheduler, constants.GetStaticPodDirectory()),
}
cmd := &cobra.Command{
@ -88,9 +91,6 @@ func newCmdDiff(out io.Writer) *cobra.Command {
func validateManifestsPath(manifests ...string) (err error) {
for _, manifestPath := range manifests {
if len(manifestPath) == 0 {
return errors.New("empty manifest path")
}
s, err := os.Stat(manifestPath)
if err != nil {
if os.IsNotExist(err) {

View File

@ -113,13 +113,6 @@ diff:
cfgPath: "missing-path-to-a-config",
expectedError: true,
},
{
name: "invalid: valid config but empty manifest path",
cfgPath: testUpgradeDiffConfig,
setManifestPath: true,
manifestPath: "",
expectedError: true,
},
{
name: "invalid: valid config but bad manifest path",
cfgPath: testUpgradeDiffConfig,