@@ -65,6 +65,7 @@ func secretIsOk(app *apiv1.App, secretName string) (string, bool) {
65
65
}
66
66
67
67
func printInstructions (app * apiv1.App , secretName string ) error {
68
+ secretDisplayName := app .Name + "." + secretName
68
69
instructions := app .Status .AppStatus .Secrets [secretName ].LoginInstructions
69
70
if instructions == "" {
70
71
return nil
@@ -80,6 +81,7 @@ func printInstructions(app *apiv1.App, secretName string) error {
80
81
return err
81
82
}
82
83
84
+ fmt .Printf ("Please follow the instructions below to login to [%s]:\n " , secretDisplayName )
83
85
fmt .Print (msg )
84
86
fmt .Println ()
85
87
return nil
@@ -109,22 +111,26 @@ func createSecret(ctx context.Context, c client.Client, app *apiv1.App, secretNa
109
111
110
112
asked := map [string ]struct {}{}
111
113
data := map [string ][]byte {}
112
- promptOrder , _ := app .Status .AppSpec .Secrets [secretName ].Params .GetData ()["promptOrder" ].([]string )
113
- for _ , key := range promptOrder {
114
- if def , ok := app .Status .AppSpec .Secrets [secretName ].Data [key ]; ok {
115
- message := key
116
- if def != "" {
117
- message += fmt .Sprintf (" (default: %s)" , def )
118
- }
119
- value , err := prompt .Password (message )
120
- if err != nil {
121
- return nil , err
122
- }
123
- if len (value ) == 0 {
124
- value = []byte (def )
114
+ paramsData := app .Status .AppSpec .Secrets [secretName ].Params .GetData ()
115
+ if promptOrder , exists := paramsData ["promptOrder" ].([]interface {}); exists {
116
+ for _ , k := range promptOrder {
117
+ if key , ok := k .(string ); ok {
118
+ if def , ok := app .Status .AppSpec .Secrets [secretName ].Data [key ]; ok {
119
+ message := key
120
+ if def != "" {
121
+ message += fmt .Sprintf (" (default: %s)" , def )
122
+ }
123
+ value , err := prompt .Password (message )
124
+ if err != nil {
125
+ return nil , err
126
+ }
127
+ if len (value ) == 0 {
128
+ value = []byte (def )
129
+ }
130
+ data [key ] = value
131
+ asked [key ] = struct {}{}
132
+ }
125
133
}
126
- data [key ] = value
127
- asked [key ] = struct {}{}
128
134
}
129
135
}
130
136
for _ , key := range typed .SortedKeys (app .Status .AppSpec .Secrets [secretName ].Data ) {
@@ -186,7 +192,8 @@ func loginSecret(ctx context.Context, c client.Client, app *apiv1.App, secretNam
186
192
187
193
if len (secretChoiceName ) > 0 {
188
194
def := "Enter a new credential"
189
- choice , err := prompt .Choice ("Choose an existing credential or enter a new one" , append (displayText , def ), def )
195
+ choice , err := prompt .Choice (fmt .Sprintf ("Choose an existing credential or enter a new one for [%s]" ,
196
+ secretDisplayName ), append (displayText , def ), def )
190
197
if err != nil {
191
198
return nil , err
192
199
}
0 commit comments