Skip to content

Commit 7fe3ca0

Browse files
committed
feat : Add config option to set developer password for cluster (#2539)
Add option to set developer password for the user. ``` $ crc config set developer-password mypassword $ crc start [...] INFO Adding crc-admin and crc-developer contexts to kubeconfig... Started the OpenShift cluster. The server is accessible via web console at: https://console-openshift-console.apps-crc.testing Log in as user: Username: developer Password: mypassword ``` Signed-off-by: Rohan Kumar <[email protected]>
1 parent f986e3e commit 7fe3ca0

File tree

6 files changed

+15
-0
lines changed

6 files changed

+15
-0
lines changed

cmd/crc/cmd/start.go

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func runStart(ctx context.Context) (*types.StartResult, error) {
7575
NameServer: config.Get(crcConfig.NameServer).AsString(),
7676
PullSecret: cluster.NewInteractivePullSecretLoader(config),
7777
KubeAdminPassword: config.Get(crcConfig.KubeAdminPassword).AsString(),
78+
DeveloperPassword: config.Get(crcConfig.DeveloperPassword).AsString(),
7879
Preset: crcConfig.GetPreset(config),
7980
IngressHTTPPort: config.Get(crcConfig.IngressHTTPPort).AsUInt(),
8081
IngressHTTPSPort: config.Get(crcConfig.IngressHTTPSPort).AsUInt(),

pkg/crc/api/handlers.go

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ func getStartConfig(cfg crcConfig.Storage, args client.StartConfig) types.StartC
127127
NameServer: cfg.Get(crcConfig.NameServer).AsString(),
128128
PullSecret: cluster.NewNonInteractivePullSecretLoader(cfg, args.PullSecretFile),
129129
KubeAdminPassword: cfg.Get(crcConfig.KubeAdminPassword).AsString(),
130+
DeveloperPassword: cfg.Get(crcConfig.DeveloperPassword).AsString(),
130131
IngressHTTPPort: cfg.Get(crcConfig.IngressHTTPPort).AsUInt(),
131132
IngressHTTPSPort: cfg.Get(crcConfig.IngressHTTPSPort).AsUInt(),
132133
Preset: crcConfig.GetPreset(cfg),

pkg/crc/config/settings.go

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const (
2929
ConsentTelemetry = "consent-telemetry"
3030
EnableClusterMonitoring = "enable-cluster-monitoring"
3131
KubeAdminPassword = "kubeadmin-password"
32+
DeveloperPassword = "developer-password"
3233
Preset = "preset"
3334
EnableSharedDirs = "enable-shared-dirs"
3435
SharedDirPassword = "shared-dir-password" // #nosec G101
@@ -134,6 +135,8 @@ func RegisterSettings(cfg *Config) {
134135

135136
cfg.AddSetting(KubeAdminPassword, "", validateString, SuccessfullyApplied,
136137
"User defined kubeadmin password")
138+
cfg.AddSetting(DeveloperPassword, constants.DefaultDeveloperPassword, validateString, SuccessfullyApplied,
139+
"User defined developer password")
137140
cfg.AddSetting(IngressHTTPPort, constants.OpenShiftIngressHTTPPort, validatePort, RequiresHTTPPortChangeWarning,
138141
fmt.Sprintf("HTTP port to use for OpenShift ingress/routes on the host (1024-65535, default: %d)", constants.OpenShiftIngressHTTPPort))
139142
cfg.AddSetting(IngressHTTPSPort, constants.OpenShiftIngressHTTPSPort, validatePort, RequiresHTTPSPortChangeWarning,

pkg/crc/config/settings_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ var configDefaultValuesTestArguments = []struct {
200200
{
201201
KubeAdminPassword, "",
202202
},
203+
{
204+
DeveloperPassword, "developer",
205+
},
203206
{
204207
CPUs, uint(4),
205208
},
@@ -286,6 +289,9 @@ var configProvidedValuesTestArguments = []struct {
286289
{
287290
KubeAdminPassword, "kubeadmin-secret-password",
288291
},
292+
{
293+
DeveloperPassword, "developer-secret-password",
294+
},
289295
{
290296
CPUs, uint(8),
291297
},

pkg/crc/constants/constants.go

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const (
3030
BackgroundLauncherURL = "https://github.com/crc-org/win32-background-launcher/releases/download/v%s/win32-background-launcher.exe"
3131
DefaultBundleURLBase = "https://mirror.openshift.com/pub/openshift-v4/clients/crc/bundles/%s/%s/%s"
3232
DefaultContext = "admin"
33+
DefaultDeveloperPassword = "developer"
3334
DaemonHTTPEndpoint = "http://unix/api"
3435
DaemonVsockPort = 1024
3536
DefaultPodmanNamedPipe = `\\.\pipe\crc-podman`

pkg/crc/machine/types/types.go

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ type StartConfig struct {
2626
// User defined kubeadmin password
2727
KubeAdminPassword string
2828

29+
// User defined developer password
30+
DeveloperPassword string
31+
2932
// Preset
3033
Preset crcpreset.Preset
3134

0 commit comments

Comments
 (0)