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
30 changes: 11 additions & 19 deletions Documentation/design/installconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ type AWSClusterSpec struct {
SSHUser string
SSLSecret corev1.LocalObjectReference

KeyPairName string

Region string
VPCName string
VPCSubnet string
Expand Down Expand Up @@ -245,11 +243,11 @@ type InstallConfig struct {
// ClusterID is the ID of the cluster.
ClusterID string `json:"clusterID"`

// Admin is the configuration for the admin user.
Admin Admin `json:"admin"`
// Admin is the configuration for the admin user.
Admin Admin `json:"admin"`

// BaseDomain is the base domain to which the cluster should belong.
BaseDomain string `json:"baseDomain"`
// BaseDomain is the base domain to which the cluster should belong.
BaseDomain string `json:"baseDomain"`

// Networking defines the pod network provider in the cluster.
Networking `json:"networking"`
Expand All @@ -260,16 +258,17 @@ type InstallConfig struct {
// only one of the platform configuration should be set
Platform `json:"platform"`

// License is an OpenShift license needed to install a cluster.
License string `json:"license"`
// License is an OpenShift license needed to install a cluster.
License string `json:"license"`

// PullSecret is the secret to use when pulling images.
PullSecret string `json:"pullSecret"`
// PullSecret is the secret to use when pulling images.
PullSecret string `json:"pullSecret"`
}

type Admin struct {
Email string `json:"email"`
Password string `json:"password"`
Email string `json:"email"`
Password string `json:"password"`
SSHKey string `json:"sshKey"`
}

type Platform struct {
Expand Down Expand Up @@ -299,10 +298,6 @@ type AWS struct {
// Region specifies the AWS region where the cluster will be created.
Region string `json:"region"`

// KeyPairName is the name of the AWS key pair to use for SSH access to EC2
// instances in this cluster.
KeyPairName string `json:"keyPairName"`

// VPCID specifies the vpc to associate with the cluster.
// If empty, new vpc will be created.
// +optional
Expand All @@ -319,9 +314,6 @@ type Libvirt struct {
// URI
URI string `json:"URI"`

// SSHKey
SSHKey string `json:"sshKey"`

// Network
Network `json:"network"`

Expand Down
2 changes: 2 additions & 0 deletions Documentation/design/resource_dep.dot
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ strict digraph resource {
platform [label="platform"];
email_address [label="email address"];
password [label="password"];
sshkey [label="SSH key"];
}

// Install config.
Expand Down Expand Up @@ -88,6 +89,7 @@ strict digraph resource {

// Dependencies
password -> install_config;
sshkey -> install_config;
platform -> install_config;
email_address -> install_config;
pull_secret -> install_config;
Expand Down
404 changes: 207 additions & 197 deletions Documentation/design/resource_dep.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions pkg/asset/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package asset defines the asset dependencies and implements the graph engine.
package asset
2 changes: 1 addition & 1 deletion pkg/asset/installconfig/clusterid.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (a *clusterID) Dependencies() []asset.Asset {
func (a *clusterID) Generate(map[asset.Asset]*asset.State) (*asset.State, error) {
return &asset.State{
Contents: []asset.Content{
{Data: []byte(uuid.NewUUID().String())},
{Data: []byte(uuid.New())},
},
}, nil
}
3 changes: 3 additions & 0 deletions pkg/asset/installconfig/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Package installconfig generates the install config assets based on its dependencies.
// The type itself is defined in ../pkg/types.
package installconfig
11 changes: 5 additions & 6 deletions pkg/asset/installconfig/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func (a *installConfig) Dependencies() []asset.Asset {
a.assetStock.ClusterID(),
a.assetStock.EmailAddress(),
a.assetStock.Password(),
a.assetStock.SSHKey(),
a.assetStock.BaseDomain(),
a.assetStock.ClusterName(),
a.assetStock.License(),
Expand All @@ -40,6 +41,7 @@ func (a *installConfig) Generate(dependencies map[asset.Asset]*asset.State) (*as
clusterID := string(dependencies[a.assetStock.ClusterID()].Contents[0].Data)
emailAddress := string(dependencies[a.assetStock.EmailAddress()].Contents[0].Data)
password := string(dependencies[a.assetStock.Password()].Contents[0].Data)
sshKey := string(dependencies[a.assetStock.SSHKey()].Contents[0].Data)
baseDomain := string(dependencies[a.assetStock.BaseDomain()].Contents[0].Data)
clusterName := string(dependencies[a.assetStock.ClusterName()].Contents[0].Data)
license := string(dependencies[a.assetStock.License()].Contents[0].Data)
Expand All @@ -53,6 +55,7 @@ func (a *installConfig) Generate(dependencies map[asset.Asset]*asset.State) (*as
Admin: types.Admin{
Email: emailAddress,
Password: password,
SSHKey: sshKey,
},
BaseDomain: baseDomain,
License: license,
Expand All @@ -64,17 +67,13 @@ func (a *installConfig) Generate(dependencies map[asset.Asset]*asset.State) (*as
switch platform {
case AWSPlatformType:
region := string(platformState.Contents[1].Data)
keyPairName := string(platformState.Contents[2].Data)
installConfig.AWS = &types.AWSPlatform{
Region: region,
KeyPairName: keyPairName,
Region: region,
}
case LibvirtPlatformType:
uri := string(platformState.Contents[1].Data)
sshKey := string(platformState.Contents[2].Data)
installConfig.Libvirt = &types.LibvirtPlatform{
URI: uri,
SSHKey: sshKey,
URI: uri,
}
default:
return nil, fmt.Errorf("unknown platform type %q", platform)
Expand Down
13 changes: 8 additions & 5 deletions pkg/asset/installconfig/installconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func TestInstallConfigDependencies(t *testing.T) {
clusterID: &testAsset{name: "test-cluster-id"},
emailAddress: &testAsset{name: "test-email"},
password: &testAsset{name: "test-password"},
sshKey: &testAsset{name: "test-sshkey"},
baseDomain: &testAsset{name: "test-domain"},
clusterName: &testAsset{name: "test-cluster"},
license: &testAsset{name: "test-license"},
Expand All @@ -42,6 +43,7 @@ func TestInstallConfigDependencies(t *testing.T) {
"test-cluster-id",
"test-email",
"test-password",
"test-sshkey",
"test-domain",
"test-cluster",
"test-license",
Expand Down Expand Up @@ -69,10 +71,8 @@ func TestInstallConfigGenerate(t *testing.T) {
platformContents: []string{
"aws",
"test-region",
"test-keypairname",
},
expectedPlatformYaml: ` aws:
keyPairName: test-keypairname
region: test-region
vpcCIDRBlock: ""
vpcID: ""`,
Expand All @@ -82,7 +82,6 @@ func TestInstallConfigGenerate(t *testing.T) {
platformContents: []string{
"libvirt",
"test-uri",
"test-sshkey",
},
expectedPlatformYaml: ` libvirt:
URI: test-uri
Expand All @@ -91,8 +90,7 @@ func TestInstallConfigGenerate(t *testing.T) {
if: ""
ipRange: ""
name: ""
resolver: ""
sshKey: test-sshkey`,
resolver: ""`,
},
}
for _, tc := range cases {
Expand All @@ -101,6 +99,7 @@ func TestInstallConfigGenerate(t *testing.T) {
clusterID: &testAsset{},
emailAddress: &testAsset{},
password: &testAsset{},
sshKey: &testAsset{},
baseDomain: &testAsset{},
clusterName: &testAsset{},
license: &testAsset{},
Expand Down Expand Up @@ -129,6 +128,9 @@ func TestInstallConfigGenerate(t *testing.T) {
stock.password: {
Contents: []asset.Content{{Data: []byte("test-password")}},
},
stock.sshKey: {
Contents: []asset.Content{{Data: []byte("test-sshkey")}},
},
stock.baseDomain: {
Contents: []asset.Content{{Data: []byte("test-domain")}},
},
Expand Down Expand Up @@ -162,6 +164,7 @@ func TestInstallConfigGenerate(t *testing.T) {
exp := fmt.Sprintf(`admin:
email: test-email
password: test-password
sshKey: test-sshkey
baseDomain: test-domain
clusterID: test-cluster-id
license: test-license
Expand Down
5 changes: 1 addition & 4 deletions pkg/asset/installconfig/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ var (
//
// * AWS
// Contents[1] is the region.
// Contents[2] is the key pair name.
//
// * Libvirt
// Contents[1] is the URI.
// Contents[2] is the SSH key.
type Platform struct {
InputReader *bufio.Reader
}
Expand Down Expand Up @@ -73,15 +71,14 @@ func (a *Platform) awsPlatform() (*asset.State, error) {
return assetStateForStringContents(
AWSPlatformType,
asset.QueryUser(a.InputReader, "Region:"),
asset.QueryUser(a.InputReader, "Key Pair Name:"),
), nil
}

func (a *Platform) libvirtPlatform() (*asset.State, error) {
return assetStateForStringContents(
LibvirtPlatformType,
// TODO(yifan): Set the default URI.
asset.QueryUser(a.InputReader, "URI:"),
asset.QueryUser(a.InputReader, "SSH Key:"),
), nil
}

Expand Down
16 changes: 4 additions & 12 deletions pkg/asset/installconfig/platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,46 +25,38 @@ func TestPlatformGenerate(t *testing.T) {
{
name: "aws",
input: `aws
test_region
test_keypairname`,
test_region`,
expectedContents: []string{
"aws",
"test_region",
"test_keypairname",
},
},
{
name: "libvirt",
input: `libvirt
test_uri
test_sshkey`,
test_uri`,
expectedContents: []string{
"libvirt",
"test_uri",
"test_sshkey",
},
},
{
name: "case insensitive platform",
input: `AWS
test_region
test_keypairname`,
test_region`,
expectedContents: []string{
"aws",
"test_region",
"test_keypairname",
},
},
{
name: "invalid platform",
input: `bad-platform
aws
test_region
test_keypairname`,
test_region`,
expectedContents: []string{
"aws",
"test_region",
"test_keypairname",
},
},
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/asset/installconfig/stock.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type Stock interface {
EmailAddress() asset.Asset
// Password is the asset that queries the user for the admin password.
Password() asset.Asset
// SSHKey is the asset that queries the user for the ssh public key in a string format.
SSHKey() asset.Asset
// BaseDomain is the asset that queries the user for the base domain to use
// for the cluster.
BaseDomain() asset.Asset
Expand All @@ -36,6 +38,7 @@ type StockImpl struct {
clusterID asset.Asset
emailAddress asset.Asset
password asset.Asset
sshKey asset.Asset
baseDomain asset.Asset
clusterName asset.Asset
license asset.Asset
Expand All @@ -58,6 +61,10 @@ func (s *StockImpl) EstablishStock(directory string, inputReader *bufio.Reader)
Prompt: "Password:",
InputReader: inputReader,
}
s.sshKey = &asset.UserProvided{
Prompt: "SSH Key:",
InputReader: inputReader,
}
s.baseDomain = &asset.UserProvided{
Prompt: "Base Domain:",
InputReader: inputReader,
Expand Down Expand Up @@ -97,6 +104,11 @@ func (s *StockImpl) Password() asset.Asset {
return s.password
}

// SSHKey is the asset that queries the user for the ssh public key in a string format.
func (s *StockImpl) SSHKey() asset.Asset {
return s.sshKey
}

// BaseDomain is the asset that queries the user for the base domain to use
// for the cluster.
func (s *StockImpl) BaseDomain() asset.Asset {
Expand Down
2 changes: 2 additions & 0 deletions pkg/asset/stock/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package stock defines a stock type that holds that holds the instantiated assets.
package stock
2 changes: 2 additions & 0 deletions pkg/types/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package types defines structures for user-supplied installer configuration.
package types
9 changes: 2 additions & 7 deletions pkg/types/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type Admin struct {
Email string `json:"email"`
// Password is the password of the admin user.
Password string `json:"password"`
// SSHKey to use for the access to compute instances.
SSHKey string `json:"sshKey,omitempty"`
}

// Platform is the configuration for the specific platform upon which to perform
Expand Down Expand Up @@ -79,10 +81,6 @@ type AWSPlatform struct {
// Region specifies the AWS region where the cluster will be created.
Region string `json:"region"`

// KeyPairName is the name of the AWS key pair to use for SSH access to EC2
// instances in this cluster.
KeyPairName string `json:"keyPairName"`

// VPCID specifies the vpc to associate with the cluster.
// If empty, new vpc will be created.
// +optional
Expand All @@ -99,9 +97,6 @@ type LibvirtPlatform struct {
// URI
URI string `json:"URI"`

// SSHKey
SSHKey string `json:"sshKey"`

// Network
Network LibvirtNetwork `json:"network"`

Expand Down