Skip to content

Commit

Permalink
Add check for empty string as os-family is not applicable for all use…
Browse files Browse the repository at this point in the history
…rs of shared library
  • Loading branch information
Richa Gangwar committed Nov 27, 2023
1 parent 0bab10f commit 6b9a4c6
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions ecs-agent/api/ecs/client/ecs_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,15 +438,25 @@ func validateRegisteredAttributes(expectedAttributes, actualAttributes []*ecsmod
}

func (client *ecsClient) getAdditionalAttributes() []*ecsmodel.Attribute {
attrs := []*ecsmodel.Attribute{
{
var attrs []*ecsmodel.Attribute

// Add a check to ensure only non-empty values are added
// to API call.
if client.configAccessor.OSType() != "" {
attrs = append(attrs, &ecsmodel.Attribute{
Name: aws.String(osTypeAttrName),
Value: aws.String(client.configAccessor.OSType()),
},
{
})
}

// OSFamily should be treated as an optional field as it is not applicable for all agents
// using ecs client shared library. Add a check to ensure only non-empty values are added
// to API call.
if client.configAccessor.OSFamily() != "" {
attrs = append(attrs, &ecsmodel.Attribute{
Name: aws.String(osFamilyAttrName),
Value: aws.String(client.configAccessor.OSFamily()),
},
})
}
// Send CPU arch attribute directly when running on external capacity. When running on EC2 or Fargate launch type,
// this is not needed since the CPU arch is reported via instance identity document in those cases.
Expand Down

0 comments on commit 6b9a4c6

Please sign in to comment.