Skip to content

Commit

Permalink
👍 Create pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
budougumi0617 committed Aug 1, 2018
1 parent 2890e79 commit 58ad36d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 4 additions & 7 deletions main.go → cmd/main.go
Expand Up @@ -8,17 +8,14 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/external"
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
"github.com/budougumi0617/lsas"
)

var (
regionFlag string
printHeaderFlag bool
)

type tag struct {
key, value string
}

func main() {
flag.StringVar(&regionFlag, "region", "", "AWS region")
flag.StringVar(&regionFlag, "r", "", "AWS region")
Expand All @@ -44,11 +41,11 @@ func main() {
panic(err)
}

var tags []tag
var tags []lsas.Tag
for _, arg := range flag.Args() {
if strings.Contains(arg, "=") {
t := strings.Split(arg, "=")
tags = append(tags, tag{key: t[0], value: t[1]})
tags = append(tags, lsas.Tag{Key: t[0], Value: t[1]})
}
}
results := []autoscaling.Group{}
Expand Down Expand Up @@ -84,7 +81,7 @@ func main() {
var matched int
for _, astag := range asg.Tags {
for _, t := range tags {
if aws.StringValue(astag.Key) == t.key && aws.StringValue(astag.Value) == t.value {
if aws.StringValue(astag.Key) == t.Key && aws.StringValue(astag.Value) == t.Value {
// fmt.Printf("%s = %+v\n", tag2[0], aws.StringValue(tag.Value))
matched++
}
Expand Down
6 changes: 6 additions & 0 deletions lsas.go
@@ -0,0 +1,6 @@
package lsas

// Tag is AMI tag name and value.
type Tag struct {
Key, Value string
}

0 comments on commit 58ad36d

Please sign in to comment.