|
|
@@ -278,12 +278,20 @@ func (c *CreateAgent) CreateFromDocker(
|
|
|
env = make(map[string]string)
|
|
|
}
|
|
|
|
|
|
- buildEnv, err := GetNestedMap(mergedValues, "container", "env", "build")
|
|
|
+ envConfig, err := GetNestedMap(mergedValues, "container", "env")
|
|
|
|
|
|
if err == nil {
|
|
|
- for key, val := range buildEnv {
|
|
|
- if valStr, ok := val.(string); ok {
|
|
|
- env[key] = valStr
|
|
|
+ _, exists := envConfig["build"]
|
|
|
+
|
|
|
+ if exists {
|
|
|
+ buildEnv, err := GetNestedMap(mergedValues, "container", "env", "build")
|
|
|
+
|
|
|
+ if err == nil {
|
|
|
+ for key, val := range buildEnv {
|
|
|
+ if valStr, ok := val.(string); ok {
|
|
|
+ env[key] = valStr
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -520,33 +528,46 @@ func (c *CreateAgent) CreateSubdomainIfRequired(mergedValues map[string]interfac
|
|
|
enabled, eOK := enabledVal.(bool)
|
|
|
customDomain, cOK := customDomVal.(bool)
|
|
|
|
|
|
- // in the case of ingress enabled but no custom domain, create subdomain
|
|
|
- if eOK && cOK && enabled && !customDomain {
|
|
|
- dnsRecord, err := c.Client.CreateDNSRecord(
|
|
|
- context.Background(),
|
|
|
- c.CreateOpts.ProjectID,
|
|
|
- c.CreateOpts.ClusterID,
|
|
|
- c.CreateOpts.Namespace,
|
|
|
- c.CreateOpts.ReleaseName,
|
|
|
- )
|
|
|
-
|
|
|
- if err != nil {
|
|
|
- return "", fmt.Errorf("Error creating subdomain: %s", err.Error())
|
|
|
- }
|
|
|
+ if eOK && cOK && enabled {
|
|
|
+ if customDomain {
|
|
|
+ // return the first custom domain when one exists
|
|
|
+ hostsArr, hostsExists := ingressMap["hosts"]
|
|
|
|
|
|
- subdomain = dnsRecord.ExternalURL
|
|
|
+ if hostsExists {
|
|
|
+ hostsArrVal, hostsArrOk := hostsArr.([]string)
|
|
|
|
|
|
- if ingressVal, ok := mergedValues["ingress"]; !ok {
|
|
|
- mergedValues["ingress"] = map[string]interface{}{
|
|
|
- "porter_hosts": []string{
|
|
|
- subdomain,
|
|
|
- },
|
|
|
+ if hostsArrOk && len(hostsArrVal) > 0 {
|
|
|
+ subdomain = hostsArrVal[0]
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
- ingressValMap := ingressVal.(map[string]interface{})
|
|
|
+ // in the case of ingress enabled but no custom domain, create subdomain
|
|
|
+ dnsRecord, err := c.Client.CreateDNSRecord(
|
|
|
+ context.Background(),
|
|
|
+ c.CreateOpts.ProjectID,
|
|
|
+ c.CreateOpts.ClusterID,
|
|
|
+ c.CreateOpts.Namespace,
|
|
|
+ c.CreateOpts.ReleaseName,
|
|
|
+ )
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ return "", fmt.Errorf("Error creating subdomain: %s", err.Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ subdomain = dnsRecord.ExternalURL
|
|
|
|
|
|
- ingressValMap["porter_hosts"] = []string{
|
|
|
- subdomain,
|
|
|
+ if ingressVal, ok := mergedValues["ingress"]; !ok {
|
|
|
+ mergedValues["ingress"] = map[string]interface{}{
|
|
|
+ "porter_hosts": []string{
|
|
|
+ subdomain,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ingressValMap := ingressVal.(map[string]interface{})
|
|
|
+
|
|
|
+ ingressValMap["porter_hosts"] = []string{
|
|
|
+ subdomain,
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|