|
| 1 | +Setting up golang env |
| 2 | + |
| 3 | +0: Make sure you have your SSH keys setup on github.ibm.com https://github.ibm.com/settings/keys |
| 4 | + |
| 5 | +1: Know your GOPATH: https://go.dev/doc/gopath_code#GOPATH |
| 6 | + |
| 7 | +``` |
| 8 | +$> echo $GOPATH |
| 9 | +C:\Users\allmi\go |
| 10 | +$> cd ~/go/ |
| 11 | +``` |
| 12 | + |
| 13 | +2: Get the softlayer-cli code https://github.ibm.com/softlayer/softlayer-cli |
| 14 | +Read the README as well. |
| 15 | + |
| 16 | +``` |
| 17 | +$> mkdir -p src/github.ibm.com/softlayer |
| 18 | +$> cd src/github.ibm.com/softlayer |
| 19 | +$> pwd |
| 20 | +/c/Users/allmi/go/src/github.ibm.com/softlayer |
| 21 | +$> git clone https://github.ibm.com/softlayer/softlayer-cli |
| 22 | +``` |
| 23 | + |
| 24 | +At this point you have the code, but need to setup the required libraries |
| 25 | + |
| 26 | +3: run go mod vendor https://go.dev/ref/mod#go-mod-vendor This command will download everything listed in `go.mod`, which are the libraries this codebase uses. |
| 27 | + |
| 28 | +``` |
| 29 | +$> go mod vendor |
| 30 | +go: downloading github.com/IBM-Cloud/ibm-cloud-cli-sdk v1.0.1 |
| 31 | +go: downloading github.com/softlayer/softlayer-go v1.1.2 |
| 32 | +go: downloading github.com/miekg/dns v1.1.50 |
| 33 | +go: downloading github.com/onsi/ginkgo v1.16.2 |
| 34 | +go: downloading github.com/onsi/gomega v1.11.0 |
| 35 | +go: downloading github.com/spf13/cobra v1.5.0 |
| 36 | +go: downloading github.com/spf13/pflag v1.0.5 |
| 37 | +go: downloading github.com/Xuanwo/go-locale v1.1.0 |
| 38 | +go: downloading github.com/nicksnyder/go-i18n v1.10.1 |
| 39 | +go: downloading golang.org/x/text v0.7.0 |
| 40 | +go: downloading github.com/stretchr/testify v1.7.0 |
| 41 | +go: downloading golang.org/x/net v0.7.0 |
| 42 | +go: downloading golang.org/x/sys v0.5.0 |
| 43 | +go: downloading golang.org/x/tools v0.1.12 |
| 44 | +go: downloading github.com/fatih/color v1.10.0 |
| 45 | +go: downloading github.com/mattn/go-colorable v0.1.8 |
| 46 | +go: downloading github.com/mattn/go-runewidth v0.0.12 |
| 47 | +go: downloading golang.org/x/crypto v0.6.0 |
| 48 | +go: downloading github.com/fatih/structs v1.1.0 |
| 49 | +go: downloading github.com/softlayer/xmlrpc v0.0.0-20200409220501-5f089df7cb7e |
| 50 | +go: downloading github.com/inconshreveable/mousetrap v1.0.0 |
| 51 | +go: downloading github.com/davecgh/go-spew v1.1.1 |
| 52 | +go: downloading github.com/pmezard/go-difflib v1.0.0 |
| 53 | +go: downloading gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c |
| 54 | +go: downloading gopkg.in/yaml.v2 v2.4.0 |
| 55 | +go: downloading github.com/nicksnyder/go-i18n/v2 v2.2.0 |
| 56 | +go: downloading github.com/mattn/go-isatty v0.0.12 |
| 57 | +go: downloading github.com/rivo/uniseg v0.1.0 |
| 58 | +go: downloading github.com/nxadm/tail v1.4.8 |
| 59 | +go: downloading github.com/pelletier/go-toml v1.2.0 |
| 60 | +go: downloading golang.org/x/term v0.5.0 |
| 61 | +go: downloading gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 |
| 62 | +go: downloading github.com/fsnotify/fsnotify v1.4.9 |
| 63 | +go: downloading golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 |
| 64 | +``` |
| 65 | + |
| 66 | +4: You can now build the softlayer-cli: https://go.dev/ref/mod#build-commands |
| 67 | + |
| 68 | +``` |
| 69 | +$> go build |
| 70 | +$> ./softlayer-cli.exe --help |
| 71 | +Manage Classic infrastructure services |
| 72 | +
|
| 73 | +Usage: |
| 74 | + sl [command] |
| 75 | +``` |
| 76 | + |
| 77 | +At this point you can test the softlayer-cli plugin independent of the `ibmcloud` command. If you want to test it all together, you need to ALSO build the `ibmcloud` binary. |
| 78 | + |
| 79 | +5: Get the ibmcloud code https://github.ibm.com/ibmcloud-cli/bluemix-cli |
| 80 | + |
| 81 | +``` |
| 82 | +$> mkdir -p $GOPATH/src/github.ibm.com/ibmcloud-cli |
| 83 | +$> cd $GOPATH/src/github.ibm.com/ibmcloud-cli |
| 84 | +$> git@github.ibm.com:ibmcloud-cli/bluemix-cli.git |
| 85 | +``` |
| 86 | + |
| 87 | +6: Edit the ibmcloud-cli/go.mod file to force it to use the copy of softlayer-cli on your computer |
| 88 | +Add `github.ibm.com/SoftLayer/softlayer-cli => ../../SoftLayer/softlayer-cli` to the `replace` section in `github.ibm.com/ibmcloud-cli/bluemix-cli/go.mod` |
| 89 | + |
| 90 | +``` |
| 91 | +module github.ibm.com/ibmcloud-cli/bluemix-cli |
| 92 | +
|
| 93 | +go 1.20 |
| 94 | +
|
| 95 | +replace ( |
| 96 | + github.com/dgrijalva/jwt-go => github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1 |
| 97 | + github.com/docker/docker => github.com/docker/engine v17.12.0-ce-rc1.0.20191121165722-d1d5f6476656+incompatible |
| 98 | + github.com/ulikunitz/xz => github.com/ulikunitz/xz v0.5.8 |
| 99 | + github.ibm.com/SoftLayer/softlayer-cli => ../../SoftLayer/softlayer-cli |
| 100 | +) |
| 101 | +``` |
| 102 | + |
| 103 | +7: vendor and build |
| 104 | + |
| 105 | +You'll need to change some git settings first to access private repositories. See https://github.ibm.com/softlayer/softlayer-cli#vendor |
| 106 | + |
| 107 | +``` |
| 108 | +# I usually add these to ~/.bashrc so they are always set |
| 109 | +$> export GOPROXY=direct |
| 110 | +$> export GOPRIVATE=github.ibm.com/* |
| 111 | +# Make sure you gitconfig has these lines |
| 112 | +$> git config --global url."ssh://git@github.ibm.com/".insteadof https://github.ibm.com/ |
| 113 | +$> go mod vendor |
| 114 | +``` |
| 115 | + |
| 116 | +Need to run `go mod tidy` when you make changes to go.mod |
| 117 | +``` |
| 118 | +$> go mod tidy |
| 119 | +go: downloading gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c |
| 120 | +go: downloading github.com/onsi/ginkgo/v2 v2.1.6 |
| 121 | +go: downloading github.com/jarcoal/httpmock v1.0.5 |
| 122 | +go: downloading github.com/smartystreets/goconvey v1.6.7 |
| 123 | +go: downloading github.com/BurntSushi/toml v1.1.0 |
| 124 | +go: downloading golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 |
| 125 | +go: downloading github.com/elazarl/goproxy v0.0.0-20210110162100-a92cc753f88e |
| 126 | +go: downloading sigs.k8s.io/yaml v1.2.0 |
| 127 | +go: downloading github.com/jtolds/gls v4.20.0+incompatible |
| 128 | +go: downloading github.com/smartystreets/assertions v1.0.0 |
| 129 | +go: downloading github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 |
| 130 | +go: downloading github.com/kr/pretty v0.3.0 |
| 131 | +go: downloading github.com/kr/text v0.2.0 |
| 132 | +go: downloading github.com/rogpeppe/go-internal v1.6.1 |
| 133 | +$> go mod vendor |
| 134 | +go: downloading github.ibm.com/arf/cli-dev-plugin v1.3.4-0.20230220210426-acb097801062 |
| 135 | +go: downloading github.ibm.com/SoftLayer/softlayer-cli v1.4.1 |
| 136 | +go: downloading github.ibm.com/Bluemix/resource-catalog-cli v0.0.0-20220906182229-845aab607438 |
| 137 | +go: downloading github.com/pelletier/go-toml v1.9.5 |
| 138 | +go: downloading github.com/parnurzeal/gorequest v0.2.16 |
| 139 | +go: downloading github.com/briandowns/spinner v0.0.0-20190311160019-998b3556fb3f |
| 140 | +go: downloading k8s.io/api v0.25.3 |
| 141 | +go: downloading moul.io/http2curl v1.0.0 |
| 142 | +go: downloading github.com/miekg/dns v1.1.25 |
| 143 | +go: downloading k8s.io/apimachinery v0.25.3 |
| 144 | +go: downloading github.com/gogo/protobuf v1.3.2 |
| 145 | +go: downloading k8s.io/klog/v2 v2.80.0 |
| 146 | +go: downloading k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73 |
| 147 | +go: downloading github.com/google/gofuzz v1.2.0 |
| 148 | +go: downloading gopkg.in/inf.v0 v0.9.1 |
| 149 | +go: downloading sigs.k8s.io/structured-merge-diff/v4 v4.2.3 |
| 150 | +go: downloading sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 |
| 151 | +go: downloading github.com/go-logr/logr v1.2.3 |
| 152 | +go: downloading github.com/json-iterator/go v1.1.12 |
| 153 | +go: downloading github.com/modern-go/reflect2 v1.0.2 |
| 154 | +go: downloading github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd |
| 155 | +
|
| 156 | +$> go build |
| 157 | +$> ./bluemix-cli |
| 158 | +``` |
| 159 | + |
| 160 | +8: Login to use it. I like to use an API key. Use https://cloud.ibm.com/iam/apikeys to create a "My IBM Cloud API Keys". It will be 32 characters long, and different from a classic infrastructure api key. |
| 161 | + |
| 162 | + |
| 163 | +``` |
| 164 | +$> ibmcloud.exe login --apikey <keyhere> |
| 165 | +$> ibmcloud sl vs list (or some other command) |
| 166 | +``` |
| 167 | + |
| 168 | + |
| 169 | + |
| 170 | +### Uploading binaries for testing |
| 171 | + |
| 172 | +Sometimes I'll upload binaries build with local softlayer-cli changes, mostly for the translation team to test with. That process is as follows: |
| 173 | + |
| 174 | + |
| 175 | +URL: https://s3.us-east.cloud-object-storage.appdomain.cloud/softlayer-cli-binaries/index.html |
| 176 | +CLI Docs: https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-cli-plugin-ic-cos-cli |
| 177 | + |
| 178 | +COS Plugin install and setup |
| 179 | +``` |
| 180 | +$> ibmcloud plugin install cloud-object-storage |
| 181 | +$> ibmcloud cos config region us-east |
| 182 | +$> ibmcloud cos config crn --crn 0859c995-bf8b-46fe-9d8b-0f3405e25359 |
| 183 | +# be in the bluemix-cli directory, make sure you have the replace directive in go.mod and its ready to be build |
| 184 | +$> cd $GOPATH/src/github.ibm.com/ibmcloud-cli/bluemix-cli |
| 185 | +$> ./bin/build-all |
| 186 | +$> for i in `\ls out/`; do echo UPLOADING $i; ibmcloud.exe cos object-put --bucket=softlayer-cli-binaries --key=$i --body=./out/$i; done |
| 187 | +``` |
| 188 | +Hopefully that will work. |
0 commit comments