|
1 | | -// package aws contains amazon web services related actions |
2 | 1 | package aws |
3 | 2 |
|
4 | 3 | import ( |
5 | | - "strings" |
6 | | - |
7 | 4 | "github.com/carapace-sh/carapace" |
8 | | - "gopkg.in/ini.v1" |
9 | 5 | ) |
10 | 6 |
|
11 | 7 | // ActionRegions completes region names |
@@ -50,37 +46,3 @@ func ActionRegions() carapace.Action { |
50 | 46 | "us-west-2", "US West (Oregon)", |
51 | 47 | ) |
52 | 48 | } |
53 | | - |
54 | | -// ActionProfiles completes configuration profile names |
55 | | -// |
56 | | -// someprofile (eu-central-1) |
57 | | -// anotherprofile (us-east-1) |
58 | | -func ActionProfiles() carapace.Action { |
59 | | - return carapace.ActionCallback(func(c carapace.Context) carapace.Action { |
60 | | - profiles := []string{} |
61 | | - |
62 | | - // TODO support windows |
63 | | - if path, err := c.Abs("~/.aws/config"); err != nil { |
64 | | - return carapace.ActionMessage(err.Error()) |
65 | | - } else { |
66 | | - if cfg, err := ini.Load(path); err != nil { |
67 | | - return carapace.ActionMessage(err.Error()) |
68 | | - } else { |
69 | | - for _, section := range cfg.Sections() { |
70 | | - if after, ok := strings.CutPrefix(section.Name(), "profile "); ok { |
71 | | - profiles = append(profiles, after) |
72 | | - if key, err := section.GetKey("region"); err != nil { |
73 | | - profiles = append(profiles, "") |
74 | | - } else { |
75 | | - profiles = append(profiles, key.String()) |
76 | | - } |
77 | | - } |
78 | | - } |
79 | | - if len(profiles) == 0 { |
80 | | - profiles = append(profiles, "default", "") |
81 | | - } |
82 | | - return carapace.ActionValuesDescribed(profiles...) |
83 | | - } |
84 | | - } |
85 | | - }) |
86 | | -} |
0 commit comments