diff --git a/resources/eks-fargate.go b/resources/eks-fargate-profile.go similarity index 65% rename from resources/eks-fargate.go rename to resources/eks-fargate-profile.go index 489397a4..ae8f1db5 100644 --- a/resources/eks-fargate.go +++ b/resources/eks-fargate-profile.go @@ -2,6 +2,8 @@ package resources import ( "context" + "github.com/sirupsen/logrus" + "time" "fmt" @@ -71,10 +73,21 @@ func (l *EKSFargateProfileLister) List(_ context.Context, o interface{}) ([]reso } for _, name := range resp.FargateProfileNames { + profResp, err := svc.DescribeFargateProfile(&eks.DescribeFargateProfileInput{ + ClusterName: clusterName, + FargateProfileName: name, + }) + if err != nil { + logrus.WithError(err).Error("unable to describe fargate profile") + continue + } + resources = append(resources, &EKSFargateProfile{ - svc: svc, - name: name, - cluster: clusterName, + svc: svc, + Name: name, + Cluster: clusterName, + CreatedAt: profResp.FargateProfile.CreatedAt, + Tags: profResp.FargateProfile.Tags, }) } @@ -91,25 +104,25 @@ func (l *EKSFargateProfileLister) List(_ context.Context, o interface{}) ([]reso } type EKSFargateProfile struct { - svc *eks.EKS - cluster *string - name *string + svc *eks.EKS + Cluster *string + Name *string + CreatedAt *time.Time + Tags map[string]*string } -func (fp *EKSFargateProfile) Remove(_ context.Context) error { - _, err := fp.svc.DeleteFargateProfile(&eks.DeleteFargateProfileInput{ - ClusterName: fp.cluster, - FargateProfileName: fp.name, +func (r *EKSFargateProfile) Remove(_ context.Context) error { + _, err := r.svc.DeleteFargateProfile(&eks.DeleteFargateProfileInput{ + ClusterName: r.Cluster, + FargateProfileName: r.Name, }) return err } -func (fp *EKSFargateProfile) Properties() types.Properties { - return types.NewProperties(). - Set("Cluster", *fp.cluster). - Set("Profile", *fp.name) +func (r *EKSFargateProfile) Properties() types.Properties { + return types.NewPropertiesFromStruct(r) } -func (fp *EKSFargateProfile) String() string { - return fmt.Sprintf("%s:%s", *fp.cluster, *fp.name) +func (r *EKSFargateProfile) String() string { + return fmt.Sprintf("%s:%s", *r.Cluster, *r.Name) } diff --git a/resources/eks-fargate-profile_mock_test.go b/resources/eks-fargate-profile_mock_test.go new file mode 100644 index 00000000..17af377d --- /dev/null +++ b/resources/eks-fargate-profile_mock_test.go @@ -0,0 +1,20 @@ +package resources + +import ( + "github.com/gotidy/ptr" + "github.com/stretchr/testify/assert" + "testing" +) + +func TestEKSFargateProperties(t *testing.T) { + resource := &EKSFargateProfile{ + Cluster: ptr.String("test-id"), + Name: ptr.String("test-name"), + } + + properties := resource.Properties() + + assert.Equal(t, "test-id", properties.Get("Cluster")) + assert.Equal(t, "test-name", properties.Get("Name")) + assert.Equal(t, "test-id:test-name", resource.String()) +}