Skip to content

Commit

Permalink
Use region with GCE to enable reserved IPs
Browse files Browse the repository at this point in the history
Fixes an issue for inlets users originally reported for
inletsctl.

Ref: inlets/inletsctl#125

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed May 3, 2023
1 parent b061d19 commit 1062f18
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 40 deletions.
2 changes: 1 addition & 1 deletion controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ func getHostConfig(c *Controller, tunnel *inletsv1alpha1.Tunnel, service *corev1
Name: tunnel.Name,
OS: "projects/ubuntu-os-cloud/global/images/ubuntu-minimal-2004-focal-v20210707",
Plan: "f1-micro",
Region: "",
Region: c.infraConfig.Region,
UserData: userData,
Additional: map[string]string{
"projectid": c.infraConfig.ProjectID,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.19

require (
github.com/google/go-cmp v0.5.9
github.com/inlets/cloud-provision v0.6.4
github.com/inlets/cloud-provision v0.6.5
github.com/sethvargo/go-password v0.2.0
k8s.io/api v0.26.1
k8s.io/apimachinery v0.26.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ github.com/inlets/cloud-provision v0.6.3 h1:Ldr+80yuLqthgGbGgLBEtq0Vl3EfTLBipTFu
github.com/inlets/cloud-provision v0.6.3/go.mod h1:zK0cG+FIZuKHyxx0PwBim5qM1AApAxmZfCExZa3VVqc=
github.com/inlets/cloud-provision v0.6.4 h1:mL87c9CUBFapLd+zBxV7WOfqgDvjZUY1Egfn9p14xqc=
github.com/inlets/cloud-provision v0.6.4/go.mod h1:zK0cG+FIZuKHyxx0PwBim5qM1AApAxmZfCExZa3VVqc=
github.com/inlets/cloud-provision v0.6.5 h1:IOzdBguO+QkqO3uEwyv1bNBHyI7EhyEJr5B3br7Q4eA=
github.com/inlets/cloud-provision v0.6.5/go.mod h1:zK0cG+FIZuKHyxx0PwBim5qM1AApAxmZfCExZa3VVqc=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
Expand Down
3 changes: 3 additions & 0 deletions validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ func validateFlags(c InfraConfig) error {
if len(c.Zone) == 0 {
return fmt.Errorf("zone required for provider: %s", c.Provider)
}
if len(c.Region) == 0 {
return fmt.Errorf("region required for provider: %s", c.Provider)
}
}
if c.Provider == "azure" {
if len(c.SubscriptionID) == 0 {
Expand Down
14 changes: 14 additions & 0 deletions validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ func Test_validateFlags_GCE_Zone(t *testing.T) {
}
}

func Test_validateFlags_GCE_Region(t *testing.T) {
c := InfraConfig{
Provider: "gce",
Zone: "Zone",
ProjectID: "my-project",
Region: "",
}
err := validateFlags(c)
want := "region required for provider: gce"
if err.Error() != want {
t.Errorf("expected error: %s, got: %s", want, err)
}
}

func Test_validateFlags_GCE_ProjectID(t *testing.T) {
c := InfraConfig{
Provider: "gce",
Expand Down
36 changes: 20 additions & 16 deletions vendor/github.com/inlets/cloud-provision/provision/ec2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 69 additions & 21 deletions vendor/github.com/inlets/cloud-provision/provision/gce.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ github.com/hetznercloud/hcloud-go/hcloud/schema
# github.com/imdario/mergo v0.3.6
## explicit
github.com/imdario/mergo
# github.com/inlets/cloud-provision v0.6.4
# github.com/inlets/cloud-provision v0.6.5
## explicit; go 1.18
github.com/inlets/cloud-provision/provision
# github.com/jmespath/go-jmespath v0.4.0
Expand Down

0 comments on commit 1062f18

Please sign in to comment.