Created
October 4, 2019 15:50
-
-
Save Bowenislandsong/444279ba7fd983d21481163471728615 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
woo found a logic problem ... lol if len(instances.Reservations) < 1 || len(instances.Reservations[0].Instances) < 1