Skip to content

Commit 1838f37

Browse files
author
Chris Gilmer
committed
Merge master
2 parents 6f5ee5e + ef67a1b commit 1838f37

File tree

2 files changed

+5
-52
lines changed

2 files changed

+5
-52
lines changed

cmd/setup.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -549,16 +549,6 @@ func openQrCode(tempFile *os.File) error {
549549
return nil
550550
}
551551

552-
func checkExistingAWSProfile(profileName string, config *vault.ConfigFile, logger *log.Logger) error {
553-
logger.Printf("Checking whether profile %q exists in AWS config file\n", profileName)
554-
_, exists := config.ProfileSection(profileName)
555-
if exists {
556-
return fmt.Errorf("Profile already exists in AWS config file: %s", profileName)
557-
}
558-
559-
return nil
560-
}
561-
562552
func getPartition(region string) (string, error) {
563553
partition, ok := endpoints.PartitionForRegion(endpoints.DefaultPartitions(), region)
564554
if !ok {
@@ -677,14 +667,6 @@ func setupUserFunction(cmd *cobra.Command, args []string) error {
677667
Keyring: keyring,
678668
NoMFA: noMFA,
679669
}
680-
err = checkExistingAWSProfile(baseProfile.Name, config, logger)
681-
if err != nil {
682-
logger.Fatal(err)
683-
}
684-
err = checkExistingAWSProfile(roleProfile.Name, config, logger)
685-
if err != nil {
686-
logger.Fatal(err)
687-
}
688670
setupConfig.Setup()
689671

690672
// If we got this far, we win

cmd/setup_test.go

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ import (
1313
// Test logger
1414
var logger = log.New(os.Stdout, "", log.LstdFlags)
1515

16-
var defaultConfig = []byte(`[profile test]
17-
region=us-west-2
18-
output=json
19-
`)
20-
2116
func newConfigFile(t *testing.T, b []byte) string {
2217
f, err := ioutil.TempFile("", "aws-config")
2318
if err != nil {
@@ -29,36 +24,12 @@ func newConfigFile(t *testing.T, b []byte) string {
2924
return f.Name()
3025
}
3126

32-
func TestExistingAWSProfile(t *testing.T) {
33-
f := newConfigFile(t, defaultConfig)
34-
defer func() {
35-
errRemove := os.Remove(f)
36-
assert.NoError(t, errRemove)
37-
}()
38-
config, _ := vault.LoadConfig(f)
39-
baseProfile := vault.ProfileSection{
40-
Name: "test",
41-
Region: "us-west-2",
42-
}
43-
keyring, err := getKeyring("test")
44-
assert.NoError(t, err)
45-
setupConfig := SetupConfig{
46-
Logger: logger,
47-
Name: "test",
48-
BaseProfile: &baseProfile,
49-
Output: "json",
50-
Config: config,
51-
QrTempFile: nil,
52-
Keyring: keyring,
53-
}
54-
55-
err = checkExistingAWSProfile(baseProfile.Name, setupConfig.Config, logger)
56-
assert.Error(t, err)
57-
err = checkExistingAWSProfile("missing", setupConfig.Config, logger)
58-
assert.NoError(t, err)
59-
}
60-
6127
func TestUpdateAWSConfigFile(t *testing.T) {
28+
29+
var defaultConfig = []byte(`[profile test]
30+
region=us-west-2
31+
output=json
32+
`)
6233
f := newConfigFile(t, defaultConfig)
6334
defer func() {
6435
errRemove := os.Remove(f)

0 commit comments

Comments
 (0)