Skip to content

Commit

Permalink
Show status of fargate profile when get fargateprofile command is cal…
Browse files Browse the repository at this point in the history
…led.

Issue #2845
  • Loading branch information
hvydya committed Dec 1, 2020
1 parent 4ea3040 commit ac43445
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
3 changes: 3 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,9 @@ type FargateProfile struct {
// Used to tag the AWS resources
// +optional
Tags map[string]string `json:"tags,omitempty"`

// The current status of the Fargate profile.
Status string `json:"status"`
}

// FargateProfileSelector defines rules to select workload to schedule onto Fargate.
Expand Down
1 change: 1 addition & 0 deletions pkg/fargate/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ func toFargateProfile(in *eks.FargateProfile) *api.FargateProfile {
PodExecutionRoleARN: strings.EmptyIfNil(in.PodExecutionRoleArn),
Subnets: strings.ToValuesArray(in.Subnets),
Tags: strings.ToValuesMap(in.Tags),
Status: *in.Status,
}
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/fargate/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ func createProfileWithoutTag() *api.FargateProfile {
},
},
},
Status: "ACTIVE",
}
}

Expand Down Expand Up @@ -350,6 +351,7 @@ func apiFargateProfile(name string) *api.FargateProfile {
},
Subnets: []string{},
Tags: map[string]string{},
Status: "ACTIVE",
}
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/fargate/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type row struct {
Subnets []string
Selector api.FargateProfileSelector
Tags map[string]string
Status string
}

func toTable(profiles []*api.FargateProfile) []*row {
Expand All @@ -47,6 +48,7 @@ func toTable(profiles []*api.FargateProfile) []*row {
Subnets: profile.Subnets,
Selector: selector,
Tags: profile.Tags,
Status: profile.Status,
})
}
}
Expand Down Expand Up @@ -75,4 +77,7 @@ func addFargateProfileColumns(printer *printers.TablePrinter) {
printer.AddColumn("TAGS", func(r *row) string {
return labels.FormatLabels(r.Tags)
})
printer.AddColumn("STATUS", func(r *row) string {
return r.Status
})
}
18 changes: 12 additions & 6 deletions pkg/fargate/print_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ var _ = Describe("fargate", func() {
})
})

const expectedTable = `NAME SELECTOR_NAMESPACE SELECTOR_LABELS POD_EXECUTION_ROLE_ARN SUBNETS TAGS
fp-prod prod env=prod arn:aws:iam::123:role/root subnet-prod,subnet-d34dc0w <none>
fp-test default <none> arn:aws:iam::123:role/root <none> app=my-app,env=test
fp-test kube-system app=my-app,env=test arn:aws:iam::123:role/root <none> app=my-app,env=test
const expectedTable = `NAME SELECTOR_NAMESPACE SELECTOR_LABELS POD_EXECUTION_ROLE_ARN SUBNETS TAGS STATUS
fp-prod prod env=prod arn:aws:iam::123:role/root subnet-prod,subnet-d34dc0w <none> ACTIVE
fp-test default <none> arn:aws:iam::123:role/root <none> app=my-app,env=test ACTIVE
fp-test kube-system app=my-app,env=test arn:aws:iam::123:role/root <none> app=my-app,env=test ACTIVE
`

const expectedYAML = `- name: fp-test
Expand All @@ -60,6 +60,7 @@ const expectedYAML = `- name: fp-test
env: test
namespace: kube-system
- namespace: default
status: ACTIVE
tags:
app: my-app
env: test
Expand All @@ -69,6 +70,7 @@ const expectedYAML = `- name: fp-test
- labels:
env: prod
namespace: prod
status: ACTIVE
subnets:
- subnet-prod
- subnet-d34dc0w
Expand All @@ -93,7 +95,8 @@ const expectedJSON = `[
"tags": {
"app": "my-app",
"env": "test"
}
},
"status": "ACTIVE"
},
{
"name": "fp-prod",
Expand All @@ -109,7 +112,8 @@ const expectedJSON = `[
"subnets": [
"subnet-prod",
"subnet-d34dc0w"
]
],
"status": "ACTIVE"
}
]`

Expand All @@ -134,6 +138,7 @@ func sampleProfiles() []*api.FargateProfile {
"app": "my-app",
"env": "test",
},
Status: "ACTIVE",
},
{
Name: "fp-prod",
Expand All @@ -147,6 +152,7 @@ func sampleProfiles() []*api.FargateProfile {
},
},
PodExecutionRoleARN: "arn:aws:iam::123:role/root",
Status: "ACTIVE",
},
}
}

0 comments on commit ac43445

Please sign in to comment.