Skip to content

Commit

Permalink
Remove omitempty and fix test
Browse files Browse the repository at this point in the history
Signed-off-by: James Relph <[email protected]>
  • Loading branch information
jprelph committed Dec 16, 2021
1 parent caac957 commit 355581a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion commands/out.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (o *Out) Execute() error {

src := o.args[1]

if (req.Source.AwsAccessKeyId != "" && req.Source.AwsSecretAccessKey != "" && req.Source.AwsRegion != "") || (req.Source.AwsRegion != "" && req.Source.AwsUseInstanceRole == true) {
if (req.Source.AwsAccessKeyId != "" && req.Source.AwsSecretAccessKey != "" && req.Source.AwsRegion != "") || (req.Source.AwsRegion != "" && req.Source.AwsUseInstanceRole) {
if !req.Source.AuthenticateToECR() {
return fmt.Errorf("cannot authenticate with ECR")
}
Expand Down
4 changes: 2 additions & 2 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type AwsCredentials struct {
AWSECRRegistryId string `json:"aws_ecr_registry_id,omitempty"`
AwsRoleArn string `json:"aws_role_arn,omitempty"`
AwsRoleArns []string `json:"aws_role_arns,omitempty"`
AwsUseInstanceRole bool `json:"aws_use_instance_role,omitempty"`
AwsUseInstanceRole bool `json:"aws_use_instance_role"`
}

type BasicCredentials struct {
Expand Down Expand Up @@ -306,7 +306,7 @@ func (source *Source) AuthenticateToECR() bool {
}))

// Override mySession if aws_use_instance_role is set
if source.AwsUseInstanceRole == true {
if source.AwsUseInstanceRole {
mySession = session.Must(session.NewSession(&aws.Config{
Region: aws.String(source.AwsRegion)}))
}
Expand Down
2 changes: 1 addition & 1 deletion types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var _ = Describe("Source", func() {
json, err := json.Marshal(source)
Expect(err).ToNot(HaveOccurred())

Expect(json).To(MatchJSON(`{"repository":"foo","insecure":false,"tag":"0"}`))
Expect(json).To(MatchJSON(`{"repository":"foo","insecure":false,"tag":"0", "aws_use_instance_role":false}`))
})

Describe("ecr", func() {
Expand Down

0 comments on commit 355581a

Please sign in to comment.