Skip to content

Commit

Permalink
docs(api/v1): Update PoC application instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanilves committed May 5, 2018
1 parent 07f3063 commit f812507
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 46 deletions.
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
50 changes: 13 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
File renamed without changes.

0 comments on commit f812507

Please sign in to comment.