Skip to content

Commit d8b3b49

Browse files
ajp-ioemosbaugh
andauthored
prompt if manager will use self-signed cert (#2313)
* prompt if manager will use self-signed cert * fix test race --------- Co-authored-by: Ethan Mosbaugh <ethan@replicated.com>
1 parent 61bb6fe commit d8b3b49

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

api/integration/install_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,18 +209,15 @@ func TestConfigureInstallation(t *testing.T) {
209209
require.NoError(t, err)
210210

211211
// Verify that the status was properly set
212-
assert.Equal(t, types.StateRunning, status.State)
213-
assert.Equal(t, "Configuring installation", status.Description)
214-
}
215-
216-
if !tc.expectedError {
217212
// The status is set to succeeded in a goroutine, so we need to wait for it
218213
assert.Eventually(t, func() bool {
219214
status, err := installController.GetInstallationStatus(t.Context())
220215
require.NoError(t, err)
221-
return status.State == types.StateSucceeded
222-
}, 1*time.Second, 100*time.Millisecond)
216+
return status.State == types.StateSucceeded && status.Description == "Installation configured"
217+
}, 1*time.Second, 100*time.Millisecond, "status should eventually be succeeded")
218+
}
223219

220+
if !tc.expectedError {
224221
// Verify that the config is in the store
225222
storedConfig, err := installController.GetInstallationConfig(t.Context())
226223
require.NoError(t, err)

cmd/installer/cli/install.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,23 @@ func runManagerExperienceInstall(ctx context.Context, flags InstallCmdFlags, rc
337337
return fmt.Errorf("unable to list all valid IP addresses: %w", err)
338338
}
339339

340+
if flags.tlsCertFile == "" || flags.tlsKeyFile == "" {
341+
logrus.Warn("\nNo certificate files provided. A self-signed certificate will be used, and your browser will show a security warning.")
342+
logrus.Info("To use your own certificate, provide both --tls-key and --tls-cert flags.")
343+
344+
if !flags.assumeYes {
345+
logrus.Info("") // newline so the prompt is separated from the warning
346+
confirmed, err := prompts.New().Confirm("Do you want to continue with a self-signed certificate?", false)
347+
if err != nil {
348+
return fmt.Errorf("failed to get confirmation: %w", err)
349+
}
350+
if !confirmed {
351+
logrus.Infof("\nInstallation cancelled. Please run the command again with the --tls-key and --tls-cert flags.\n")
352+
return nil
353+
}
354+
}
355+
}
356+
340357
if flags.tlsCertFile != "" && flags.tlsKeyFile != "" {
341358
cert, err := tls.LoadX509KeyPair(flags.tlsCertFile, flags.tlsKeyFile)
342359
if err != nil {

0 commit comments

Comments
 (0)