|
|
@@ -13,7 +13,7 @@ func commonValidator(resource *types.Resource) (*Source, *Target, error) {
|
|
|
err := mapstructure.Decode(resource.Source, source)
|
|
|
|
|
|
if err != nil {
|
|
|
- return nil, nil, fmt.Errorf("error parsing source for resource '%s': %w", resource.Name, err)
|
|
|
+ return nil, nil, fmt.Errorf("for resource '%s': error parsing source: %w", resource.Name, err)
|
|
|
}
|
|
|
|
|
|
target := &Target{}
|
|
|
@@ -21,75 +21,125 @@ func commonValidator(resource *types.Resource) (*Source, *Target, error) {
|
|
|
err = mapstructure.Decode(resource.Target, target)
|
|
|
|
|
|
if err != nil {
|
|
|
- return nil, nil, fmt.Errorf("error parsing target for resource '%s': %w", resource.Name, err)
|
|
|
+ return nil, nil, fmt.Errorf("for resource '%s': error parsing target: %w", resource.Name, err)
|
|
|
}
|
|
|
|
|
|
return source, target, nil
|
|
|
}
|
|
|
|
|
|
func deployDriverValidator(resource *types.Resource) error {
|
|
|
- _, _, err := commonValidator(resource)
|
|
|
+ source, _, err := commonValidator(resource)
|
|
|
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
+ if source.Repo == "" || source.Repo == "https://charts.getporter.dev" {
|
|
|
+ appConfig := &ApplicationConfig{}
|
|
|
+
|
|
|
+ err = mapstructure.Decode(resource.Config, appConfig)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ return fmt.Errorf("for resource '%s': error parsing config: %w", resource.Name, err)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func buildImageDriverValidator(resource *types.Resource) error {
|
|
|
- _, _, err := commonValidator(resource)
|
|
|
+ _, target, err := commonValidator(resource)
|
|
|
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
+ if target.AppName == "" {
|
|
|
+ return fmt.Errorf("for resource '%s': target app_name is missing", resource.Name)
|
|
|
+ }
|
|
|
+
|
|
|
+ driverConfig := &BuildDriverConfig{}
|
|
|
+
|
|
|
+ err = mapstructure.Decode(resource.Config, driverConfig)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ return fmt.Errorf("for resource '%s': error parsing config: %w", resource.Name, err)
|
|
|
+ }
|
|
|
+
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func pushImageDriverValidator(resource *types.Resource) error {
|
|
|
- _, _, err := commonValidator(resource)
|
|
|
+ _, target, err := commonValidator(resource)
|
|
|
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
+ if target.AppName == "" {
|
|
|
+ return fmt.Errorf("for resource '%s': target app_name is missing", resource.Name)
|
|
|
+ }
|
|
|
+
|
|
|
+ driverConfig := &PushDriverConfig{}
|
|
|
+
|
|
|
+ err = mapstructure.Decode(resource.Config, driverConfig)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ return fmt.Errorf("for resource '%s': error parsing config: %w", resource.Name, err)
|
|
|
+ }
|
|
|
+
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func updateConfigDriverValidator(resource *types.Resource) error {
|
|
|
- _, _, err := commonValidator(resource)
|
|
|
+ _, target, err := commonValidator(resource)
|
|
|
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- return nil
|
|
|
-}
|
|
|
+ if target.AppName == "" {
|
|
|
+ return fmt.Errorf("for resource '%s': target app_name is missing", resource.Name)
|
|
|
+ }
|
|
|
|
|
|
-func randomStringDriverValidator(resource *types.Resource) error {
|
|
|
- _, _, err := commonValidator(resource)
|
|
|
+ driverConfig := &UpdateConfigDriverConfig{}
|
|
|
+
|
|
|
+ err = mapstructure.Decode(resource.Config, driverConfig)
|
|
|
|
|
|
if err != nil {
|
|
|
- return err
|
|
|
+ return fmt.Errorf("for resource '%s': error parsing config: %w", resource.Name, err)
|
|
|
}
|
|
|
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func randomStringDriverValidator(resource *types.Resource) error {
|
|
|
driverConfig := &RandomStringDriverConfig{}
|
|
|
|
|
|
- err = mapstructure.Decode(resource.Config, driverConfig)
|
|
|
+ err := mapstructure.Decode(resource.Config, driverConfig)
|
|
|
|
|
|
if err != nil {
|
|
|
- return fmt.Errorf("error parsing config for resource '%s': %w", resource.Name, err)
|
|
|
+ return fmt.Errorf("for resource '%s': error parsing config: %w", resource.Name, err)
|
|
|
}
|
|
|
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func envGroupDriverValidator(resource *types.Resource) error {
|
|
|
- _, _, err := commonValidator(resource)
|
|
|
+ target := &Target{}
|
|
|
+
|
|
|
+ err := mapstructure.Decode(resource.Target, target)
|
|
|
|
|
|
if err != nil {
|
|
|
- return err
|
|
|
+ return fmt.Errorf("for resource '%s': error parsing target: %w", resource.Name, err)
|
|
|
+ }
|
|
|
+
|
|
|
+ config := &EnvGroupDriverConfig{}
|
|
|
+
|
|
|
+ err = mapstructure.Decode(resource.Config, config)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ return fmt.Errorf("for resource '%s': error parsing config: %w", resource.Name, err)
|
|
|
}
|
|
|
|
|
|
return nil
|