|
|
@@ -58,6 +58,7 @@ func parse(
|
|
|
existingDependencies []*chart.Dependency,
|
|
|
opts SubdomainCreateOpts,
|
|
|
injectLauncher bool,
|
|
|
+ shouldCreate bool,
|
|
|
) (*chart.Chart, map[string]interface{}, map[string]interface{}, error) {
|
|
|
parsed := &PorterStackYAML{}
|
|
|
|
|
|
@@ -66,7 +67,7 @@ func parse(
|
|
|
return nil, nil, nil, fmt.Errorf("%s: %w", "error parsing porter.yaml", err)
|
|
|
}
|
|
|
|
|
|
- values, err := buildUmbrellaChartValues(parsed, imageInfo, existingValues, opts, injectLauncher)
|
|
|
+ values, err := buildUmbrellaChartValues(parsed, imageInfo, existingValues, opts, injectLauncher, shouldCreate)
|
|
|
if err != nil {
|
|
|
return nil, nil, nil, fmt.Errorf("%s: %w", "error building values from porter.yaml", err)
|
|
|
}
|
|
|
@@ -86,7 +87,14 @@ func parse(
|
|
|
return chart, convertedValues, preDeployJobValues, nil
|
|
|
}
|
|
|
|
|
|
-func buildUmbrellaChartValues(parsed *PorterStackYAML, imageInfo types.ImageInfo, existingValues map[string]interface{}, opts SubdomainCreateOpts, injectLauncher bool) (map[string]interface{}, error) {
|
|
|
+func buildUmbrellaChartValues(
|
|
|
+ parsed *PorterStackYAML,
|
|
|
+ imageInfo types.ImageInfo,
|
|
|
+ existingValues map[string]interface{},
|
|
|
+ opts SubdomainCreateOpts,
|
|
|
+ injectLauncher bool,
|
|
|
+ shouldCreate bool,
|
|
|
+) (map[string]interface{}, error) {
|
|
|
values := make(map[string]interface{})
|
|
|
|
|
|
if parsed.Apps == nil {
|
|
|
@@ -110,7 +118,7 @@ func buildUmbrellaChartValues(parsed *PorterStackYAML, imageInfo types.ImageInfo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- validateErr := validateHelmValues(helm_values)
|
|
|
+ validateErr := validateHelmValues(helm_values, shouldCreate)
|
|
|
if validateErr != "" {
|
|
|
return nil, fmt.Errorf("error validating service \"%s\": %s", name, validateErr)
|
|
|
}
|
|
|
@@ -167,24 +175,27 @@ func buildUmbrellaChartValues(parsed *PorterStackYAML, imageInfo types.ImageInfo
|
|
|
}
|
|
|
|
|
|
// we can add to this function up later or use an alternative
|
|
|
-func validateHelmValues(values map[string]interface{}) string {
|
|
|
- containerMap, err := getNestedMap(values, "container")
|
|
|
- if err != nil {
|
|
|
- return "error checking port: misformatted values"
|
|
|
- } else {
|
|
|
- portVal, portExists := containerMap["port"]
|
|
|
- if portExists {
|
|
|
- portStr, pOK := portVal.(string)
|
|
|
- if !pOK {
|
|
|
- return "error checking port: no port in container"
|
|
|
- }
|
|
|
+func validateHelmValues(values map[string]interface{}, shouldCreate bool) string {
|
|
|
+ // currently, we only validate port on initial app create, because this will break any updates to existing apps with lower port numbers
|
|
|
+ if shouldCreate {
|
|
|
+ containerMap, err := getNestedMap(values, "container")
|
|
|
+ if err != nil {
|
|
|
+ return "error checking port: misformatted values"
|
|
|
+ } else {
|
|
|
+ portVal, portExists := containerMap["port"]
|
|
|
+ if portExists {
|
|
|
+ portStr, pOK := portVal.(string)
|
|
|
+ if !pOK {
|
|
|
+ return "error checking port: no port in container"
|
|
|
+ }
|
|
|
|
|
|
- port, err := strconv.Atoi(portStr)
|
|
|
- if err != nil || port < 1024 || port > 65535 {
|
|
|
- return "port must be a number between 1024 and 65535"
|
|
|
+ port, err := strconv.Atoi(portStr)
|
|
|
+ if err != nil || port < 1024 || port > 65535 {
|
|
|
+ return "port must be a number between 1024 and 65535"
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return "must specify port if choosing to expose service externally"
|
|
|
}
|
|
|
- } else {
|
|
|
- return "must specify port if choosing to expose service externally"
|
|
|
}
|
|
|
}
|
|
|
return ""
|