Skip to content

Commit 7fb8ad8

Browse files
committed
Allow custom tags for instance lane and name
1 parent 940e646 commit 7fb8ad8

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ behavior:
102102
``$LANES_CONFIG_DIR/lanes.yml``
103103
* ``LANES_REGION``: the AWS region to use when listing EC2 instances. Default:
104104
``us-west-2``
105+
* ``LANES_LANE_TAG``: the EC2 instance tag to use for determining which lane an
106+
instance belongs to. Default: ``Lane``
107+
* ``LANES_NAME_TAG``: the EC2 instance tag to use for determining an instance's
108+
name. Default: ``Name``
105109
106110
## Usage
107111

config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ var (
1818

1919
// REGION is the default region to use for any profile that doesn't have a region explicitly set.
2020
REGION = EnvDefault("LANES_REGION", "us-west-2")
21+
22+
// LANE_TAG is the name of the EC2 tag to use when determining which lane a server belongs in.
23+
LANE_TAG = EnvDefault("LANES_LANE_TAG", "Lane")
24+
25+
// NAME_TAG is the name of the EC2 tag to use when determining a server's name.
26+
NAME_TAG = EnvDefault("LANES_NAME_TAG", "Name")
2127
)
2228

2329
type Config struct {

server.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"os"
77
"os/exec"
88
"sort"
9-
"strings"
109
"time"
1110

1211
"github.com/apcera/termtables"
@@ -92,7 +91,7 @@ func FetchServersInLane(svc *ec2.EC2, lane string) ([]*Server, error) {
9291
input = &ec2.DescribeInstancesInput{
9392
Filters: []*ec2.Filter{{
9493
Name: aws.String("tag-key"),
95-
Values: []*string{aws.String("Lane")},
94+
Values: []*string{aws.String(LANE_TAG)},
9695
}, {
9796
Name: aws.String("tag-value"),
9897
Values: []*string{aws.String(lane)},
@@ -132,10 +131,10 @@ func FetchServersBy(svc *ec2.EC2, input *ec2.DescribeInstancesInput) (servers []
132131
continue
133132
}
134133

135-
switch strings.ToLower(*tag.Key) {
136-
case "name":
134+
switch *tag.Key {
135+
case NAME_TAG:
137136
svr.Name = *tag.Value
138-
case "lane":
137+
case LANE_TAG:
139138
svr.Lane = *tag.Value
140139
}
141140
}

0 commit comments

Comments
 (0)