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

Fix for enabling agent level backups #188

Merged
merged 1 commit into from
Nov 13, 2024
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
8 changes: 1 addition & 7 deletions cmd/ecloud/ecloud_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

instances, err := service.GetInstances(params)
if err != nil {
return fmt.Errorf("Error retrieving instances: %s", err)

Check notice on line 76 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

return output.CommandOutput(cmd, OutputECloudInstancesProvider(instances))
Expand All @@ -87,7 +87,7 @@
Example: "ans ecloud instance show i-abcdef12",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("Missing instance")

Check notice on line 90 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

return nil
Expand Down Expand Up @@ -141,8 +141,7 @@
cmd.Flags().String("resource-tier", "", "ID of resource tier to deploy to. A default tier is chosen if not specified")
cmd.Flags().String("ip-address", "", "IP address to allocate for DHCP")
cmd.Flags().Bool("enable-vm-backups", false, "Enable VM-level backups")
cmd.Flags().Bool("enable-agent-backups", false, "Enable agent-level backups, requires a backup gateway")
cmd.Flags().String("backup-gateway-id", "", "Backup gateway ID, for use with agent level backups")
cmd.Flags().String("backup-gateway-id", "", "Backup gateway ID, enables agent-level backups")
cmd.Flags().Bool("wait", false, "Specifies that the command should wait until the instance has been completely created")

return cmd
Expand All @@ -157,13 +156,12 @@
createRequest.HostGroupID, _ = cmd.Flags().GetString("host-group")
createRequest.ResourceTierID, _ = cmd.Flags().GetString("resource-tier")
createRequest.BackupEnabled, _ = cmd.Flags().GetBool("enable-vm-backups")
createRequest.BackupAgentEnabled, _ = cmd.Flags().GetBool("enable-agent-backups")
createRequest.BackupGatewayID, _ = cmd.Flags().GetString("backup-gateway-id")
createRequest.Name, _ = cmd.Flags().GetString("name")

if cmd.Flags().Changed("vcpu") {
if cmd.Flags().Changed("vcpu-sockets") || cmd.Flags().Changed("vcpu-cores-per-socket") {
return fmt.Errorf("Flag --vcpu is mutually exclusive with --vcpu-sockets and --vcpu-cores-per-socket")

Check notice on line 164 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}
createRequest.VCPUCores, _ = cmd.Flags().GetInt("vcpu")
} else {
Expand All @@ -182,10 +180,6 @@

imageFlag, _ := cmd.Flags().GetString("image")

if createRequest.BackupAgentEnabled && createRequest.BackupGatewayID == "" {
return fmt.Errorf("A backup gateway is required to use agent-level backups, please specify a backup gateway ID")
}

if strings.HasPrefix(imageFlag, "img-") {
createRequest.ImageID = imageFlag
} else {
Expand All @@ -199,15 +193,15 @@
},
})
if err != nil {
return fmt.Errorf("Error retrieving images: %s", err)

Check notice on line 196 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

if len(images) == 0 {
return fmt.Errorf("Image not found with name '%s'", imageFlag)

Check notice on line 200 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

if len(images) > 1 {
return fmt.Errorf("Expected 1 image, got %d images", len(images))

Check notice on line 204 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

createRequest.ImageID = images[0].ID
Expand All @@ -218,20 +212,20 @@

instanceID, err := service.CreateInstance(createRequest)
if err != nil {
return fmt.Errorf("Error creating instance: %s", err)

Check notice on line 215 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

waitFlag, _ := cmd.Flags().GetBool("wait")
if waitFlag {
err := helper.WaitForCommand(InstanceResourceSyncStatusWaitFunc(service, instanceID, ecloud.SyncStatusComplete))
if err != nil {
return fmt.Errorf("Error waiting for instance sync: %s", err)

Check notice on line 222 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}
}

instance, err := service.GetInstance(instanceID)
if err != nil {
return fmt.Errorf("Error retrieving new instance: %s", err)

Check notice on line 228 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

return output.CommandOutput(cmd, OutputECloudInstancesProvider([]ecloud.Instance{instance}))
Expand All @@ -245,7 +239,7 @@
Example: "ans ecloud instance update i-abcdef12 --name \"my instance\"",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("Missing instance")

Check notice on line 242 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

return nil
Expand Down Expand Up @@ -274,7 +268,7 @@

if cmd.Flags().Changed("vcpu") {
if cmd.Flags().Changed("vcpu-sockets") || cmd.Flags().Changed("vcpu-cores-per-socket") {
return fmt.Errorf("Flag --vcpu is mutually exclusive with --vcpu-sockets and --vcpu-cores-per-socket")

Check notice on line 271 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}
patchRequest.VCPUCores, _ = cmd.Flags().GetInt("vcpu")
} else {
Expand Down Expand Up @@ -333,7 +327,7 @@
Example: "ans ecloud instance delete i-abcdef12",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("Missing instance")

Check notice on line 330 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

return nil
Expand Down Expand Up @@ -374,7 +368,7 @@
Example: "ans ecloud instance lock i-abcdef12",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("Missing instance")

Check notice on line 371 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

return nil
Expand All @@ -401,7 +395,7 @@
Example: "ans ecloud instance unlock i-abcdef12",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("Missing instance")

Check notice on line 398 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

return nil
Expand All @@ -428,7 +422,7 @@
Example: "ans ecloud instance start i-abcdef12",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("Missing instance")

Check notice on line 425 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

return nil
Expand Down Expand Up @@ -469,7 +463,7 @@
Example: "ans ecloud instance stop i-abcdef12",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("Missing instance")

Check notice on line 466 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

return nil
Expand Down Expand Up @@ -523,7 +517,7 @@
Example: "ans ecloud instance restart i-abcdef12",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("Missing instance")

Check notice on line 520 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

return nil
Expand Down Expand Up @@ -577,7 +571,7 @@
Example: "ans ecloud instance ssh i-abcdef12",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("Missing instance")

Check notice on line 574 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

return nil
Expand All @@ -599,22 +593,22 @@
if internal {
nics, err := service.GetInstanceNICs(args[0], connection.APIRequestParameters{})
if err != nil {
return fmt.Errorf("Error retrieving instance NICs: %s", err)

Check notice on line 596 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

if len(nics) < 1 {
return fmt.Errorf("No floating IPs found for instance")

Check notice on line 600 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

ipAddress = nics[0].IPAddress
} else {
fips, err := service.GetInstanceFloatingIPs(args[0], connection.APIRequestParameters{})
if err != nil {
return fmt.Errorf("Error retrieving instance floating IPs: %s", err)

Check notice on line 607 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

if len(fips) < 1 {
return fmt.Errorf("No floating IPs found for instance")

Check notice on line 611 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

ipAddress = fips[0].IPAddress
Expand All @@ -641,7 +635,7 @@
Example: "ans ecloud instance migrate i-abcdef12 --resource-tier rt-abcdef12",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("Missing instance")

Check notice on line 638 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

return nil
Expand Down Expand Up @@ -699,7 +693,7 @@
Example: "ans ecloud instance encrypt i-abcdef12",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("Missing instance")

Check notice on line 696 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

return nil
Expand Down Expand Up @@ -739,7 +733,7 @@
Example: "ans ecloud instance decrypt i-abcdef12",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("Missing instance")

Check notice on line 736 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

return nil
Expand Down Expand Up @@ -789,7 +783,7 @@
case *ecloud.InstanceNotFoundError:
return true, nil
default:
return false, fmt.Errorf("Failed to retrieve instance [%s]: %s", instanceID, err)

Check notice on line 786 in cmd/ecloud/ecloud_instance.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}
}

Expand Down
10 changes: 5 additions & 5 deletions cmd/ecloud/ecloud_vpnprofilegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
func ecloudVPNProfileGroupRootCmd(f factory.ClientFactory) *cobra.Command {
cmd := &cobra.Command{
Use: "vpnprofilegroup",
Short: "sub-commands relating to VPN sessions",
Short: "sub-commands relating to VPN profile groups",
}

// Child commands
Expand All @@ -27,8 +27,8 @@
func ecloudVPNProfileGroupListCmd(f factory.ClientFactory) *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "Lists VPN sessions",
Long: "This command lists VPN sessions",
Short: "Lists VPN profile groups",
Long: "This command lists VPN profile groups",
Example: "ans ecloud vpnprofilegroup list",
RunE: ecloudCobraRunEFunc(f, ecloudVPNProfileGroupList),
}
Expand All @@ -48,7 +48,7 @@

sessions, err := service.GetVPNProfileGroups(params)
if err != nil {
return fmt.Errorf("Error retrieving VPN sessions: %s", err)

Check notice on line 51 in cmd/ecloud/ecloud_vpnprofilegroup.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

return output.CommandOutput(cmd, OutputECloudVPNProfileGroupsProvider(sessions))
Expand All @@ -57,12 +57,12 @@
func ecloudVPNProfileGroupShowCmd(f factory.ClientFactory) *cobra.Command {
return &cobra.Command{
Use: "show <session: id>...",
Short: "Shows a VPN session",
Long: "This command shows one or more VPN sessions",
Short: "Shows a VPN profile group",
Long: "This command shows one or more VPN profile groups",
Example: "ans ecloud vpnprofilegroup show vpns-abcdef12",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return errors.New("Missing VPN session")

Check notice on line 65 in cmd/ecloud/ecloud_vpnprofilegroup.go

View workflow job for this annotation

GitHub Actions / Qodana for Go

Error string should not be capitalized or end with punctuation

Error string should not be capitalized or end with punctuation mark
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.0
toolchain go1.23.2

require (
github.com/ans-group/sdk-go v1.22.0
github.com/ans-group/sdk-go v1.22.1
github.com/blang/semver v3.5.1+incompatible
github.com/golang/mock v1.6.0
github.com/iancoleman/strcase v0.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/ans-group/go-durationstring v1.2.0 h1:UJIuQATkp0t1rBvZsHRwki33YHV9E+Ulro+3NbMB7MM=
github.com/ans-group/go-durationstring v1.2.0/go.mod h1:QGF9Mdpq9058QXaut8r55QWu6lcHX6i/GvF1PZVkV6o=
github.com/ans-group/sdk-go v1.22.0 h1:/eD8CCYkHjqTje+WqfYLNSot2NmjACFrGRqtdMsM5Do=
github.com/ans-group/sdk-go v1.22.0/go.mod h1:Dx34ZUbyHNniHAKsDy/vp8q8hQC5L51ub2sv9We7d8E=
github.com/ans-group/sdk-go v1.22.1 h1:3wfYuWXPldIzKT393+yxQBPjP+O0kPZHzsD1q6zm/+E=
github.com/ans-group/sdk-go v1.22.1/go.mod h1:Dx34ZUbyHNniHAKsDy/vp8q8hQC5L51ub2sv9We7d8E=
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/mock_ecloudservice.go

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

Loading