Skip to content

Commit

Permalink
Merge pull request #151 from ivanilves/NORELEASE/dev-env
Browse files Browse the repository at this point in the history
Add sample development environment initialization
  • Loading branch information
vonrabbe authored May 4, 2018
2 parents 6c6dc4b + 402373b commit 4613860
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ test: unit-test whitebox-integration-test
unit-test:
@find \
-mindepth 2 -type f ! -path "./vendor/*" ! -path "./api/*" -name "*_test.go" \
| xargs dirname \
| xargs -i dirname {} \
| xargs -i sh -c "pushd {}; go test -v -cover || exit 1; popd"

whitebox-integration-test:
@find \
-mindepth 2 -type f -path "./api/*" -name "*_test.go" \
| xargs dirname \
| xargs -i dirname {} \
| xargs -i sh -c "pushd {}; go test -v -cover || exit 1; popd"

coverage: PROJECT:=github.com/ivanilves/lstags
Expand Down Expand Up @@ -131,6 +131,15 @@ deploy-docker:
echo "NB! Docker release skipped! (DO_RELEASE != true)"; \
fi

dev-env: DST_PATH=../lstags-api
dev-env: prepare dep
dev-env:
@echo -e "\e[1mInitializing sample development environment:\e[0m" \
&& mkdir -p ${DST_PATH} \
&& cp api_usage.go.sample ${DST_PATH}/main.go \
&& pushd ${DST_PATH} >/dev/null; go build; pwd; popd >/dev/null \
&& echo -e "\e[31mHINT: Set 'DST_PATH' makefile variable to adjust environment path ;)\e[0m"

wrapper: PREFIX:=/usr/local
wrapper:
install -o root -g root -m755 scripts/wrapper.sh ${PREFIX}/bin/lstags
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,6 @@ func main() {
}
```

You may also run `make dev-env` to set up sample lstags API development environment on your system.

**NB!** Far more complete API usage example could be found in **[main.go](https://github.com/ivanilves/lstags/blob/master/main.go)** :wink:
2 changes: 1 addition & 1 deletion api/registry/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestLaunchContainerAndThanDestroyIt(t *testing.T) {
}

func TestLaunchManyContainersWithoutNamingCollisions(t *testing.T) {
const createContainers = 5
const createContainers = 3

done := make(chan error, createContainers)

Expand Down
32 changes: 32 additions & 0 deletions api_usage.go.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// vi:syntax=go

package main

import (
"fmt"

"github.com/ivanilves/lstags/api/v1"
)

func main() {
api, _ := v1.New(v1.Config{})

collection, _ := api.CollectTags(
"alpine",
"nginx=latest,stable",
"gcr.io/google_containers/pause-amd64:3.1",
"quay.io/coreos/flannel~/v0.10/",
)

for _, repo := range collection.Repos() {
for _, tag := range collection.Tags(repo.Ref()) {
fmt.Printf(
"- %-40s %-15s %s %s\n",
repo.Name(),
tag.Name(),
tag.GetCreatedString(),
tag.GetState(),
)
}
}
}

0 comments on commit 4613860

Please sign in to comment.