Skip to content

Commit

Permalink
fixup! tests: Add tests for EC2 Metadata immitation cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmood Ali committed Mar 26, 2020
1 parent 0c1dd0e commit 6199e96
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client/fingerprint/env_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (f *EnvAWSFingerprint) Fingerprint(request *FingerprintRequest, response *F

for k, unique := range keys {
resp, err := ec2meta.GetMetadata(k)
v := strings.TrimSpace(strings.Trim(resp, "\n"))
v := strings.TrimSpace(resp)
if v == "" {
f.logger.Debug("read an empty value", "attribute", k)
continue
Expand Down Expand Up @@ -219,5 +219,6 @@ func ec2MetaClient(endpoint string, timeout time.Duration) (*ec2metadata.EC2Meta

func isAWS(ec2meta *ec2metadata.EC2Metadata) bool {
v, err := ec2meta.GetMetadata("ami-id")
v = strings.TrimSpace(v)
return err == nil && v != ""
}

0 comments on commit 6199e96

Please sign in to comment.