Skip to content

Commit

Permalink
bumping go from 1.17 to 1.19 (#284)
Browse files Browse the repository at this point in the history
* add ARM v6 support

* bumping go from 1.17 to 1.19

* Replaced golint with golangci-lint

* Replaced golint with golangci-lint

* Fix linting issues and unhandle error returns

* Fix linter issues

* Rename github workflow

* Make load balancer display show VPN

* Gofmt cmd/dnsRecord

Co-authored-by: Michael Riley <[email protected]>
  • Loading branch information
mondragonfx and optik-aper committed Oct 4, 2022
1 parent 8de43d2 commit 5a53115
Show file tree
Hide file tree
Showing 285 changed files with 16,703 additions and 6,478 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.19

- name: Run unit tests and coverage test
id: test-coverage
Expand Down
21 changes: 8 additions & 13 deletions .github/workflows/gochecks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,25 @@ on:
- master

jobs:
Go-Lint:
Golangci-Lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.17'
go-version: 1.19

- name: Install dependencies
run: |
go version
go get -u golang.org/x/lint/golint
go install github.com/golangci/golangci-lint/cmd/[email protected]
- name: Run Lint
- name: Run golangci-lint
run: |
golint_files=$(golint cmd)
if [[ -n ${golint_files} ]]; then
echo 'fix the following linting errors:'
echo "${golint_files}"
exit 1
fi
exit 0
golangci-lint run cmd/...
Go-Fmt:
runs-on: ubuntu-latest
Expand All @@ -39,7 +34,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.17'
go-version: 1.19

- name: Run fmt
run: |
Expand All @@ -49,4 +44,4 @@ jobs:
echo "${gofmt_files}"
exit 1
fi
exit 0
exit 0
2 changes: 1 addition & 1 deletion .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.19
-
name: Docker Login
env:
Expand Down
3 changes: 2 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ builds:
goarch:
- amd64
- arm64


archives:
-
Expand Down Expand Up @@ -94,4 +95,4 @@ dockers:
release:
github:
owner: vultr
name: vultr-cli
name: vultr-cli
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.17-alpine as builder
FROM golang:1.19-alpine as builder

RUN apk add --update \
make
Expand All @@ -17,4 +17,4 @@ FROM alpine:latest
RUN apk add --no-cache ca-certificates

COPY --from=builder /go/src/github.com/vultr/vultr-cli/builds/* /
ENTRYPOINT ["/vultr-cli_linux_amd64"]
ENTRYPOINT ["/vultr-cli_linux_amd64"]
19 changes: 15 additions & 4 deletions cmd/bareMetal.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ func BareMetal() *cobra.Command {
Use: "bare-metal",
Short: "bare-metal is used to access bare metal server commands",
Aliases: []string{"bm"},
Long: bareMetalLong,
Example: bareMetalExample,
}

bareMetalCmd.AddCommand(
Expand All @@ -73,9 +75,15 @@ func BareMetal() *cobra.Command {

// create server
bareMetalCreate.Flags().StringP("region", "r", "", "ID of the region where the server will be created.")
bareMetalCreate.MarkFlagRequired("region")
if err := bareMetalCreate.MarkFlagRequired("region"); err != nil {
fmt.Printf("error marking bare metal create 'region' flag required: %v\n", err)
os.Exit(1)
}
bareMetalCreate.Flags().StringP("plan", "p", "", "ID of the plan that the server will subscribe to.")
bareMetalCreate.MarkFlagRequired("plan")
if err := bareMetalCreate.MarkFlagRequired("plan"); err != nil {
fmt.Printf("error marking bare metal create 'plan' flag required: %v\n", err)
os.Exit(1)
}
bareMetalCreate.Flags().IntP("os", "o", 0, "ID of the operating system that will be installed on the server.")
bareMetalCreate.Flags().StringP("script", "s", "", "(optional) ID of the startup script that will run after the server is created.")
bareMetalCreate.Flags().StringP("snapshot", "", "", "(optional) ID of the snapshot that the server will be restored from.")
Expand All @@ -102,7 +110,10 @@ func BareMetal() *cobra.Command {
bareMetalListIPV6.Flags().IntP("per-page", "p", 100, "(optional) Number of items requested per page. Default is 100 and Max is 500.")

bareMetalTags.Flags().StringSliceP("tags", "t", []string{}, "A comma separated list of tags to apply to the server")
bareMetalTags.MarkFlagRequired("tags")
if err := bareMetalTags.MarkFlagRequired("tags"); err != nil {
fmt.Printf("error marking bare metal create 'tags' flag required: %v\n", err)
os.Exit(1)
}

return bareMetalCmd
}
Expand Down Expand Up @@ -452,7 +463,7 @@ func optionCheckBM(options map[string]interface{}) (string, error) {
}

if len(result) > 1 {
return "", fmt.Errorf("Too many options have been selected : %v : please select one", result)
return "", fmt.Errorf("too many options have been selected : %v : please select one", result)
}

// Return back an empty slice so we can possibly add in osID
Expand Down
3 changes: 1 addition & 2 deletions cmd/bareMetalUserData.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"encoding/base64"
"errors"
"fmt"
"io/ioutil"
"os"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -74,7 +73,7 @@ var bareMetalSetUserData = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
userData, _ := cmd.Flags().GetString("userdata")

rawData, err := ioutil.ReadFile(userData)
rawData, err := os.ReadFile(userData)
if err != nil {
fmt.Printf("error reading user-data : %v\n", err)
os.Exit(1)
Expand Down
40 changes: 27 additions & 13 deletions cmd/blockStorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var (
#Full example with block-type
vultr-cli block-storage create --region 'lax' --size 10 --block-type 'high_perf'
#Shortened with aliased commands
vultr-cli bs c -r 'lax' -s 10
Expand All @@ -54,7 +54,7 @@ var (
deleteBlockStorageExample = `
#Full example
vultr-cli block-storage delete 67181686-5455-4ebb-81eb-7299f3506e2c
#Shortened with aliased commands
vultr-cli bs d 67181686-5455-4ebb-81eb-7299f3506e2c
`
Expand All @@ -63,7 +63,7 @@ var (
detachBlockStorageExample = `
#Full example
vultr-cli block-storage detach 67181686-5455-4ebb-81eb-7299f3506e2c
#Shortened with aliased commands
vultr-cli bs detach 67181686-5455-4ebb-81eb-7299f3506e2c
`
Expand All @@ -72,7 +72,7 @@ var (
labelBlockStorageExample = `
#Full example
vultr-cli block-storage label 67181686-5455-4ebb-81eb-7299f3506e2c --label "Example Label"
#Shortened with aliased commands
vultr-cli bs label 67181686-5455-4ebb-81eb-7299f3506e2c -l "Example Label"
`
Expand All @@ -81,7 +81,7 @@ var (
listBlockStorageExample = `
#Full example
vultr-cli block-storage list
#Shortened with aliased commands
vultr-cli bs l
`
Expand All @@ -90,7 +90,7 @@ var (
getBlockStorageExample = `
#Full example
vultr-cli block-storage get 67181686-5455-4ebb-81eb-7299f3506e2c
#Shortened with aliased commands
vultr-cli bs g 67181686-5455-4ebb-81eb-7299f3506e2c
`
Expand All @@ -99,7 +99,7 @@ var (
resizeBlockStorageExample = `
#Full example
vultr-cli block-storage resize 67181686-5455-4ebb-81eb-7299f3506e2c --size 20
#Shortened with aliased commands
vultr-cli bs r 67181686-5455-4ebb-81eb-7299f3506e2c -s 20
`
Expand All @@ -124,29 +124,43 @@ func BlockStorageCmd() *cobra.Command {
// Attach
bsAttach.Flags().StringP("instance", "i", "", "instance id you want to attach to")
bsAttach.Flags().Bool("live", false, "attach Block Storage without restarting the Instance.")
bsAttach.MarkFlagRequired("instance")

if err := bsAttach.MarkFlagRequired("instance"); err != nil {
fmt.Printf("error marking block storage attach 'live' flag required: %v\n", err)
os.Exit(1)
}
// Detach
bsDetach.Flags().Bool("live", false, "detach block storage from instance without a restart")

// Create
bsCreate.Flags().StringP("region", "r", "", "regionID you want to create the block storage in")
bsCreate.MarkFlagRequired("region")
if err := bsCreate.MarkFlagRequired("region"); err != nil {
fmt.Printf("error marking block storage create 'region' flag required: %v\n", err)
os.Exit(1)
}

bsCreate.Flags().IntP("size", "s", 0, "size of the block storage you want to create")
bsCreate.MarkFlagRequired("size")
if err := bsCreate.MarkFlagRequired("size"); err != nil {
fmt.Printf("error marking block storage create 'size' flag required: %v\n", err)
os.Exit(1)
}

bsCreate.Flags().StringP("label", "l", "", "label you want to give the block storage")

bsCreate.Flags().StringP("block-type", "b", "", "(optional) Block type you want to give the block storage. Possible values: 'high_perf', 'storage_opt'. Currently defaults to 'high_perf'.")

// Label
bsLabelSet.Flags().StringP("label", "l", "", "label you want your block storage to have")
bsLabelSet.MarkFlagRequired("label")
if err := bsLabelSet.MarkFlagRequired("label"); err != nil {
fmt.Printf("error marking block storage label set 'label' flag required: %v\n", err)
os.Exit(1)
}

// Resize
bsResize.Flags().IntP("size", "s", 0, "size you want your block storage to be")
bsResize.MarkFlagRequired("size")
if err := bsResize.MarkFlagRequired("size"); err != nil {
fmt.Printf("error marking block storage resize 'size' flag required: %v\n", err)
os.Exit(1)
}

return bsCmd
}
Expand Down
15 changes: 12 additions & 3 deletions cmd/dnsDomain.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,25 @@ func DNSDomain() *cobra.Command {

// Create
domainCreate.Flags().StringP("domain", "d", "", "name of the domain")
domainCreate.MarkFlagRequired("domain")
if err := domainCreate.MarkFlagRequired("domain"); err != nil {
fmt.Printf("error marking domain create 'domain' flag required: %v\n", err)
os.Exit(1)
}
domainCreate.Flags().StringP("ip", "i", "", "instance ip you want to assign this domain to")

// Dns Sec
secEnable.Flags().StringP("enabled", "e", "", "set whether dns sec is enabled or not. true or false")
secEnable.MarkFlagRequired("enabled")
if err := secEnable.MarkFlagRequired("enabled"); err != nil {
fmt.Printf("error marking domain security 'enabled' flag required: %v\n", err)
os.Exit(1)
}

// Soa Update
soaUpdate.Flags().StringP("ns-primary", "n", "", "primary nameserver to store in the SOA record")
soaUpdate.MarkFlagRequired("ns-primary")
if err := soaUpdate.MarkFlagRequired("ns-primary"); err != nil {
fmt.Printf("error marking domain soa update 'ns-primary' flag required: %v\n", err)
os.Exit(1)
}
soaUpdate.Flags().StringP("email", "e", "", "administrative email to store in the SOA record")

// List
Expand Down
21 changes: 17 additions & 4 deletions cmd/dnsRecord.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,22 @@ func DNSRecord() *cobra.Command {
recordCreate.Flags().StringP("type", "t", "", "record type you want to create : Possible values A, AAAA, CNAME, NS, MX, SRV, TXT CAA, SSHFP")
recordCreate.Flags().StringP("name", "n", "", "name of record")
recordCreate.Flags().StringP("data", "d", "", "data for the record")
recordCreate.MarkFlagRequired("domain")
recordCreate.MarkFlagRequired("type")
recordCreate.MarkFlagRequired("name")
recordCreate.MarkFlagRequired("data")
if err := recordCreate.MarkFlagRequired("domain"); err != nil {
fmt.Printf("error marking dns record create 'domain' flag required: %v\n", err)
os.Exit(1)
}
if err := recordCreate.MarkFlagRequired("type"); err != nil {
fmt.Printf("error marking dns record create 'type' flag required: %v\n", err)
os.Exit(1)
}
if err := recordCreate.MarkFlagRequired("name"); err != nil {
fmt.Printf("error marking dns record create 'name' flag required: %v\n", err)
os.Exit(1)
}
if err := recordCreate.MarkFlagRequired("data"); err != nil {
fmt.Printf("error marking dns record create 'data' flag required: %v\n", err)
os.Exit(1)
}
// Create Optional
recordCreate.Flags().IntP("ttl", "", 0, "time to live for the record")
recordCreate.Flags().IntP("priority", "p", 0, "only required for MX and SRV")
Expand All @@ -64,6 +76,7 @@ func DNSRecord() *cobra.Command {

// Temporary solution to determine if the record type is TXT, in order to
// add quotes around the value. The API does not accept TXT records without
//
// quotes.
var regRecordTxt = regexp.MustCompile("([A-Z]|=|_)")

Expand Down
26 changes: 19 additions & 7 deletions cmd/firewallRule.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ var (
firewallRuleLong = `Show commands available for firewall rules`
firewallRuleExample = `
# Full example
vultr-cli firewall rule
vultr-cli firewall rule
# Shortened example with aliases
vultr-cli fw r
`
Expand Down Expand Up @@ -73,7 +73,7 @@ var (
vultr-cli firewall rule list 704ac064-4ff2-49ca-a6e6-88262cca8f8a
# Shortened example with aliases
vultr-cli fw r l 704ac064-4ff2-49ca-a6e6-88262cca8f8a
vultr-cli fw r l 704ac064-4ff2-49ca-a6e6-88262cca8f8a
`
)

Expand All @@ -100,10 +100,22 @@ func FirewallRule() *cobra.Command {
firewallRuleCreate.Flags().StringP("port", "r", "", "(optional) TCP/UDP only. This field can be an integer value specifying a port or a colon separated port range.")
firewallRuleCreate.Flags().StringP("notes", "n", "", "(optional) This field supports notes up to 255 characters.")

firewallRuleCreate.MarkFlagRequired("id")
firewallRuleCreate.MarkFlagRequired("protocol")
firewallRuleCreate.MarkFlagRequired("subnet")
firewallRuleCreate.MarkFlagRequired("size")
if err := firewallRuleCreate.MarkFlagRequired("id"); err != nil {
fmt.Printf("error marking firewall rule create 'id' flag required: %v\n", err)
os.Exit(1)
}
if err := firewallRuleCreate.MarkFlagRequired("protocol"); err != nil {
fmt.Printf("error marking firewall rule create 'protocol' flag required: %v\n", err)
os.Exit(1)
}
if err := firewallRuleCreate.MarkFlagRequired("subnet"); err != nil {
fmt.Printf("error marking firewall rule create 'subnet' flag required: %v\n", err)
os.Exit(1)
}
if err := firewallRuleCreate.MarkFlagRequired("size"); err != nil {
fmt.Printf("error marking firewall rule create 'size' flag required: %v\n", err)
os.Exit(1)
}

firewallRuleList.Flags().StringP("cursor", "c", "", "(optional) Cursor for paging.")
firewallRuleList.Flags().IntP("per-page", "p", 100, "(optional) Number of items requested per page. Default is 100 and Max is 500.")
Expand Down
Loading

0 comments on commit 5a53115

Please sign in to comment.