Commit 4bf611a
committed
refac(io) set IO once in main to allow overriding with in memory io in tests
`print.Printer` had a reference to a `cobra.Command` for using its IO
streams. Each Command also used a Printer, resulting in an awkward
circular dependency.
Refactored Printer to use IO streams directly. When using the application
these are set in `main`, when used in tests these can be set to
`bytes.Buffer`s.
Also replaced usages of `os.Args` with just a string slice. Also set
in `main`.
`cobra.Command`s `Args` and IO-streams are set in `NewRootCmd` with
`traverseCommands`.
`CmdParams` also has an `fs.FS`, currently unused but will allow using
the real FS during regular use and an in-memory-FS during tests.
This change prepares the application for integrative testing while keeping
good isolation. Generally speaking the goal is to move all things with
side effects into main (compare with https://grafana.com/blog/how-i-write-http-services-in-go-after-13-years/#func-main-only-calls-run)1 parent 83cf194 commit 4bf611a
File tree
380 files changed
+1659
-2413
lines changed- internal
- cmd
- affinity-groups
- create
- delete
- describe
- list
- beta
- alb
- create
- describe
- list
- observability-credentials
- add
- delete
- describe
- list
- update
- plans
- pool/update
- quotas
- template
- update
- cdn/distribution
- create
- describe
- list
- update
- edge
- instance
- create
- describe
- list
- kubeconfig/create
- plans/list
- token/create
- intake
- create
- describe
- list
- runner
- create
- describe
- list
- update
- update
- user
- create
- describe
- list
- update
- sfs
- export-policy
- create
- describe
- list
- update
- performance-class/list
- resource-pool
- create
- delete
- describe
- list
- update
- snapshot
- create
- describe
- list
- sqlserverflex
- database
- create
- describe
- list
- instance
- create
- describe
- list
- update
- options
- user
- create
- describe
- list
- reset-password
- config
- list
- profile/list
- unset
- curl
- dns
- record-set
- create
- describe
- list
- update
- zone
- clone
- create
- describe
- list
- update
- git
- flavor/list
- instance
- create
- delete
- describe
- list
- image
- create
- delete
- describe
- list
- update
- key-pair
- create
- delete
- describe
- list
- update
- kms
- keyring
- create
- delete
- describe
- list
- key
- create
- delete
- describe
- importKey
- list
- restore
- rotate
- version
- destroy
- disable
- enable
- list
- restore
- wrappingkey
- create
- delete
- describe
- list
- load-balancer
- describe
- generate-payload
- list
- observability-credentials
- add
- describe
- list
- quota
- target-pool
- add-target
- describe
- remove-target
- logme
- credentials
- create
- describe
- list
- instance
- create
- describe
- list
- update
- plans
- logs
- access_token
- create
- describe
- list
- update
- instance
- create
- describe
- list
- update
- mariadb
- credentials
- create
- describe
- list
- instance
- create
- describe
- list
- update
- plans
- mongodbflex
- backup
- describe
- list
- restore-jobs
- schedule
- instance
- create
- describe
- list
- update
- options
- user
- create
- describe
- list
- reset-password
- network-area
- create
- describe
- list
- network-range
- create
- delete
- describe
- list
- region
- create
- describe
- list
- update
- route
- create
- delete
- describe
- list
- update
- routingtable
- create
- describe
- list
- route
- create
- describe
- list
- update
- update
- update
- network-interface
- create
- delete
- describe
- list
- update
- network
- create
- describe
- list
- update
- object-storage
- bucket
- create
- describe
- list
- compliance-lock
- describe
- lock
- credentials-group
- create
- list
- credentials
- create
- list
- observability
- credentials
- create
- list
- grafana/describe
- instance
- create
- describe
- list
- plans
- scrape-config
- describe
- generate-payload
- list
- opensearch
- credentials
- create
- describe
- list
- instance
- create
- describe
- list
- update
- plans
- organization
- describe
- list
- member/list
- role/list
- postgresflex
- backup
- describe
- list
- instance
- clone
- create
- describe
- list
- update
- options
- user
- create
- describe
- list
- reset-password
- project
- create
- describe
- list
- member/list
- role/list
- public-ip
- associate
- create
- describe
- disassociate
- list
- ranges/list
- update
- quota/list
- rabbitmq
- credentials
- create
- describe
- list
- instance
- create
- describe
- list
- update
- plans
- redis
- credentials
- create
- describe
- list
- instance
- create
- describe
- list
- update
- plans
- secrets-manager
- instance
- create
- describe
- list
- user
- create
- describe
- list
- update
- security-group
- create
- delete
- describe
- list
- rule
- create
- delete
- describe
- list
- update
- server
- backup
- create
- describe
- list
- schedule
- create
- describe
- list
- update
- command
- create
- describe
- list
- template
- describe
- list
- console
- create
- describe
- list
- log
- machine-type
- describe
- list
- network-interface/list
- os-update
- create
- describe
- list
- schedule
- create
- describe
- list
- update
- public-ip
- attach
- detach
- service-account
- attach
- detach
- list
- update
- volume
- attach
- describe
- detach
- list
- update
- service-account
- create
- get-jwks
- key
- describe
- list
- list
- token
- create
- list
- ske
- cluster
- create
- describe
- generate-payload
- hibernate
- list
- maintenance
- reconcile
- update
- wakeup
- describe
- kubeconfig/create
- options
- availability_zones
- kubernetes_versions
- machine_images
- machine_types
- volume_types
- volume
- backup
- create
- describe
- list
- create
- describe
- list
- performance-class
- describe
- list
- resize
- snapshot
- describe
- list
- update
- pkg
- auth
- config
- flags
- print
- projectname
- services
- cdn/utils
- edge/common/validation
- testparams
- testutils
- types
- scripts
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
380 files changed
+1659
-2413
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | 7 | | |
10 | 8 | | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
| 12 | + | |
| 13 | + | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
181 | 180 | | |
182 | 181 | | |
183 | 182 | | |
184 | | - | |
185 | | - | |
| 183 | + | |
186 | 184 | | |
187 | 185 | | |
188 | | - | |
| 186 | + | |
189 | 187 | | |
190 | 188 | | |
191 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | 7 | | |
10 | 8 | | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
| 12 | + | |
| 13 | + | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
103 | 102 | | |
104 | 103 | | |
105 | 104 | | |
106 | | - | |
107 | | - | |
| 105 | + | |
| 106 | + | |
108 | 107 | | |
109 | 108 | | |
110 | 109 | | |
| |||
136 | 135 | | |
137 | 136 | | |
138 | 137 | | |
139 | | - | |
| 138 | + | |
140 | 139 | | |
141 | 140 | | |
142 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | 7 | | |
10 | 8 | | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
| 12 | + | |
| 13 | + | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
104 | 103 | | |
105 | 104 | | |
106 | 105 | | |
107 | | - | |
108 | | - | |
| 106 | + | |
| 107 | + | |
109 | 108 | | |
110 | 109 | | |
111 | 110 | | |
| |||
137 | 136 | | |
138 | 137 | | |
139 | 138 | | |
140 | | - | |
| 139 | + | |
141 | 140 | | |
142 | 141 | | |
143 | 142 | | |
| |||
197 | 196 | | |
198 | 197 | | |
199 | 198 | | |
200 | | - | |
201 | | - | |
| 199 | + | |
202 | 200 | | |
203 | 201 | | |
204 | 202 | | |
205 | | - | |
| 203 | + | |
206 | 204 | | |
207 | 205 | | |
208 | 206 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | 8 | | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
14 | 12 | | |
| 13 | + | |
| 14 | + | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
155 | 154 | | |
156 | 155 | | |
157 | 156 | | |
158 | | - | |
159 | | - | |
| 157 | + | |
160 | 158 | | |
161 | 159 | | |
162 | | - | |
| 160 | + | |
163 | 161 | | |
164 | 162 | | |
165 | 163 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | 10 | | |
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
16 | 14 | | |
| 15 | + | |
| 16 | + | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
213 | 212 | | |
214 | 213 | | |
215 | 214 | | |
216 | | - | |
217 | | - | |
| 215 | + | |
218 | 216 | | |
219 | 217 | | |
220 | | - | |
| 218 | + | |
221 | 219 | | |
222 | 220 | | |
223 | 221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | 7 | | |
10 | | - | |
| 8 | + | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
| |||
168 | 166 | | |
169 | 167 | | |
170 | 168 | | |
171 | | - | |
172 | | - | |
| 169 | + | |
173 | 170 | | |
174 | 171 | | |
175 | | - | |
| 172 | + | |
176 | 173 | | |
177 | 174 | | |
178 | 175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
| 8 | + | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
168 | 167 | | |
169 | 168 | | |
170 | 169 | | |
171 | | - | |
172 | | - | |
| 170 | + | |
| 171 | + | |
173 | 172 | | |
174 | 173 | | |
175 | | - | |
| 174 | + | |
176 | 175 | | |
177 | 176 | | |
178 | 177 | | |
| |||
Lines changed: 3 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | 7 | | |
10 | | - | |
| 8 | + | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
| |||
166 | 164 | | |
167 | 165 | | |
168 | 166 | | |
169 | | - | |
170 | | - | |
| 167 | + | |
171 | 168 | | |
172 | 169 | | |
173 | | - | |
| 170 | + | |
174 | 171 | | |
175 | 172 | | |
176 | 173 | | |
| |||
Lines changed: 6 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | 7 | | |
10 | 8 | | |
11 | | - | |
12 | | - | |
| 9 | + | |
13 | 10 | | |
14 | 11 | | |
15 | 12 | | |
16 | 13 | | |
| 14 | + | |
| 15 | + | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
114 | 113 | | |
115 | 114 | | |
116 | 115 | | |
117 | | - | |
118 | | - | |
| 116 | + | |
| 117 | + | |
119 | 118 | | |
120 | 119 | | |
121 | 120 | | |
| |||
147 | 146 | | |
148 | 147 | | |
149 | 148 | | |
150 | | - | |
| 149 | + | |
151 | 150 | | |
152 | 151 | | |
153 | 152 | | |
| |||
Lines changed: 4 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | 7 | | |
10 | | - | |
| 8 | + | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
| |||
168 | 166 | | |
169 | 167 | | |
170 | 168 | | |
171 | | - | |
172 | | - | |
| 169 | + | |
| 170 | + | |
173 | 171 | | |
174 | 172 | | |
175 | | - | |
| 173 | + | |
176 | 174 | | |
177 | 175 | | |
178 | 176 | | |
| |||
0 commit comments