Skip to content

Commit

Permalink
Merge pull request #8711 from tanjunchen/remove-TODO02
Browse files Browse the repository at this point in the history
remove // TODO move this into networking.go :(
  • Loading branch information
k8s-ci-robot committed Mar 10, 2020
2 parents b65031f + d73bcc1 commit ba231e9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
1 change: 0 additions & 1 deletion pkg/apis/kops/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ var DefaultChannelBase = "https://raw.githubusercontent.com/kubernetes/kops/mast

const (
DefaultChannel = "stable"
AlphaChannel = "alpha"
)

type Channel struct {
Expand Down
42 changes: 23 additions & 19 deletions pkg/apis/kops/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,29 @@ func (c *Cluster) FillDefaults() error {
c.Spec.Networking = &NetworkingSpec{}
}

// TODO move this into networking.go :(
c.fillClusterSpecNetworkingSpec()

if c.Spec.Channel == "" {
c.Spec.Channel = DefaultChannel
}

if c.ObjectMeta.Name == "" {
return fmt.Errorf("cluster Name not set in FillDefaults")
}

if c.Spec.MasterInternalName == "" {
c.Spec.MasterInternalName = "api.internal." + c.ObjectMeta.Name
}

if c.Spec.MasterPublicName == "" {
c.Spec.MasterPublicName = "api." + c.ObjectMeta.Name
}

return nil
}

// fillClusterSpecNetworking provides default value if c.Spec.NetworkingSpec is nil
func (c *Cluster) fillClusterSpecNetworkingSpec() {
if c.Spec.Networking.Classic != nil {
// OK
} else if c.Spec.Networking.Kubenet != nil {
Expand Down Expand Up @@ -602,24 +624,6 @@ func (c *Cluster) FillDefaults() error {
// No networking model selected; choose Kubenet
c.Spec.Networking.Kubenet = &KubenetNetworkingSpec{}
}

if c.Spec.Channel == "" {
c.Spec.Channel = DefaultChannel
}

if c.ObjectMeta.Name == "" {
return fmt.Errorf("cluster Name not set in FillDefaults")
}

if c.Spec.MasterInternalName == "" {
c.Spec.MasterInternalName = "api.internal." + c.ObjectMeta.Name
}

if c.Spec.MasterPublicName == "" {
c.Spec.MasterPublicName = "api." + c.ObjectMeta.Name
}

return nil
}

// SharedVPC is a simple helper function which makes the templates for a shared VPC clearer
Expand Down

0 comments on commit ba231e9

Please sign in to comment.