Skip to content

Commit f9787b1

Browse files
committed
Parameter validation for new-app strategy
1 parent 4db1957 commit f9787b1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/generate/app/cmd/newapp.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,13 @@ func validateEnforcedName(name string) error {
269269
return nil
270270
}
271271

272+
func validateStrategyName(name string) error {
273+
if name != "docker" && name != "source" {
274+
return fmt.Errorf("invalid strategy: %s. Must be 'docker' or 'source'.", name)
275+
}
276+
return nil
277+
}
278+
272279
func validateOutputImageReference(ref string) error {
273280
if _, err := imageapi.ParseDockerImageReference(ref); err != nil {
274281
return fmt.Errorf("invalid output image reference: %s", ref)
@@ -597,6 +604,12 @@ func (c *AppConfig) Run() (*AppResult, error) {
597604
}
598605
}
599606

607+
if len(c.Strategy) > 0 {
608+
if err := validateStrategyName(c.Strategy); err != nil {
609+
return nil, err
610+
}
611+
}
612+
600613
if len(c.To) > 0 {
601614
if err := validateOutputImageReference(c.To); err != nil {
602615
return nil, err

0 commit comments

Comments
 (0)