Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions pkg/asset/cluster/cluster.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cluster

import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
Expand All @@ -12,7 +11,6 @@ import (
"github.com/openshift/installer/data"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/terraform"
"github.com/openshift/installer/pkg/types/config"
)

const (
Expand Down Expand Up @@ -59,12 +57,7 @@ func (c *Cluster) Generate(parents map[asset.Asset]*asset.State) (*asset.State,
return nil, errors.Wrap(err, "failed to write terraform.tfvars file")
}

var tfvars config.Cluster
if err := json.Unmarshal(state.Contents[0].Data, &tfvars); err != nil {
return nil, errors.Wrap(err, "failed to Unmarshal terraform.tfvars file")
}

platform := string(tfvars.Platform)
platform := string(state.Contents[1].Data)
if err := data.Unpack(tmpDir, platform); err != nil {
return nil, err
}
Expand Down
19 changes: 6 additions & 13 deletions pkg/asset/cluster/tfvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cluster
import (
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig"
"github.com/openshift/installer/pkg/types/config"
"github.com/openshift/installer/pkg/tfvars"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -58,18 +58,7 @@ func (t *TerraformVariables) Generate(parents map[asset.Asset]*asset.State) (*as
}
}

cluster, err := config.ConvertInstallConfigToTFVars(installCfg, contents[t.bootstrapIgnition][0], contents[t.masterIgnition], contents[t.workerIgnition][0])
if err != nil {
return nil, err
}

if cluster.Platform == config.PlatformLibvirt {
if err := cluster.Libvirt.UseCachedImage(); err != nil {
return nil, err
}
}

data, err := cluster.TFVars()
data, err := tfvars.TFVars(installCfg, contents[t.bootstrapIgnition][0], contents[t.masterIgnition], contents[t.workerIgnition][0])
if err != nil {
return nil, errors.Wrap(err, "failed to get Tfvars")
}
Expand All @@ -80,6 +69,10 @@ func (t *TerraformVariables) Generate(parents map[asset.Asset]*asset.State) (*as
Name: tfvarsFilename,
Data: []byte(data),
},
{
Name: "platform",
Data: []byte(installCfg.Platform.Name()),
},
},
}, nil
}
2 changes: 1 addition & 1 deletion pkg/asset/ignition/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (a *bootstrap) getTemplateData(installConfig *types.InstallConfig) (*bootst
}
etcdEndpoints := make([]string, installConfig.MasterCount())
for i := range etcdEndpoints {
etcdEndpoints[i] = fmt.Sprintf("https://%s-etcd-%d.%s:2379", installConfig.Name, i, installConfig.BaseDomain)
etcdEndpoints[i] = fmt.Sprintf("https://%s-etcd-%d.%s:2379", installConfig.ObjectMeta.Name, i, installConfig.BaseDomain)
}

releaseImage := defaultReleaseImage
Expand Down
2 changes: 1 addition & 1 deletion pkg/asset/ignition/machine/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func pointerIgnitionConfig(installConfig *types.InstallConfig, rootCA []byte, ro
Source: func() *url.URL {
return &url.URL{
Scheme: "https",
Host: fmt.Sprintf("%s-api.%s:49500", installConfig.Name, installConfig.BaseDomain),
Host: fmt.Sprintf("%s-api.%s:49500", installConfig.ObjectMeta.Name, installConfig.BaseDomain),
Path: fmt.Sprintf("/config/%s", role),
RawQuery: query,
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/asset/installconfig/stock.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
survey "gopkg.in/AlecAivazis/survey.v1"

"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/types/config"
"github.com/openshift/installer/pkg/validate"
)

// Stock is the stock of InstallConfig assets that can be generated.
Expand Down Expand Up @@ -58,7 +58,7 @@ func (s *StockImpl) EstablishStock() {
Help: "The email address of the cluster administrator. This will be used to log in to the console.",
},
Validate: survey.ComposeValidators(survey.Required, func(ans interface{}) error {
return config.ValidateEmail(ans.(string))
return validate.Email(ans.(string))
}),
},
EnvVarName: "OPENSHIFT_INSTALL_EMAIL_ADDRESS",
Expand All @@ -81,7 +81,7 @@ func (s *StockImpl) EstablishStock() {
Help: "The base domain of the cluster. All DNS records will be sub-domains of this base.\n\nFor AWS, this must be a previously-existing public Route 53 zone. You can check for any already in your account with:\n\n $ aws route53 list-hosted-zones --query 'HostedZones[? !(Config.PrivateZone)].Name' --output text",
},
Validate: survey.ComposeValidators(survey.Required, func(ans interface{}) error {
return config.ValidateDomainName(ans.(string))
return validate.DomainName(ans.(string))
}),
},
EnvVarName: "OPENSHIFT_INSTALL_BASE_DOMAIN",
Expand All @@ -94,7 +94,7 @@ func (s *StockImpl) EstablishStock() {
Help: "The name of the cluster. This will be used when generating sub-domains.",
},
Validate: survey.ComposeValidators(survey.Required, func(ans interface{}) error {
return config.ValidateDomainName(ans.(string))
return validate.ClusterName(ans.(string))
}),
},
EnvVarName: "OPENSHIFT_INSTALL_CLUSTER_NAME",
Expand All @@ -107,7 +107,7 @@ func (s *StockImpl) EstablishStock() {
Help: "The container registry pull secret for this cluster.",
},
Validate: survey.ComposeValidators(survey.Required, func(ans interface{}) error {
return config.ValidateJSON([]byte(ans.(string)))
return validate.JSON([]byte(ans.(string)))
}),
},
EnvVarName: "OPENSHIFT_INSTALL_PULL_SECRET",
Expand Down
6 changes: 3 additions & 3 deletions pkg/asset/kubeconfig/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ func (k *Kubeconfig) Generate(parents map[asset.Asset]*asset.State) (*asset.Stat
kubeconfig := clientcmd.Config{
Clusters: []clientcmd.NamedCluster{
{
Name: installConfig.Name,
Name: installConfig.ObjectMeta.Name,
Cluster: clientcmd.Cluster{
Server: fmt.Sprintf("https://%s-api.%s:6443", installConfig.Name, installConfig.BaseDomain),
Server: fmt.Sprintf("https://%s-api.%s:6443", installConfig.ObjectMeta.Name, installConfig.BaseDomain),
CertificateAuthorityData: parents[k.rootCA].Contents[tls.CertIndex].Data,
},
},
Expand All @@ -70,7 +70,7 @@ func (k *Kubeconfig) Generate(parents map[asset.Asset]*asset.State) (*asset.Stat
{
Name: k.userName,
Context: clientcmd.Context{
Cluster: installConfig.Name,
Cluster: installConfig.ObjectMeta.Name,
AuthInfo: k.userName,
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/asset/manifests/kube-addon-operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ func (kao *kubeAddonOperator) addonConfig() ([]byte, error) {
}

func (kao *kubeAddonOperator) getAPIServerURL() string {
return fmt.Sprintf("https://%s-api.%s:6443", kao.installConfig.Name, kao.installConfig.BaseDomain)
return fmt.Sprintf("https://%s-api.%s:6443", kao.installConfig.ObjectMeta.Name, kao.installConfig.BaseDomain)
}
8 changes: 4 additions & 4 deletions pkg/asset/manifests/kube-core-operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,23 @@ func (kco *kubeCoreOperator) coreConfig() ([]byte, error) {
}

func (kco *kubeCoreOperator) getAPIServerURL() string {
return fmt.Sprintf("https://%s-api.%s:6443", kco.installConfig.Name, kco.installConfig.BaseDomain)
return fmt.Sprintf("https://%s-api.%s:6443", kco.installConfig.ObjectMeta.Name, kco.installConfig.BaseDomain)
}

func (kco *kubeCoreOperator) getEtcdServersURLs() []string {
var urls []string
for i := 0; i < kco.installConfig.MasterCount(); i++ {
urls = append(urls, fmt.Sprintf("https://%s-etcd-%d.%s:2379", kco.installConfig.Name, i, kco.installConfig.BaseDomain))
urls = append(urls, fmt.Sprintf("https://%s-etcd-%d.%s:2379", kco.installConfig.ObjectMeta.Name, i, kco.installConfig.BaseDomain))
}
return urls
}

func (kco *kubeCoreOperator) getOicdIssuerURL() string {
return fmt.Sprintf("https://%s.%s/identity", kco.installConfig.Name, kco.installConfig.BaseDomain)
return fmt.Sprintf("https://%s.%s/identity", kco.installConfig.ObjectMeta.Name, kco.installConfig.BaseDomain)
}

func (kco *kubeCoreOperator) getBaseAddress() string {
return fmt.Sprintf("%s.%s", kco.installConfig.Name, kco.installConfig.BaseDomain)
return fmt.Sprintf("%s.%s", kco.installConfig.ObjectMeta.Name, kco.installConfig.BaseDomain)
}

// Converts a platform to the cloudProvider that k8s understands
Expand Down
6 changes: 3 additions & 3 deletions pkg/asset/manifests/machine-api-operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (mao *machineAPIOperator) maoConfig(dependencies map[asset.Asset]*asset.Sta
}

cfg.AWS = &awsConfig{
ClusterName: mao.installConfig.Name,
ClusterName: mao.installConfig.ObjectMeta.Name,
ClusterID: mao.installConfig.ClusterID,
Region: mao.installConfig.Platform.AWS.Region,
AvailabilityZone: "",
Expand All @@ -133,15 +133,15 @@ func (mao *machineAPIOperator) maoConfig(dependencies map[asset.Asset]*asset.Sta
}
} else if mao.installConfig.Platform.Libvirt != nil {
cfg.Libvirt = &libvirtConfig{
ClusterName: mao.installConfig.Name,
ClusterName: mao.installConfig.ObjectMeta.Name,
URI: mao.installConfig.Platform.Libvirt.URI,
NetworkName: mao.installConfig.Platform.Libvirt.Network.Name,
IPRange: mao.installConfig.Platform.Libvirt.Network.IPRange,
Replicas: int(*mao.installConfig.Machines[1].Replicas),
}
} else if mao.installConfig.Platform.OpenStack != nil {
cfg.OpenStack = &openstackConfig{
ClusterName: mao.installConfig.Name,
ClusterName: mao.installConfig.ObjectMeta.Name,
ClusterID: mao.installConfig.ClusterID,
Region: mao.installConfig.Platform.OpenStack.Region,
Replicas: int(*mao.installConfig.Machines[1].Replicas),
Expand Down
2 changes: 1 addition & 1 deletion pkg/asset/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (m *Metadata) Generate(parents map[asset.Asset]*asset.State) (*asset.State,
}

cm := &types.ClusterMetadata{
ClusterName: installCfg.Name,
ClusterName: installCfg.ObjectMeta.Name,
}
switch {
case installCfg.Platform.AWS != nil:
Expand Down
10 changes: 5 additions & 5 deletions pkg/asset/tls/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func assetFilePath(filename string) string {
}

func getBaseAddress(cfg *types.InstallConfig) string {
return fmt.Sprintf("%s.%s", cfg.Name, cfg.BaseDomain)
return fmt.Sprintf("%s.%s", cfg.ObjectMeta.Name, cfg.BaseDomain)
}

func cidrhost(network net.IPNet, hostNum int) (string, error) {
Expand All @@ -45,7 +45,7 @@ func genDNSNamesForIngressCertKey(cfg *types.InstallConfig) ([]string, error) {

func genDNSNamesForAPIServerCertKey(cfg *types.InstallConfig) ([]string, error) {
return []string{
fmt.Sprintf("%s-api.%s", cfg.Name, cfg.BaseDomain),
fmt.Sprintf("%s-api.%s", cfg.ObjectMeta.Name, cfg.BaseDomain),
"kubernetes", "kubernetes.default",
"kubernetes.default.svc",
"kubernetes.default.svc.cluster.local",
Expand All @@ -63,7 +63,7 @@ func genIPAddressesForAPIServerCertKey(cfg *types.InstallConfig) ([]net.IP, erro

func genDNSNamesForOpenshiftAPIServerCertKey(cfg *types.InstallConfig) ([]string, error) {
return []string{
fmt.Sprintf("%s-api.%s", cfg.Name, cfg.BaseDomain),
fmt.Sprintf("%s-api.%s", cfg.ObjectMeta.Name, cfg.BaseDomain),
"openshift-apiserver",
"openshift-apiserver.kube-system",
"openshift-apiserver.kube-system.svc",
Expand All @@ -81,9 +81,9 @@ func genIPAddressesForOpenshiftAPIServerCertKey(cfg *types.InstallConfig) ([]net
}

func genDNSNamesForMCSCertKey(cfg *types.InstallConfig) ([]string, error) {
return []string{fmt.Sprintf("%s-api.%s", cfg.Name, cfg.BaseDomain)}, nil
return []string{fmt.Sprintf("%s-api.%s", cfg.ObjectMeta.Name, cfg.BaseDomain)}, nil
}

func genSubjectForMCSCertKey(cfg *types.InstallConfig) (pkix.Name, error) {
return pkix.Name{CommonName: fmt.Sprintf("%s-api.%s", cfg.Name, cfg.BaseDomain)}, nil
return pkix.Name{CommonName: fmt.Sprintf("%s-api.%s", cfg.ObjectMeta.Name, cfg.BaseDomain)}, nil
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading