@@ -34,6 +34,7 @@ import (
34
34
"github.com/codefresh-io/cli-v2/pkg/util"
35
35
36
36
"github.com/argoproj-labs/argocd-autopilot/pkg/git"
37
+ autoPilotUtil "github.com/argoproj-labs/argocd-autopilot/pkg/util"
37
38
"github.com/manifoldco/promptui"
38
39
"github.com/spf13/cobra"
39
40
"github.com/spf13/pflag"
@@ -83,7 +84,11 @@ func IsValidName(s string) (bool, error) {
83
84
}
84
85
85
86
func isValidIngressHost (ingressHost string ) (bool , error ) {
86
- return regexp .MatchString (`^(http|https)://` , ingressHost )
87
+ pattern := `^https://`
88
+ if store .Get ().InsecureIngressHost {
89
+ pattern = `^(http|https)://`
90
+ }
91
+ return regexp .MatchString (pattern , ingressHost )
87
92
}
88
93
89
94
func askUserIfToInstallDemoResources (cmd * cobra.Command , sampleInstall * bool ) error {
@@ -149,6 +154,13 @@ func ensureRepo(cmd *cobra.Command, runtimeName string, cloneOpts *git.CloneOpti
149
154
func getRepoFromUserInput (cmd * cobra.Command ) error {
150
155
repoPrompt := promptui.Prompt {
151
156
Label : "Repository URL" ,
157
+ Validate : func (value string ) error {
158
+ host , orgRepo , _ , _ , _ , _ , _ := autoPilotUtil .ParseGitUrl (value )
159
+ if host != "" && orgRepo != "" {
160
+ return nil
161
+ }
162
+ return fmt .Errorf ("Invalid URL for Git repository" )
163
+ },
152
164
}
153
165
repoInput , err := repoPrompt .Run ()
154
166
if err != nil {
@@ -225,7 +237,7 @@ func validateRuntimeName(runtime string) error {
225
237
return fmt .Errorf ("failed to validate runtime name: %w" , err )
226
238
}
227
239
if ! isValid {
228
- return fmt .Errorf ("runtime name cannot have any uppercase letters, must start with a character, end with character or number, and be shorter than 63 chars " )
240
+ return fmt .Errorf ("Runtime name must start with a lower-case character, and can include up to 62 lower-case characters and numbers " )
229
241
}
230
242
return nil
231
243
}
@@ -276,10 +288,10 @@ func inferProviderFromRepo(opts *git.CloneOptions) {
276
288
}
277
289
278
290
func ensureGitToken (cmd * cobra.Command , cloneOpts * git.CloneOptions , verify bool ) error {
279
- errMessage := "Value from environment variable TOKEN is not valid, enter another value "
291
+ errMessage := "Value stored in environment variable TOKEN is invalid; enter a valid runtime token "
280
292
if cloneOpts .Auth .Password == "" && ! store .Get ().Silent {
281
293
err := getGitTokenFromUserInput (cmd )
282
- errMessage = "Entered git token is not valid, enter another value please "
294
+ errMessage = "Invalid runtime token; enter a valid token "
283
295
if err != nil {
284
296
return err
285
297
}
@@ -440,7 +452,7 @@ func validateIngressHost(ingressHost string) error {
440
452
if err != nil {
441
453
err = fmt .Errorf ("could not verify ingress host: %w" , err )
442
454
} else if ! isValid {
443
- err = fmt .Errorf ("ingress host must begin with protocol ' http://' or ' https://' " )
455
+ err = fmt .Errorf ("Ingress host must begin with a protocol, either http:// or https://" )
444
456
}
445
457
446
458
return err
@@ -484,6 +496,11 @@ func setIngressHost(ctx context.Context, opts *RuntimeInstallOptions) error {
484
496
if err != nil {
485
497
return err
486
498
}
499
+ _ , err := http .Get (opts .IngressHost )
500
+ if err != nil {
501
+ opts .IngressHost = ""
502
+ return err
503
+ }
487
504
}
488
505
489
506
if opts .IngressHost == "" {
0 commit comments