Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow GCE network to be reconfigured #3988

Merged
merged 1 commit into from
Dec 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions pkg/model/gcemodel/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,18 @@ type GCEModelContext struct {
*model.KopsModelContext
}

func (b *GCEModelContext) LinkToNetwork() *gcetasks.Network {
return &gcetasks.Network{Name: s("default")}
// LinkToNetwork returns the GCE Network object the cluster is located in
func (c *GCEModelContext) LinkToNetwork() *gcetasks.Network {
return &gcetasks.Network{Name: s(c.NameForNetwork())}
}

// NameForNetwork returns the name for the GCE Network the cluster is located in
func (c *GCEModelContext) NameForNetwork() string {
networkName := c.Cluster.Spec.NetworkID
if networkName == "" {
networkName = "default"
}
return networkName
}

// SafeObjectName returns the object name and cluster name escaped for GCE
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/gcemodel/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var _ fi.ModelBuilder = &NetworkModelBuilder{}

func (b *NetworkModelBuilder) Build(c *fi.ModelBuilderContext) error {
network := &gcetasks.Network{
Name: s("default"),
Name: s(b.NameForNetwork()),
Lifecycle: b.Lifecycle,
Mode: "auto", // Automatically create subnets, but stop using legacy mode
}
Expand Down