Skip to content

Commit 2aee60a

Browse files
authored
Fix fetching EKS AMI release archive (#112)
This changelist fixes fetching the EKS AMI release archive by removing the check for adding a `v` prefix if it does not exist. The last release published a [tag](https://github.com/awslabs/amazon-eks-ami/releases/tag/V20220123) that begins with an uppercase `V` and the code ends up prepending an additional `v`, rendering the URL incorrect. Rather than accounting for this case in code, this changelist removes that check altogether as `amazon-eks-ami` has been consistently adding the `v` prefix to their tags.
1 parent 7578114 commit 2aee60a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

pkg/selector/eks.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (e *EKS) Filters(version string) (Filters, error) {
4141
if e.AMIRepoURL == "" {
4242
e.AMIRepoURL = eksAMIRepoURL
4343
}
44-
filters := Filters{}
44+
var filters Filters
4545

4646
if version == "" {
4747
var err error
@@ -51,9 +51,6 @@ func (e *EKS) Filters(version string) (Filters, error) {
5151
version = eksFallbackLatestAMIVersion
5252
}
5353
}
54-
if !strings.HasPrefix(version, "v") {
55-
version = fmt.Sprintf("v%s", version)
56-
}
5754
supportedInstanceTypes, err := e.getSupportedInstanceTypes(version)
5855
if err != nil {
5956
log.Printf("Unable to retrieve EKS supported instance types for version %s: %v", version, err)
@@ -72,7 +69,7 @@ func (e *EKS) getSupportedInstanceTypes(version string) ([]string, error) {
7269
}
7370

7471
defer resp.Body.Close()
75-
if resp.StatusCode != 200 {
72+
if resp.StatusCode != http.StatusOK {
7673
return supportedInstanceTypes, fmt.Errorf("Unable to retrieve EKS supported instance types, got non-200 status code: %d", resp.StatusCode)
7774
}
7875

@@ -119,7 +116,7 @@ func (e EKS) getLatestAMIVersion() (string, error) {
119116
if err != nil {
120117
return "", err
121118
}
122-
if resp.StatusCode != 302 {
119+
if resp.StatusCode != http.StatusFound {
123120
return "", fmt.Errorf("Can't retrieve latest release from github because redirect was not sent")
124121
}
125122
versionRedirect := resp.Header.Get("location")

0 commit comments

Comments
 (0)