Skip to content

Commit d05811e

Browse files
authored
init: Skips TLS validation on API calls (#39)
Hardcodes the configuration for the `init` API calls to skip TLS validation so that init works out of the box with self-signed TLS certificates, common in ECE installations. Signed-off-by: Marc Lopez <marc5.12@outlook.com>
1 parent 1bd7726 commit d05811e

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

pkg/ecctl/init.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ func InitConfig(params InitConfigParams) error {
178178
Client: params.Client,
179179
OutputDevice: outputDevice,
180180
ErrorDevice: params.ErrWriter,
181+
// Insecure is set to true by default to allow API calls against HTTPS
182+
// endpoints with self-signed certificates.
183+
Insecure: true,
181184
}
182185
if err := params.Viper.Unmarshal(&cfg); err != nil {
183186
return err

pkg/ecctl/init_test.go

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,10 @@ func TestInitConfig(t *testing.T) {
256256
}))),
257257
}},
258258
wantSettings: map[string]interface{}{
259-
"apikey": "somekey",
260-
"host": "https://ahost",
261-
"output": "text",
259+
"apikey": "somekey",
260+
"host": "https://ahost",
261+
"insecure": true,
262+
"output": "text",
262263
},
263264
wantOutput: disclaimer + missingConfigMsg + hostMsg +
264265
formatChoiceMsg + "\n" + authChoiceMsg + "\n" + apiKeyMsg + "\n" +
@@ -291,10 +292,11 @@ func TestInitConfig(t *testing.T) {
291292
),
292293
}},
293294
wantSettings: map[string]interface{}{
294-
"host": "https://ahost",
295-
"output": "text",
296-
"pass": "apassword",
297-
"user": "auser",
295+
"host": "https://ahost",
296+
"insecure": true,
297+
"output": "text",
298+
"pass": "apassword",
299+
"user": "auser",
298300
},
299301
wantOutput: disclaimer + missingConfigMsg + hostMsg +
300302
formatChoiceMsg + "\n" + authChoiceMsg + "\n" + userMsg + passMsg +
@@ -322,9 +324,10 @@ func TestInitConfig(t *testing.T) {
322324
}))),
323325
}},
324326
wantSettings: map[string]interface{}{
325-
"apikey": "somekey",
326-
"host": "https://ahost",
327-
"output": "text",
327+
"apikey": "somekey",
328+
"host": "https://ahost",
329+
"insecure": true,
330+
"output": "text",
328331
},
329332
wantOutput: disclaimer +
330333
fmt.Sprintf(settingsPathMsg, "test_files/userpassmodif.yaml") +
@@ -359,10 +362,11 @@ func TestInitConfig(t *testing.T) {
359362
),
360363
}},
361364
wantSettings: map[string]interface{}{
362-
"host": "https://ahost",
363-
"output": "text",
364-
"pass": "apassword",
365-
"user": "auser",
365+
"host": "https://ahost",
366+
"insecure": true,
367+
"output": "text",
368+
"pass": "apassword",
369+
"user": "auser",
366370
},
367371
wantOutput: disclaimer +
368372
fmt.Sprintf(settingsPathMsg, "test_files/apikeymodif.yaml") +

0 commit comments

Comments
 (0)