commit
f55e41bb1d
|
@ -1,6 +1,10 @@
|
|||
package aws
|
||||
|
||||
import "github.com/cloudskiff/driftctl/pkg/resource"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cloudskiff/driftctl/pkg/resource"
|
||||
)
|
||||
|
||||
func (r *AwsIamAccessKey) NormalizeForState() (resource.Resource, error) {
|
||||
// As we can't read secrets from aws API once access_key created we need to set
|
||||
|
@ -14,3 +18,10 @@ func (r *AwsIamAccessKey) NormalizeForState() (resource.Resource, error) {
|
|||
func (r *AwsIamAccessKey) NormalizeForProvider() (resource.Resource, error) {
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func (r *AwsIamAccessKey) String() string {
|
||||
if r.User == nil {
|
||||
return r.TerraformId()
|
||||
}
|
||||
return fmt.Sprintf("%s (User: %s)", r.TerraformId(), *r.User)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
)
|
||||
|
||||
func TestAwsIamAccessKey_String(t *testing.T) {
|
||||
tests := []struct {
|
||||
user string
|
||||
access AwsIamAccessKey
|
||||
want string
|
||||
}{
|
||||
{user: "test iam access key stringer with user and id",
|
||||
access: AwsIamAccessKey{
|
||||
User: aws.String("test_user"),
|
||||
Id: "AKIA2SIQ53JH4CMB42VB",
|
||||
},
|
||||
want: "AKIA2SIQ53JH4CMB42VB (User: test_user)",
|
||||
},
|
||||
{user: "test iam access key stringer without user",
|
||||
access: AwsIamAccessKey{
|
||||
User: nil,
|
||||
Id: "AKIA2SIQ53JH4CMB42VB",
|
||||
},
|
||||
want: "AKIA2SIQ53JH4CMB42VB",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.user, func(t *testing.T) {
|
||||
if got := tt.access.String(); got != tt.want {
|
||||
t.Errorf("String() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue