Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Commit

Permalink
Copy kubernetes version from machine into cluster on apply if cluster…
Browse files Browse the repository at this point in the history
… value is not set (#319)

Co-authored-by: Jerry Jackson <[email protected]>
  • Loading branch information
jrryjcksn and weave-e2e-quickstart authored Dec 2, 2020
1 parent 85ae4c8 commit 61d9e53
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions cmd/wksctl/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
existinginfrav1 "github.com/weaveworks/cluster-api-provider-existinginfra/apis/cluster.weave.works/v1alpha3"
"github.com/weaveworks/cluster-api-provider-existinginfra/pkg/apis/wksprovider/machine/config"
capeios "github.com/weaveworks/cluster-api-provider-existinginfra/pkg/apis/wksprovider/machine/os"
"github.com/weaveworks/cluster-api-provider-existinginfra/pkg/cluster/machine"
"github.com/weaveworks/cluster-api-provider-existinginfra/pkg/scheme"
capeispecs "github.com/weaveworks/cluster-api-provider-existinginfra/pkg/specs"
"github.com/weaveworks/cluster-api-provider-existinginfra/pkg/utilities/kubeadm"
Expand Down Expand Up @@ -186,22 +187,32 @@ func (a *Applier) initiateCluster(ctx context.Context, clusterManifestPath, mach
}

// Read manifests and pass in the contents
machinesManifest, err := ioutil.ReadFile(machinesManifestPath)
if err != nil {
return errors.Wrap(err, "failed to read machines manifest: ")
}

cluster, eic, err := parseCluster(clusterManifest)
if err != nil {
return errors.Wrap(err, "failed to parse cluster manifest: ")
}

// Allow for versions to be on machines only (for now)
if eic.Spec.KubernetesVersion == "" {
machines, _, err := machine.Parse(ioutil.NopCloser(bytes.NewReader(machinesManifest)))
if err != nil {
return errors.Wrap(err, "failed to parse machine manifest: ")
}

eic.Spec.KubernetesVersion = *machines[0].Spec.Version
}

eic.Spec.DeprecatedSSHKeyPath = a.Params.sshKeyPath
clusterManifest, err = unparseCluster(cluster, eic)
if err != nil {
return errors.Wrap(err, "failed to annotate cluster manifest: ")
}

machinesManifest, err := ioutil.ReadFile(machinesManifestPath)
if err != nil {
return errors.Wrap(err, "failed to read machines manifest: ")
}

// Read sealed secret cert and key
var cert []byte
var key []byte
Expand Down

0 comments on commit 61d9e53

Please sign in to comment.