Skip to content

Commit

Permalink
Merge pull request #15 from goldeneggg/new_feature
Browse files Browse the repository at this point in the history
New feature's cadidates for v0.2.7
  • Loading branch information
goldeneggg authored Mar 16, 2019
2 parents f3a1b6a + d57b44f commit ffcab3a
Show file tree
Hide file tree
Showing 30 changed files with 931 additions and 570 deletions.
19 changes: 15 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,29 @@ before:
builds:
- env:
- CGO_ENABLED=0
- GO111MODULE=on
main: ./cmd/lsec2/main.go
flags:
- -a
- -tags
- netgo
- -installsuffix
- netgo
ldflags:
- -w -s -extldflags "-static" -X github.com/goldeneggg/lsec2/cmd/lsec2/cli.BuildDate={{.Date}} -X github.com/goldeneggg/lsec2/cmd/lsec2/cli.BuildCommit={{.ShortCommit}} -X github.com/goldeneggg/lsec2/cmd/lsec2/cli.GoVersion={{.Env.GOVERSION}}
goos:
- darwin
- linux
- windows
- freebsd
- darwin
- windows
goarch:
- '386'
- amd64
- 386
ignore:
- goos: darwin
goarch: 386

- goos: windows
goarch: 386
archive:
format_overrides:
- goos: windows
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ install:
- go mod download

script:
- make ci-test
- make ci

after_success:
- bash <(curl -s https://codecov.io/bash)

deploy:
- provider: script
skip_cleanup: true
script: curl -sL http://git.io/goreleaser | bash
script: export GOVERSION=$TRAVIS_GO_VERSION && curl -sL http://git.io/goreleaser | bash
on:
tags: true
condition: $TRAVIS_OS_NAME = linux && $TRAVIS_GO_VERSION =~ ^1\.12.*
Expand Down
56 changes: 0 additions & 56 deletions CHANGELOG.md

This file was deleted.

92 changes: 36 additions & 56 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,49 +1,62 @@
NAME := lsec2
SRCS := $(shell find . -type f -name '*.go' | \grep -v 'vendor')
VERSION := $(shell ./scripts/_version.sh)
LDFLAGS := $(shell ./scripts/_ldflags.sh)
PACKAGES := $(shell ./scripts/_packages.sh)
PROF_DIR := ./.profile
PROF_TARGET := ./awsec2
GOVERSION := $(shell go version | awk '{print $$3;}')

.DEFAULT_GOAL := bin/$(NAME)

.PHONY: version
version:
@echo $(VERSION)
@echo $(shell ./scripts/_version.sh)

mod-dl:
@GO111MODULE=on go mod download

mod-tidy:
@GO111MODULE=on go mod tidy

bin/$(NAME): $(SRCS)
@./scripts/build.sh bin/$(NAME)

.PHONY: install
install:
@go install -v -ldflags='$(LDFLAGS)'
@./scripts/install.sh

.PHONY: test
test:
@go test -race -cover -v $(PACKAGES)

ci-test:
@./scripts/ci-test.sh

.PHONY: prof
prof:
@[ ! -d $(PROF_DIR) ] && mkdir $(PROF_DIR); go test -bench . -benchmem -blockprofile $(PROF_DIR)/block.out -cover -coverprofile $(PROF_DIR)/cover.out -cpuprofile $(PROF_DIR)/cpu.out -memprofile $(PROF_DIR)/mem.out $(PROF_TARGET)
@[ ! -d $(PROF_DIR) ] && mkdir $(PROF_DIR); go test -bench . -benchmem -cover -coverprofile $(PROF_DIR)/cover.out $(PACKAGES)

prof-full-awsec2:
@[ ! -d $(PROF_DIR) ] && mkdir $(PROF_DIR); go test -bench . -benchmem -blockprofile $(PROF_DIR)/block.out -cover -coverprofile $(PROF_DIR)/cover.out -cpuprofile $(PROF_DIR)/cpu.out -memprofile $(PROF_DIR)/mem.out ./awsec2

prof-full-printer:
@[ ! -d $(PROF_DIR) ] && mkdir $(PROF_DIR); go test -bench . -benchmem -blockprofile $(PROF_DIR)/block.out -cover -coverprofile $(PROF_DIR)/cover.out -cpuprofile $(PROF_DIR)/cpu.out -memprofile $(PROF_DIR)/mem.out ./printer

prof-full-cmd-cli:
@[ ! -d $(PROF_DIR) ] && mkdir $(PROF_DIR); go test -bench . -benchmem -blockprofile $(PROF_DIR)/block.out -cover -coverprofile $(PROF_DIR)/cover.out -cpuprofile $(PROF_DIR)/cpu.out -memprofile $(PROF_DIR)/mem.out ./cmd/lsec2/cli

.PHONY: vet
vet:
@go vet -n -x $(PACKAGES)
@go vet $(PACKAGES)

.PHONY: lint
lint:
@${GOBIN}/golint -set_exit_status $(PACKAGES)
@golint -set_exit_status $(PACKAGES)

.PHONY: validate
validate: vet lint

ci-test:
@./scripts/ci-test.sh

.PHONY: ci
ci: ci-test vet

.PHONY: vendor
vendor:
@GO111MODULE=on go mod vendor
Expand All @@ -55,48 +68,15 @@ lint-travis:
@travis lint --org --debug .travis.yml

test-goreleaser:
@goreleaser release --snapshot --skip-publish --rm-dist

# Duplicated tasks as follows

.PHONY: release
release:
@./scripts/release.sh

release-darwin-386:
@./scripts/release.sh darwin 386

release-darwin-amd64:
@./scripts/release.sh darwin amd64

release-linux-386:
@./scripts/release.sh linux 386

release-linux-amd64:
@./scripts/release.sh linux amd64

release-linux-arm:
@./scripts/release.sh linux arm

release-windows-386:
@./scripts/release.sh windows 386

release-windows-amd64:
@./scripts/release.sh windows amd64

release-freebsd-386:
@./scripts/release.sh freebsd 386

release-freebsd-amd64:
@./scripts/release.sh freebsd amd64

.PHONY: upload
upload:
@./scripts/upload.sh

.PHONY: formula
formula:
@./scripts/upload.sh formula-only

.PHONY: publish
publish: release upload
@GOVERSION=$(GOVERSION) goreleaser release --snapshot --skip-publish --rm-dist

ci-goreleaser:
@export GOVERSION=$(GOVERSION) && curl -sL http://git.io/goreleaser | bash -s -- release --snapshot --skip-publish --rm-dist

.PHONY: clean
clean:
@go clean $(PACKAGES)
@rm -f bin/$(NAME)
@rm -fr dist pkg
@find . -name '*.test' -delete
@rm -fr $(PROF_DIR)
74 changes: 54 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
lsec2
==========

List view of aws ec2 instances
# lsec2

[![Build Status](https://travis-ci.org/goldeneggg/lsec2.svg?branch=master)](https://travis-ci.org/goldeneggg/lsec2)
[![GolangCI](https://golangci.com/badges/github.com/goldeneggg/gat.svg)](https://golangci.com/r/github.com/goldeneggg/lsec2)
[![Go Report Card](https://goreportcard.com/badge/github.com/goldeneggg/lsec2)](https://goreportcard.com/report/github.com/goldeneggg/lsec2)
[![GolangCI](https://golangci.com/badges/github.com/goldeneggg/gat.svg)](https://golangci.com/r/github.com/goldeneggg/lsec2)
[![Codecov](https://codecov.io/github/goldeneggg/lsec2/coverage.svg?branch=master)](https://codecov.io/github/goldeneggg/lsec2?branch=master)
[![MIT License](http://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/goldeneggg/lsec2/blob/master/LICENSE)

List view of AWS EC2 instances.

Example as follows.

```sh
$ lsec2 -H
```
```
INSTANCE_ID PRIVATE_IP PUBLIC_IP TYPE STATE TAGS
i-0xxxxxxxxxxxxxx1 172.111.111.111 54.111.111.111 t2.micro running TagA=ValueA,TagB=ValueB
i-0xxxxxxxxxxxxxx2 172.222.222.222 54.222.222.222 t2.medium running TagAA=ValueAA
i-0xxxxxxxxxxxxxx3 172.333.333.333 54.333.333.333 t1.large stopped
```

## Install

### Using Homebrew for OS X
Expand Down Expand Up @@ -42,7 +53,25 @@ Download from [latest release](https://github.com/goldeneggg/lsec2/releases/late

## Configuration

### Set environment variables
### Create `~/.aws/credentials` file
__If you have already installed [aws\-cli](https://github.com/aws/aws-cli), I recommend setting up by `aws configure` command.__

Write your credential information in `~/.aws/credentials` file.

* Write a section
* Default is `[default]`. It's known as "Profile".
* Write `aws_access_key_id` in your section
* Write `aws_secret_access_key` in your section

```ini
[default]
aws_access_key_id = YOUR_ACCESS_KEY_ID
aws_secret_access_key = YOUR_SECRET_ACCESS_KEY
```

More information: [session \- Amazon Web Services \- Go SDK](http://docs.aws.amazon.com/sdk-for-go/api/aws/session/)

### Or Set environment variables

2 variables are required

Expand All @@ -51,20 +80,22 @@ $ export AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY_ID
$ export AWS_SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEY
```

### Or create `~/.aws/credentials` file
Write your credential information in `~/.aws/credentials` file

* Write a `[default]` section
* Write `aws_access_key_id` in `[default]` section
* Write `aws_secret_access_key` in `[default]` section
### Change runtime profile
Use `--profile` option

```ini
[default]
aws_access_key_id = YOUR_ACCESS_KEY_ID
aws_secret_access_key = YOUR_SECRET_ACCESS_KEY
```

More information: [session \- Amazon Web Services \- Go SDK](http://docs.aws.amazon.com/sdk-for-go/api/aws/session/)
[test]
aws_access_key_id = YOUR_ACCESS_KEY_ID2
aws_secret_access_key = YOUR_SECRET_ACCESS_KEY2
```
```sh
$ lsec2 # use "default" profile
$ lsec2 --profile test # use "test" profile
```

## Usage

Expand Down Expand Up @@ -94,12 +125,6 @@ You can use 3 patterns
$ lsec2 --region ap-northeast-1
```

* set `AWS_REGION` environment

```sh
$ export AWS_REGION=ap-northeast-1
```

* set `AWS_SDK_LOAD_CONFIG` environment, and write `region` key in `~/.aws/config` file

```sh
Expand All @@ -112,6 +137,12 @@ $ vi ~/.aws/config
region = ap-northeast-1
```

* set `AWS_REGION` environment

```sh
$ export AWS_REGION=ap-northeast-1
```

Show more information from public AWS documents

* [SDK Configuration — Developer Guide](https://docs.aws.amazon.com/sdk-for-go/v1/developerguide/configuring-sdk.html)
Expand Down Expand Up @@ -147,6 +178,9 @@ $ lsec2 -p
# print state with color
# ("running" is green, "stopped" is red, and others are yellow)
$ lsec2 -c

# change column delimiter (default delimiter is TAB)
$ lsec2 -d ,
```

## Tips
Expand Down
Loading

0 comments on commit ffcab3a

Please sign in to comment.