Skip to content

Commit f2e5b5d

Browse files
Merge branch 'master' of github.ibm.com:SoftLayer/softlayer-cli into docs
2 parents 25ef347 + 752e510 commit f2e5b5d

73 files changed

Lines changed: 2873 additions & 655 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
group: bluezone
22
language: go
33
go:
4-
- 1.19.3
4+
- 1.21.3
55
addons:
66
apt:
77
packages:

bin/buildAndDeploy.py

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
import json
55
from pathlib import Path
66
import os
7+
import sys
78
import re
89
import subprocess
910
import requests
1011
import platform
1112
import hashlib
1213
import glob
13-
import sys
1414
from rich import print
1515
from rich.markup import escape
1616

@@ -40,19 +40,11 @@ def buildArchs() -> dict:
4040
"""Returns the list of binaries we should build"""
4141
buildArchs = {
4242
'darwin': ['arm64', 'amd64'],
43-
'linux': ['amd64', '386', 'arm64'],
43+
'linux': ['amd64', '386', 'arm64', 'ppc64le', 's390x'],
4444
'windows': ['386', 'amd64'],
4545
}
4646
return buildArchs
4747

48-
def cgoEnable(theOs: str, theArch: str) -> int:
49-
"""Disable cgo for these archs"""
50-
cgo_disable = ["amd64", "386", "arm64"]
51-
if theOs == "linux" and theArch in cgo_disable:
52-
return 0
53-
return 1
54-
55-
5648

5749
def runTests() -> None:
5850
"""Runs unit tests"""
@@ -72,14 +64,19 @@ def runTests() -> None:
7264

7365
go_vet = ['go', 'vet'] + clean_mods
7466
# Not using the 'real' command here because this looks neater.
67+
7568
print(f'[turquoise2]Running: go vet $(go list ./... | grep -v "fixtures" | grep -v "vendor")')
76-
subprocess.run(go_vet, check=True)
69+
try:
70+
subprocess.run(go_vet, check=True)
71+
except subprocess.CalledProcessError as e:
72+
print(f"[red]>>> Go Vet failed <<<")
73+
sys.exit(e.returncode)
7774
go_test = ['go', 'test'] + clean_mods
7875
print(f'[turquoise2]Running: go test $(go list ./... | grep -v "fixtures" | grep -v "vendor")')
7976
try:
8077
subprocess.run(go_test, check=True)
8178
except subprocess.CalledProcessError as e:
82-
print(f"[red]Unit tests failed")
79+
print(f"[red]>>> Go Test failed <<<")
8380
sys.exit(e.returncode)
8481
go_sec = ['gosec', '-exclude-dir=fixture', '-exclude-dir=plugin/resources', '-quiet', './...']
8582
# Not using the 'real' command because this is more copy/pasteable.
@@ -89,9 +86,6 @@ def runTests() -> None:
8986
except FileNotFoundError:
9087
gosec_instal = "curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $GOPATH/bin"
9188
print(f"[red]gosec not found. Try running:\n{gosec_instal}")
92-
93-
94-
9589

9690
### Section for i18n4go stuff ###
9791
def runI18n4go(path: str) -> None:
@@ -177,7 +171,6 @@ def add_i18n(file_name: str, updates: dict) -> None:
177171

178172
write_source_data(file_name, source_i18n)
179173

180-
181174
def del_i18n(file_name: str, updates: dict) -> None:
182175
"""Removes unneeded translations
183176
@@ -195,7 +188,6 @@ def del_i18n(file_name: str, updates: dict) -> None:
195188

196189
write_source_data(file_name, source_i18n)
197190

198-
199191
def get_source_data(file_name: str) -> dict:
200192
"""Reads from the i18n files and returns a formatted dict"""
201193
source_i18n = {}
@@ -272,11 +264,11 @@ def deploy(self):
272264
"""Uploads binaries to IBM COS"""
273265
apikey = os.getenv("IBMCLOUD_APIKEY")
274266
# if IBMCLOUD_TRACE is true the upload will print out the binary file data to the screen.
275-
os.environ["IBMCLOUD_TRACE"] = "False"
267+
os.environ["IBMCLOUD_TRACE"] = "false"
276268
if not apikey:
277269
raise Exception("IBMCLOUD_APIKEY needs to be set to the proper API key first.")
278-
login_cmd = ["ibmcloud", "login", f"--apikey={apikey}", "-r=us-east"]
279-
print(f"[yellow]Running: ibmcloud login --apikey $IBMCLOUD_APIKEY -r us-east")
270+
login_cmd = ["ibmcloud", "login", f"--apikey={apikey}"]
271+
print(f"[yellow]Running: ibmcloud login --apikey $IBMCLOUD_APIKEY")
280272
subprocess.run(login_cmd)
281273
files = glob.glob(os.path.join(self.cwd, 'out', f"sl-{self.version}-*"))
282274
for f in files:
@@ -291,6 +283,8 @@ def getChecksums(self) -> dict:
291283
'Linux_X86': {'file': f"sl-{self.version}-linux-386", 'checksum': ''},
292284
'Linux_X64': {'file': f"sl-{self.version}-linux-amd64", 'checksum': ''},
293285
'Linux_arm64' : {'file': f"sl-{self.version}-linux-arm64", 'checksum': ''},
286+
'Linux_Ppc64le': {'file': f"sl-{self.version}-linux-ppc64le", 'checksum': ''},
287+
'Linux_s390x': {'file': f"sl-{self.version}-linux-s390x", 'checksum': ''},
294288
'MacOS': {'file': f"sl-{self.version}-darwin-amd64", 'checksum': ''},
295289
'MacOS_arm64': {'file': f"sl-{self.version}-darwin-arm64", 'checksum': ''},
296290
'Win_X86': {'file': f"sl-{self.version}-windows-386.exe", 'checksum': ''},
@@ -320,7 +314,14 @@ def runJenkins(self):
320314
'{"name":"Url_Linux_X86", "value":"https://s3.us-east.cloud-object-storage.appdomain.cloud/softlayer-cli-binaries/sl-1.4.2-linux-386"}]}' -v
321315
"""
322316
checksums = self.getChecksums()
317+
# Set this to true if you want to use the Refresh-Plugin-Version-on-YS1 job
318+
refresh = False
319+
# This create a new version
323320
jenkinsUrl = 'https://wcp-cloud-foundry-jenkins.swg-devops.com/job/Publish%20Plugin%20to%20YS1'
321+
322+
if refresh:
323+
# This updates an existing version
324+
jenkinsUrl = 'https://wcp-cloud-foundry-jenkins.swg-devops.com/job/Refresh-Plugin-Version-on-YS1'
324325
jenkins_token = os.getenv('JENKINS_TOKEN')
325326
if not jenkins_token:
326327
raise Exception("JENKINS_TOKEN is not set to an API key")
@@ -337,7 +338,11 @@ def runJenkins(self):
337338

338339
for x in checksums.keys():
339340
urlData = {'name': f"Url_{x}", "value": self.cnd_url + checksums[x]['file']}
340-
checkData = {'name': f"Checksum_{x}", "value": checksums[x]['checksum']}
341+
# This one doesn't follow the normal pattern so it needs a special case.
342+
if x == "Linux_s390x" and not refresh:
343+
checkData = {'name': f"Checksum_Linux_S390x", "value": checksums[x]['checksum']}
344+
else:
345+
checkData = {'name': f"Checksum_{x}", "value": checksums[x]['checksum']}
341346
form_json['parameter'].append(urlData)
342347
form_json['parameter'].append(checkData)
343348

@@ -348,7 +353,10 @@ def runJenkins(self):
348353
print(f"[green] Created Job! Check {jenkinsUrl}" )
349354
else:
350355
print(f"[red]Error: {result.status_code} {result.reason}")
351-
raise Excetion("Error in runJenkins()")
356+
print(f"[yellow] {result.text}")
357+
print(f"[yellow] {result.url}")
358+
print(f"[yellow] {result.request}")
359+
raise Exception("Error in runJenkins()")
352360

353361

354362

@@ -359,16 +367,17 @@ def goBuild(self, theOs: str, theArch: str) -> None:
359367
:param str theOs: OS to build for
360368
:param str theArch: Architecture to build for
361369
"""
370+
cgo_enabled = 0
362371
os.environ["GOOS"] = theOs
363372
os.environ["GOARCH"] = theArch
364-
os.environ["CGO_ENABLED"] = str(cgoEnable(theOs, theArch))
373+
os.environ["CGO_ENABLED"] = str(cgo_enabled)
365374

366375
print(f"[green]Building {theOs}-{theArch}")
367376
binaryName = os.path.join(self.cwd, 'out', f"sl-{self.version}-{theOs}-{theArch}")
368377
if theOs == "windows":
369378
binaryName = f"{binaryName}.exe"
370-
buildCmd = f"go build -ldflags \"-s -w\" -o {binaryName} ."
371-
print(f"[turquoise2]Running {buildCmd}")
379+
buildCmd = f" go build -ldflags \"-s -w\" -o {binaryName} ."
380+
print(f"[turquoise2]Running GOOS={theOs} GOARCH={theArch} CGO_ENABLED={cgo_enabled} {buildCmd}")
372381
# This command basically requires shell=True on mac because -ldflags doesn't get parsed properly withoutit.
373382
subprocess.run(buildCmd, shell=True)
374383

@@ -437,4 +446,3 @@ def i18n(ctx):
437446
# except Exception as e:
438447
# print(f"[red]{e}")
439448

440-

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/miekg/dns v1.1.50
1111
github.com/nicksnyder/go-i18n v1.10.1
1212
github.com/onsi/ginkgo v1.16.2
13-
github.com/onsi/gomega v1.27.10
13+
github.com/onsi/gomega v1.29.0
1414
github.com/softlayer/softlayer-go v1.1.2
1515
github.com/spf13/cobra v1.5.0
1616
github.com/spf13/pflag v1.0.5
@@ -25,7 +25,8 @@ require (
2525
github.com/fatih/structs v1.1.0 // indirect
2626
github.com/fsnotify/fsnotify v1.4.9 // indirect
2727
github.com/gofrs/flock v0.8.1 // indirect
28-
github.com/google/go-cmp v0.5.9 // indirect
28+
github.com/golang/protobuf v1.5.3 // indirect
29+
github.com/google/go-cmp v0.6.0 // indirect
2930
github.com/inconshreveable/mousetrap v1.0.0 // indirect
3031
github.com/mattn/go-colorable v0.1.8 // indirect
3132
github.com/mattn/go-isatty v0.0.12 // indirect
@@ -43,6 +44,7 @@ require (
4344
golang.org/x/sys v0.13.0 // indirect
4445
golang.org/x/term v0.13.0 // indirect
4546
golang.org/x/tools v0.12.0 // indirect
47+
google.golang.org/protobuf v1.28.0 // indirect
4648
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
4749
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
4850
gopkg.in/yaml.v2 v2.4.0 // indirect

go.sum

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU
3131
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
3232
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
3333
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
34+
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
3435
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
3536
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
3637
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
3738
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
3839
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
40+
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
3941
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
4042
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
43+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
44+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
4145
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE=
4246
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
4347
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
@@ -75,10 +79,13 @@ github.com/onsi/ginkgo v1.16.2 h1:HFB2fbVIlhIfCfOW81bZFbiC/RvnpXSdhbF2/DJr134=
7579
github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E=
7680
github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU=
7781
github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM=
82+
github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4=
7883
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
7984
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
8085
github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
8186
github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M=
87+
github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg=
88+
github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
8289
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
8390
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
8491
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -170,6 +177,8 @@ google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQ
170177
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
171178
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
172179
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
180+
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
181+
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
173182
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
174183
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
175184
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

plugin/commands/account/cancel-item.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func NewCancelItemCommand(sl *metadata.SoftlayerCommand) *CancelItemCommand {
2424
AccountManager: managers.NewAccountManager(sl.Session),
2525
}
2626
cobraCmd := &cobra.Command{
27-
Use: "cancel-item",
27+
Use: "cancel-item " + T("IDENTIFIER"),
2828
Short: T("Cancels a billing item."),
2929
Long: T(`Cancel the resource or service for a billing Item. By default the billing item will be canceled
3030
on the next bill date and reclaim of the resource will begin shortly after the cancellation`),

plugin/commands/bandwidth/pools_edit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func NewEditCommand(sl *metadata.SoftlayerCommand) (cmd *EditCommand) {
4141

4242
cobraCmd := &cobra.Command{
4343
Use: "pools-edit " + T("IDENTIFIER"),
44-
Short: T("edit bandwidth pool. "),
44+
Short: T("Edit bandwidth pool."),
4545
Args: metadata.OneArgs,
4646
RunE: func(cmd *cobra.Command, args []string) error {
4747
return thisCmd.Run(args)

plugin/commands/block/volume_detail.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ func (cmd *VolumeDetailCommand) Run(args []string) error {
135135
return slErr.NewAPIError(T("Failed to decoded the note.\n"), err.Error(), 2)
136136
}
137137
table.Add(T("Notes"), decodedValue)
138+
hasEncryption := T("False")
139+
if (blockVolume.HasEncryptionAtRest != nil && *blockVolume.HasEncryptionAtRest == true) {
140+
hasEncryption = T("True")
141+
}
142+
table.Add(T("Encrypted"), hasEncryption)
138143
table.Print()
139144
return nil
140145
}

0 commit comments

Comments
 (0)