|
|
@@ -118,6 +118,17 @@ func buildImageDriverValidator(resource *types.Resource) error {
|
|
|
|
|
|
if target.AppName == "" {
|
|
|
return fmt.Errorf("for resource '%s': target app_name is missing", resource.Name)
|
|
|
+ } else {
|
|
|
+ errStrs := validation.IsDNS1123Label(target.AppName)
|
|
|
+
|
|
|
+ if len(errStrs) > 0 {
|
|
|
+ str := fmt.Sprintf("for resource '%s': invalid characters found in app_name:", resource.Name)
|
|
|
+ for _, errStr := range errStrs {
|
|
|
+ str += fmt.Sprintf("\n * %s", errStr)
|
|
|
+ }
|
|
|
+
|
|
|
+ return fmt.Errorf("%s", str)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
driverConfig := &BuildDriverConfig{}
|
|
|
@@ -128,6 +139,34 @@ func buildImageDriverValidator(resource *types.Resource) error {
|
|
|
return fmt.Errorf("for resource '%s': error parsing config: %w", resource.Name, err)
|
|
|
}
|
|
|
|
|
|
+ if driverConfig.Build.Method == "" {
|
|
|
+ return fmt.Errorf("for resource '%s': build method cannot be empty", resource.Name)
|
|
|
+ } else if driverConfig.Build.Method != "docker" &&
|
|
|
+ driverConfig.Build.Method != "pack" &&
|
|
|
+ driverConfig.Build.Method != "registry" {
|
|
|
+ return fmt.Errorf("for resource '%s': build method must be one of 'docker', 'pack', or 'registry'", resource.Name)
|
|
|
+ }
|
|
|
+
|
|
|
+ if driverConfig.Build.Method == "docker" && driverConfig.Build.Dockerfile == "" {
|
|
|
+ return fmt.Errorf("for resource '%s': dockerfile cannot be empty when using the 'docker' build method",
|
|
|
+ resource.Name)
|
|
|
+ } else if driverConfig.Build.Method == "registry" && driverConfig.Build.Image == "" {
|
|
|
+ return fmt.Errorf("for resource '%s': image cannot be empty when using the 'registry' build method",
|
|
|
+ resource.Name)
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, eg := range driverConfig.EnvGroups {
|
|
|
+ if errStrs := validation.IsDNS1123Label(eg.Name); len(errStrs) > 0 {
|
|
|
+ str := fmt.Sprintf("for resource '%s': invalid characters found in env group '%s' name:",
|
|
|
+ resource.Name, eg.Name)
|
|
|
+ for _, errStr := range errStrs {
|
|
|
+ str += fmt.Sprintf("\n * %s", errStr)
|
|
|
+ }
|
|
|
+
|
|
|
+ return fmt.Errorf("%s", str)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
@@ -140,6 +179,17 @@ func pushImageDriverValidator(resource *types.Resource) error {
|
|
|
|
|
|
if target.AppName == "" {
|
|
|
return fmt.Errorf("for resource '%s': target app_name is missing", resource.Name)
|
|
|
+ } else {
|
|
|
+ errStrs := validation.IsDNS1123Label(target.AppName)
|
|
|
+
|
|
|
+ if len(errStrs) > 0 {
|
|
|
+ str := fmt.Sprintf("for resource '%s': invalid characters found in app_name:", resource.Name)
|
|
|
+ for _, errStr := range errStrs {
|
|
|
+ str += fmt.Sprintf("\n * %s", errStr)
|
|
|
+ }
|
|
|
+
|
|
|
+ return fmt.Errorf("%s", str)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
driverConfig := &PushDriverConfig{}
|
|
|
@@ -150,6 +200,10 @@ func pushImageDriverValidator(resource *types.Resource) error {
|
|
|
return fmt.Errorf("for resource '%s': error parsing config: %w", resource.Name, err)
|
|
|
}
|
|
|
|
|
|
+ if driverConfig.Push.Image == "" {
|
|
|
+ return fmt.Errorf("for resource '%s': image cannot be empty", resource.Name)
|
|
|
+ }
|
|
|
+
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
@@ -162,6 +216,17 @@ func updateConfigDriverValidator(resource *types.Resource) error {
|
|
|
|
|
|
if target.AppName == "" {
|
|
|
return fmt.Errorf("for resource '%s': target app_name is missing", resource.Name)
|
|
|
+ } else {
|
|
|
+ errStrs := validation.IsDNS1123Label(target.AppName)
|
|
|
+
|
|
|
+ if len(errStrs) > 0 {
|
|
|
+ str := fmt.Sprintf("for resource '%s': invalid characters found in app_name:", resource.Name)
|
|
|
+ for _, errStr := range errStrs {
|
|
|
+ str += fmt.Sprintf("\n * %s", errStr)
|
|
|
+ }
|
|
|
+
|
|
|
+ return fmt.Errorf("%s", str)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
driverConfig := &UpdateConfigDriverConfig{}
|
|
|
@@ -172,6 +237,22 @@ func updateConfigDriverValidator(resource *types.Resource) error {
|
|
|
return fmt.Errorf("for resource '%s': error parsing config: %w", resource.Name, err)
|
|
|
}
|
|
|
|
|
|
+ if driverConfig.UpdateConfig.Image == "" {
|
|
|
+ return fmt.Errorf("for resource '%s': image cannot be empty", resource.Name)
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, eg := range driverConfig.EnvGroups {
|
|
|
+ if errStrs := validation.IsDNS1123Label(eg.Name); len(errStrs) > 0 {
|
|
|
+ str := fmt.Sprintf("for resource '%s': invalid characters found in env group '%s' name:",
|
|
|
+ resource.Name, eg.Name)
|
|
|
+ for _, errStr := range errStrs {
|
|
|
+ str += fmt.Sprintf("\n * %s", errStr)
|
|
|
+ }
|
|
|
+
|
|
|
+ return fmt.Errorf("%s", str)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
@@ -204,6 +285,18 @@ func envGroupDriverValidator(resource *types.Resource) error {
|
|
|
return fmt.Errorf("for resource '%s': error parsing config: %w", resource.Name, err)
|
|
|
}
|
|
|
|
|
|
+ for _, eg := range config.EnvGroups {
|
|
|
+ if errStrs := validation.IsDNS1123Label(eg.Name); len(errStrs) > 0 {
|
|
|
+ str := fmt.Sprintf("for resource '%s': invalid characters found in env group '%s' name:",
|
|
|
+ resource.Name, eg.Name)
|
|
|
+ for _, errStr := range errStrs {
|
|
|
+ str += fmt.Sprintf("\n * %s", errStr)
|
|
|
+ }
|
|
|
+
|
|
|
+ return fmt.Errorf("%s", str)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return nil
|
|
|
}
|
|
|
|