Skip to content

Instantly share code, notes, and snippets.

@Bowenislandsong
Created October 4, 2019 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bowenislandsong/444279ba7fd983d21481163471728615 to your computer and use it in GitHub Desktop.
Save Bowenislandsong/444279ba7fd983d21481163471728615 to your computer and use it in GitHub Desktop.
import test "github.com/openshift/windows-machine-config-operator/tools/windows-node-installer/pkg/cloudprovider/aws"
func getInstance(a *test.awsProvider, instanceID string) (*ec2.Instance, error) {
instances, err := a.EC2.DescribeInstances(&ec2.DescribeInstancesInput{
InstanceIds: aws.StringSlice([]string{instanceID}),
})
if err != nil {
return nil, err
}
if len(instances.Reservations) < 1 && len(instances.Reservations[0].Instances) < 1 {
return nil, fmt.Errorf("instance does not exist")
}
return instances.Reservations[0].Instances[0], err
}
func instanceHasName(instance *ec2.Instance) error {
for _, tag := range instance.Tags {
if *tag.Key == "Name" && tag.Value != nil {
return nil
}
}
return fmt.Errorf("instance is not assigned a name")
}
@Bowenislandsong
Copy link
Author

woo found a logic problem ... lol if len(instances.Reservations) < 1 || len(instances.Reservations[0].Instances) < 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment