Skip to content

Commit

Permalink
compute private instance support (#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdantas authored Dec 21, 2022
1 parent 0fcf509 commit 72e35b3
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 6 deletions.
6 changes: 6 additions & 0 deletions cmd/instance_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type instanceCreateCmd struct {
InstanceType string `cli-usage:"instance type (format: [FAMILY.]SIZE)"`
Labels map[string]string `cli-flag:"label" cli-usage:"instance label (format: key=value)"`
PrivateNetworks []string `cli-flag:"private-network" cli-usage:"instance Private Network NAME|ID (can be specified multiple times)"`
PrivateInstance bool `cli-flag:"private-instance" cli-usage:"enable private instance to be created"`
SSHKey string `cli-flag:"ssh-key" cli-usage:"SSH key to deploy on the instance"`
SecurityGroups []string `cli-flag:"security-group" cli-usage:"instance Security Group NAME|ID (can be specified multiple times)"`
Template string `cli-usage:"instance template NAME|ID"`
Expand Down Expand Up @@ -83,6 +84,11 @@ func (c *instanceCreateCmd) cmdRun(_ *cobra.Command, _ []string) error {
SSHKey: nonEmptyStringPtr(c.SSHKey),
}

if c.PrivateInstance {
t := "none"
instance.PublicIPAssignment = &t
}

ctx := exoapi.WithEndpoint(gContext, exoapi.NewReqEndpoint(gCurrentAccount.Environment, c.Zone))

if l := len(c.AntiAffinityGroups); l > 0 {
Expand Down
6 changes: 6 additions & 0 deletions cmd/instance_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type instanceShowOutput struct {
Zone string `json:"zoneid"`
AntiAffinityGroups []string `json:"anti_affinity_groups" outputLabel:"Anti-Affinity Groups"`
SecurityGroups []string `json:"security_groups"`
PrivateInstance string `json:"private-instance" outputLabel:"Private Instance"`
PrivateNetworks []string `json:"private_networks"`
ElasticIPs []string `json:"elastic_ips" outputLabel:"Elastic IPs"`
IPAddress string `json:"ip_address"`
Expand Down Expand Up @@ -108,6 +109,11 @@ func (c *instanceShowCmd) cmdRun(cmd *cobra.Command, _ []string) error {
Zone: c.Zone,
}

out.PrivateInstance = "No"
if instance.PublicIPAssignment != nil && *instance.PublicIPAssignment == "none" {
out.PrivateInstance = "Yes"
}

if instance.AntiAffinityGroupIDs != nil {
for _, id := range *instance.AntiAffinityGroupIDs {
antiAffinityGroup, err := cs.GetAntiAffinityGroup(ctx, c.Zone, id)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/s3 v1.2.0
github.com/aws/smithy-go v1.1.0
github.com/dustin/go-humanize v1.0.0
github.com/exoscale/egoscale v0.92.0
github.com/exoscale/egoscale v0.93.0
github.com/exoscale/openapi-cli-generator v1.1.0
github.com/fatih/camelcase v1.0.0
github.com/fsnotify/fsnotify v1.4.9 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ github.com/dlclark/regexp2 v1.2.0 h1:8sAhBGEM0dRWogWqWyQeIJnxjWO6oIjl8FKqREDsGfk
github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/exoscale/egoscale v0.92.0 h1:Cy/oZxuiKfFhIaatkG7KBLaoG/jtoCXAgYPMT97iX/k=
github.com/exoscale/egoscale v0.92.0/go.mod h1:BAb9p4rmyU+Wl400CJZO5270H2sXtdsZjLcm5xMKkz4=
github.com/exoscale/egoscale v0.93.0 h1:QHxHrM8UULwgQbTdAUkZb6bnA7GmOodFR1MP5Upgjrg=
github.com/exoscale/egoscale v0.93.0/go.mod h1:BAb9p4rmyU+Wl400CJZO5270H2sXtdsZjLcm5xMKkz4=
github.com/exoscale/openapi-cli-generator v1.1.0 h1:fYjmPqHR5vxlOBrbvde7eo7bISNQIFxsGn4A5/acwKA=
github.com/exoscale/openapi-cli-generator v1.1.0/go.mod h1:TZBnbT7f3hJ5ImyUphJwRM+X5xF/zCQZ6o8a42gQeTs=
github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8=
Expand Down
5 changes: 5 additions & 0 deletions vendor/github.com/exoscale/egoscale/CHANGELOG.md

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

5 changes: 4 additions & 1 deletion vendor/github.com/exoscale/egoscale/v2/instance.go

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

2 changes: 1 addition & 1 deletion vendor/github.com/exoscale/egoscale/version/version.go

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 @@ -140,7 +140,7 @@ github.com/dlclark/regexp2/syntax
# github.com/dustin/go-humanize v1.0.0
## explicit
github.com/dustin/go-humanize
# github.com/exoscale/egoscale v0.92.0
# github.com/exoscale/egoscale v0.93.0
## explicit
github.com/exoscale/egoscale
github.com/exoscale/egoscale/v2
Expand Down

0 comments on commit 72e35b3

Please sign in to comment.