diff --git a/Makefile b/Makefile index c440742..ce346b9 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ API_VERSION:=$(shell cat API_VERSION) .PHONY: default clean offline prepare dep test unit-test whitebox-integration-test coverage \ blackbox-integration-test shell-test-alpine shell-test-wrong-image shell-test-docker-socket shell-test-docker-tcp \ lint vet fail-on-errors docker-image build xbuild changelog release validate-release deploy deploy-github deploy-docker \ - wrapper install + poc-app wrapper install default: prepare dep test lint vet build @@ -131,14 +131,14 @@ 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" +poc-app: APP_PATH=../lstags-api +poc-app: prepare dep +poc-app: + @echo -e "\e[1mInitializing PoC application:\e[0m" \ + && mkdir -p ${APP_PATH} \ + && cp api_poc.go.sample ${APP_PATH}/main.go \ + && pushd ${APP_PATH} >/dev/null; go build; pwd; popd >/dev/null \ + && echo -e "\e[31mHINT: Set 'APP_PATH' makefile variable to adjust PoC application path ;)\e[0m" wrapper: PREFIX:=/usr/local wrapper: diff --git a/README.md b/README.md index 7b9216d..d3cf071 100644 --- a/README.md +++ b/README.md @@ -184,42 +184,18 @@ For the most cases it is OK. However, if you work with things that do not need t ## API -You may use `lstags` either as a standalone CLI or as a Golang package inside your own application: - -### PoC application with our `v1` API -```golang -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(), - ) - } - } -} -``` - -You may also run `make dev-env` to set up sample lstags API development environment on your system. +You may use lstags either as a standalone CLI or as a Golang package inside your own application. + +#### Set up and build PoC application with our `v1` API: + +```sh +make poc-app APP_PATH=../lstags-api +cd ../lstags-api +go build +# run "./lstags-api" binary to see PoC in action (examine main.go first to ensure no "rm -rf /" is there) +``` + +* This installs all necessary dependencies and sets up PoC application at the path `../lstags-api/` +* We assume you already have recent Golang version installed on your system https://golang.org/dl/ **NB!** Far more complete API usage example could be found in **[main.go](https://github.com/ivanilves/lstags/blob/master/main.go)** :wink: diff --git a/api_usage.go.sample b/api_poc.go.sample similarity index 100% rename from api_usage.go.sample rename to api_poc.go.sample