Skip to content

Commit

Permalink
Re-organised files and new build
Browse files Browse the repository at this point in the history
  • Loading branch information
hamstah committed Jan 25, 2018
1 parent d5ce33c commit 0a2dde4
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin/
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.1
9 changes: 0 additions & 9 deletions build.sh

This file was deleted.

File renamed without changes.
10 changes: 6 additions & 4 deletions ec2/ec2-ip-from-name/main.go → ec2/ip-from-name/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
func main() {

instanceName := flag.String("name", "", "Name of the EC2 instance")
maxResults := flag.Int("max-results", 1, "Number of results")

maxResults := flag.Int("max-results", 9, "Number of results")
region := flag.String("region", "eu-west-1", "AWS region")
flag.Parse()

Expand Down Expand Up @@ -44,10 +44,12 @@ func main() {
fmt.Println(err.Error())
os.Exit(3)
}
ips := make([]string, len(resp.Reservations))
for index, reservation := range resp.Reservations {
ips := []string{}
for _, reservation := range resp.Reservations {
instance := reservation.Instances[0]
ips[index] = *instance.PrivateIpAddress
if instance != nil {
ips = append(ips, *instance.PrivateIpAddress)
}
}

sort.Strings(ips)
Expand Down
47 changes: 47 additions & 0 deletions ecs/run-task/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package main

import (
"flag"
"fmt"
"os"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ecs"
)

func main() {

taskDefinitionName := flag.String("task-definition", "", "Task definition name")
clusterName := flag.String("cluster-name", "", "Cluster name")
region := flag.String("region", "eu-west-1", "AWS region")
flag.Parse()

if len(*taskDefinitionName) < 1 {
fmt.Println("Missing task definition name")
os.Exit(1)
}

if len(*clusterName) < 1 {
fmt.Println("Missing cluster name")
os.Exit(1)
}


config := aws.Config{Region: aws.String(*region)}
session := session.New(&config)

svc := ecs.New(session)

params := &ecs.RunTaskInput{
TaskDefinition: aws.String(*taskDefinitionName),
Cluster: aws.String(*clusterName),
Count: aws.Int64(1),
}
_, err := svc.RunTask(params)

if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -e

base=$(dirname $0)/..

mkdir -p ${base}/bin

echo "Building"
find ${base} -name "main.go" | while read src; do
src=$(realpath --relative-to=${base} ${src})
name=bin/$(echo ${src} | awk -F/ '{print $1"-"$2}')
echo " ${name}"
CGO_ENABLED=0 go build -installsuffix cgo -o ${base}/${name} ${src}
gpg --armor --detach-sig ${base}/${name}
done

0 comments on commit 0a2dde4

Please sign in to comment.