Skip to content

Commit 6be4c25

Browse files
committed
*: remove support for environment variables
The environment variables were originally added to make CI testing a little easier, since the installer didn't support consumption of provided assets (e.g. the install config). Now that the installer supports consumption, there is no need for most of the environment variables anymore. The variables have actually been confusing to users, so their removal should simplify the mental model.
1 parent 717e2a0 commit 6be4c25

File tree

12 files changed

+18
-164
lines changed

12 files changed

+18
-164
lines changed

docs/dev/libvirt-howto.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,6 @@ Set `TAGS` when building if you need `destroy cluster` support for libvirt; this
223223
TAGS=libvirt_destroy hack/build.sh
224224
```
225225

226-
To avoid being prompted repeatedly, you can set [environment variables](../user/environment-variables.md) to reflect your libvirt choices. For example, selecting libvirt, setting [our earlier name choices](#pick-names), and telling both the installer and the machine-API operator to contact `libvirtd` at [the usual libvirt IP](#firewall), you can use:
227-
228-
```sh
229-
export OPENSHIFT_INSTALL_PLATFORM=libvirt
230-
export OPENSHIFT_INSTALL_BASE_DOMAIN=tt.testing
231-
export OPENSHIFT_INSTALL_CLUSTER_NAME=test1
232-
export OPENSHIFT_INSTALL_LIBVIRT_URI=qemu+tcp://192.168.122.1/system
233-
```
234-
235226
## Cleanup
236227

237228
If you compiled with `libvirt_destroy`, you can use:

docs/user/environment-variables.md

Lines changed: 0 additions & 51 deletions
This file was deleted.

pkg/asset/installconfig/aws/aws.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
package aws
33

44
import (
5-
"encoding/json"
65
"fmt"
76
"os"
87
"path/filepath"
@@ -112,23 +111,14 @@ func Platform() (*aws.Platform, error) {
112111
}),
113112
Transform: regionTransform,
114113
},
115-
"OPENSHIFT_INSTALL_AWS_REGION",
116114
)
117115
if err != nil {
118116
return nil, err
119117
}
120118

121-
userTags := map[string]string{}
122-
if value, ok := os.LookupEnv("_CI_ONLY_STAY_AWAY_OPENSHIFT_INSTALL_AWS_USER_TAGS"); ok {
123-
if err := json.Unmarshal([]byte(value), &userTags); err != nil {
124-
return nil, errors.Wrapf(err, "_CI_ONLY_STAY_AWAY_OPENSHIFT_INSTALL_AWS_USER_TAGS contains invalid JSON: %s", value)
125-
}
126-
}
127-
128119
return &aws.Platform{
129120
VPCCIDRBlock: defaultVPCCIDR,
130121
Region: region,
131-
UserTags: userTags,
132122
}, nil
133123
}
134124

@@ -141,7 +131,6 @@ func getCredentials() error {
141131
Help: "The AWS access key ID to use for installation (this is not your username).\nhttps://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html",
142132
},
143133
},
144-
"",
145134
)
146135
if err != nil {
147136
return err
@@ -155,7 +144,6 @@ func getCredentials() error {
155144
Help: "The AWS secret access key corresponding to your access key ID (this is not your password).",
156145
},
157146
},
158-
"",
159147
)
160148
if err != nil {
161149
return err

pkg/asset/installconfig/basedomain.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ func (a *baseDomain) Generate(asset.Parents) error {
3131
return validate.DomainName(ans.(string))
3232
}),
3333
},
34-
"OPENSHIFT_INSTALL_BASE_DOMAIN",
3534
)
3635
a.BaseDomain = bd
3736
return err

pkg/asset/installconfig/clustername.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ func (a *clusterName) Generate(asset.Parents) error {
3131
return validate.DomainName(ans.(string))
3232
}),
3333
},
34-
"OPENSHIFT_INSTALL_CLUSTER_NAME",
3534
)
3635
a.ClusterName = n
3736
return err

pkg/asset/installconfig/emailaddress.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ func (a *emailAddress) Generate(asset.Parents) error {
3131
return validate.Email(ans.(string))
3232
}),
3333
},
34-
"OPENSHIFT_INSTALL_EMAIL_ADDRESS",
3534
)
3635
a.EmailAddress = email
3736
return err

pkg/asset/installconfig/libvirt/libvirt.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"context"
66
"fmt"
77
"net/url"
8-
"os"
98

109
"github.com/pkg/errors"
1110
survey "gopkg.in/AlecAivazis/survey.v1"
@@ -32,23 +31,14 @@ func Platform() (*libvirt.Platform, error) {
3231
},
3332
Validate: survey.ComposeValidators(survey.Required, uriValidator),
3433
},
35-
"OPENSHIFT_INSTALL_LIBVIRT_URI",
3634
)
3735
if err != nil {
3836
return nil, err
3937
}
4038

41-
qcowImage, ok := os.LookupEnv("OPENSHIFT_INSTALL_LIBVIRT_IMAGE")
42-
if ok {
43-
err = validURI(qcowImage)
44-
if err != nil {
45-
return nil, errors.Wrap(err, "resolve OPENSHIFT_INSTALL_LIBVIRT_IMAGE")
46-
}
47-
} else {
48-
qcowImage, err = rhcos.QEMU(context.TODO(), rhcos.DefaultChannel)
49-
if err != nil {
50-
return nil, errors.Wrap(err, "failed to fetch QEMU image URL")
51-
}
39+
qcowImage, err := rhcos.QEMU(context.TODO(), rhcos.DefaultChannel)
40+
if err != nil {
41+
return nil, errors.Wrap(err, "failed to fetch QEMU image URL")
5242
}
5343

5444
return &libvirt.Platform{

pkg/asset/installconfig/openstack/openstack.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ func Platform() (*openstack.Platform, error) {
150150
return nil
151151
}),
152152
},
153-
"OPENSHIFT_INSTALL_OPENSTACK_CLOUD",
154153
)
155154
if err != nil {
156155
return nil, err
@@ -178,7 +177,6 @@ func Platform() (*openstack.Platform, error) {
178177
return nil
179178
}),
180179
},
181-
"OPENSHIFT_INSTALL_OPENSTACK_REGION",
182180
)
183181
if err != nil {
184182
return nil, err
@@ -206,7 +204,6 @@ func Platform() (*openstack.Platform, error) {
206204
return nil
207205
}),
208206
},
209-
"OPENSHIFT_INSTALL_OPENSTACK_IMAGE",
210207
)
211208
if err != nil {
212209
return nil, err
@@ -233,7 +230,6 @@ func Platform() (*openstack.Platform, error) {
233230
return nil
234231
}),
235232
},
236-
"OPENSHIFT_INSTALL_OPENSTACK_EXTERNAL_NETWORK",
237233
)
238234
if err != nil {
239235
return nil, errors.Wrapf(err, "failed to Marshal %s platform", openstack.Name)

pkg/asset/installconfig/platform.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,5 @@ func (a *platform) queryUserForPlatform() (string, error) {
8080
return nil
8181
}),
8282
},
83-
"OPENSHIFT_INSTALL_PLATFORM",
8483
)
8584
}

pkg/asset/installconfig/pullsecret.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (a *pullSecret) Dependencies() []asset.Asset {
2020

2121
// Generate queries for the pull secret from the user.
2222
func (a *pullSecret) Generate(asset.Parents) error {
23-
s, err := asset.GenerateUserProvidedAssetForPath(
23+
s, err := asset.GenerateUserProvidedAsset(
2424
a.Name(),
2525
&survey.Question{
2626
Prompt: &survey.Input{
@@ -31,8 +31,6 @@ func (a *pullSecret) Generate(asset.Parents) error {
3131
return validate.JSON([]byte(ans.(string)))
3232
}),
3333
},
34-
"OPENSHIFT_INSTALL_PULL_SECRET",
35-
"OPENSHIFT_INSTALL_PULL_SECRET_PATH",
3634
)
3735
a.PullSecret = s
3836
return err

pkg/asset/installconfig/ssh.go

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,38 +47,21 @@ func readSSHKey(path string) (string, error) {
4747

4848
// Generate generates the SSH public key asset.
4949
func (a *sshPublicKey) Generate(asset.Parents) error {
50-
if value, ok := os.LookupEnv("OPENSHIFT_INSTALL_SSH_PUB_KEY"); ok {
51-
if value != "" {
52-
if err := validate.SSHPublicKey(value); err != nil {
53-
return errors.Wrap(err, "failed to validate public key")
54-
}
55-
}
56-
a.Key = value
57-
return nil
50+
pubKeys := map[string]string{
51+
none: "",
5852
}
59-
60-
pubKeys := map[string]string{}
61-
if path, ok := os.LookupEnv("OPENSHIFT_INSTALL_SSH_PUB_KEY_PATH"); ok {
62-
key, err := readSSHKey(path)
53+
home := os.Getenv("HOME")
54+
if home != "" {
55+
paths, err := filepath.Glob(filepath.Join(home, ".ssh", "*.pub"))
6356
if err != nil {
64-
return errors.Wrap(err, "failed to read public key file")
57+
return errors.Wrap(err, "failed to glob for public key files")
6558
}
66-
pubKeys[path] = key
67-
} else {
68-
pubKeys[none] = ""
69-
home := os.Getenv("HOME")
70-
if home != "" {
71-
paths, err := filepath.Glob(filepath.Join(home, ".ssh", "*.pub"))
59+
for _, path := range paths {
60+
key, err := readSSHKey(path)
7261
if err != nil {
73-
return errors.Wrap(err, "failed to glob for public key files")
74-
}
75-
for _, path := range paths {
76-
key, err := readSSHKey(path)
77-
if err != nil {
78-
continue
79-
}
80-
pubKeys[path] = key
62+
continue
8163
}
64+
pubKeys[path] = key
8265
}
8366
}
8467

pkg/asset/userprovided.go

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,13 @@
11
package asset
22

33
import (
4-
"io/ioutil"
5-
"os"
6-
74
"github.com/pkg/errors"
85
survey "gopkg.in/AlecAivazis/survey.v1"
96
)
107

118
// GenerateUserProvidedAsset queries for input from the user.
12-
func GenerateUserProvidedAsset(inputName string, question *survey.Question, envVarName string) (string, error) {
13-
return generateUserProvidedAsset(inputName, question, envVarName, "")
14-
}
15-
16-
// GenerateUserProvidedAssetForPath queries for input from the user. The input can
17-
// be read from a file specified in an environment variable.
18-
func GenerateUserProvidedAssetForPath(inputName string, question *survey.Question, envVarName, pathEnvVarName string) (string, error) {
19-
return generateUserProvidedAsset(inputName, question, envVarName, pathEnvVarName)
20-
}
21-
22-
func generateUserProvidedAsset(inputName string, question *survey.Question, envVarName, pathEnvVarName string) (response string, err error) {
23-
defer func() {
24-
if err != nil {
25-
err = errors.Wrapf(err, "failed to acquire user-provided input %s", inputName)
26-
}
27-
}()
28-
29-
if value, ok := os.LookupEnv(envVarName); ok {
30-
response = value
31-
} else if path, ok := os.LookupEnv(pathEnvVarName); ok {
32-
value, err := ioutil.ReadFile(path)
33-
if err != nil {
34-
return "", errors.Wrapf(err, "failed to read file from %s", pathEnvVarName)
35-
}
36-
response = string(value)
37-
}
38-
39-
if response == "" {
40-
if err := survey.Ask([]*survey.Question{question}, &response); err != nil {
41-
return "", errors.Wrap(err, "failed to Ask")
42-
}
43-
} else if question.Validate != nil {
44-
if err := question.Validate(response); err != nil {
45-
return "", errors.Wrap(err, "validation failed")
46-
}
47-
}
48-
49-
return response, nil
9+
func GenerateUserProvidedAsset(inputName string, question *survey.Question) (string, error) {
10+
var response string
11+
err := survey.Ask([]*survey.Question{question}, &response)
12+
return response, errors.Wrapf(err, "failed to acquire user-provided input %s", inputName)
5013
}

0 commit comments

Comments
 (0)