Skip to content

Commit 8549684

Browse files
authored
Merge pull request #9 from areed/areed/ch568/vendor-cli-release
generate docs
2 parents faee1a4 + ac6ba8d commit 8549684

File tree

2,977 files changed

+941363
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,977 files changed

+941363
-73
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
dist/
22
.glide
3+
gen/docs

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
language: go
22
go: 1.8.3
3-
install:
4-
- make build
53
script:
4+
- make build
65
- make test
6+
after_success:
7+
- test -n "$TRAVIS_TAG" && make package_docker_docs
8+
- test -n "$TRAVIS_TAG" && curl -sL https://git.io/goreleaser | bash

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.PHONY: docs
2+
13
API_PKGS=apps channels releases
24

35
docker:
@@ -58,3 +60,12 @@ release:
5860
--volume `pwd`:/go/src/github.com/replicatedhq/replicated \
5961
--env GITHUB_TOKEN=${GITHUB_TOKEN} \
6062
replicatedhq.replicated goreleaser
63+
64+
docs:
65+
go run docs/generate.go --path ./gen/docs
66+
67+
package_docker_docs: docs
68+
docker login -p $(QUAY_PASS) -u $(QUAY_USER) quay.io
69+
docker build -t quay.io/replicatedcom/vendor-cli-docs:release -f docs/Dockerfile .
70+
docker push quay.io/replicatedcom/vendor-cli-docs:release
71+
docker rmi -f quay.io/replicatedcom/vendor-cli-docs:release

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
This repository provides a client and CLI for interacting with the Replicated Vendor API.
44
The models are generated from the API's swagger spec.
55

6+
## CLI
7+
68
Grab the latest [release](https://github.com/replicatedhq/replicated/releases) and extract it to your path.
79

810
```
@@ -13,12 +15,52 @@ Set the following env vars to avoid passing them as arguments to each command.
1315
* REPLICATED_APP_SLUG
1416
* REPLICATED_API_TOKEN
1517

18+
## Client
19+
20+
(GoDoc)[https://godoc.org/github.com/replicatedhq/replicated/client]
21+
22+
```golang
23+
package main
24+
25+
import (
26+
"fmt"
27+
"log"
28+
"os"
29+
30+
"github.com/replicatedhq/replicated/client"
31+
)
32+
33+
func main() {
34+
token := os.Getenv("REPLICATED_API_TOKEN")
35+
appSlug := os.Getenv("REPLICATED_APP_SLUG")
36+
37+
api := client.New(token)
38+
39+
app, err := api.GetAppBySlug(appSlug)
40+
if err != nil {
41+
log.Fatal(err)
42+
}
43+
44+
channels, err := api.ListChannels(app.Id)
45+
if err != nil {
46+
log.Fatal(err)
47+
}
48+
for _, c := range channels {
49+
fmt.Printf("channel %s is on release %d\n", c.Name, c.ReleaseSequence)
50+
}
51+
}
52+
```
53+
1654
## Development
1755
```make build``` installs the binary to ```$GOPATH/bin```
1856

1957
### Tests
2058
REPLICATED_API_ORIGIN may be set for testing an alternative environment.
2159

60+
Since apps can only be deleted in a login session, set these to cleanup garbage from the tests.
61+
VENDOR_USER_EMAIL should be set to delete app
62+
VENDOR_USER_PASSWORD should be set to delete app
63+
2264
### Releases
2365
Releases are created locally with [goreleaser](https://github.com/goreleaser/goreleaser).
2466
Tag the commit to release then run goreleaser.

cli/cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func Execute(w io.Writer) error {
6262
return errors.New("Please provide your API token")
6363
}
6464
}
65-
api := client.New(apiOrigin, apiToken)
65+
api := client.NewHTTPClient(apiOrigin, apiToken)
6666
runCmds.api = api
6767

6868
if appSlug == "" {

cli/test/channel_create_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
)
1313

1414
var _ = Describe("channel create", func() {
15+
t := GinkgoT()
1516
var app = &apps.App{Name: mustToken(8)}
1617

1718
BeforeEach(func() {
@@ -22,14 +23,13 @@ var _ = Describe("channel create", func() {
2223

2324
AfterEach(func() {
2425
// ignore error, garbage collection
25-
api.DeleteApp(app.Id)
26+
deleteApp(t, app.Id)
2627
})
2728

2829
name := mustToken(8)
2930
desc := mustToken(16)
3031
Describe(fmt.Sprintf("--name %s --description %s", name, desc), func() {
3132
It("should print the created channel", func() {
32-
t := GinkgoT()
3333
var stdout bytes.Buffer
3434
var stderr bytes.Buffer
3535

cli/test/channel_inspect_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import (
1212
)
1313

1414
var _ = Describe("channel inspect", func() {
15+
t := GinkgoT()
1516
var app = &apps.App{Name: mustToken(8)}
1617
var appChan = &channels.AppChannel{}
1718

1819
BeforeEach(func() {
19-
t := GinkgoT()
2020
var err error
2121
app, err = api.CreateApp(app.Name)
2222
assert.Nil(t, err)
@@ -28,13 +28,12 @@ var _ = Describe("channel inspect", func() {
2828

2929
AfterEach(func() {
3030
// ignore error, garbage collection
31-
api.DeleteApp(app.Id)
31+
deleteApp(t, app.Id)
3232
})
3333

3434
Context("with an existing channel ID", func() {
3535
Context("with no licenses and no releases", func() {
3636
It("should print the full channel details", func() {
37-
t := GinkgoT()
3837
var stdout bytes.Buffer
3938
var stderr bytes.Buffer
4039

cli/test/channel_list_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ var _ = Describe("channel ls", func() {
2727
})
2828

2929
AfterEach(func() {
30-
// ignore error, garbage collection
31-
api.DeleteApp(app.Id)
30+
deleteApp(t, app.Id)
3231
})
3332

3433
Context("when an app has three channels without releases", func() {

cli/test/channel_rm_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ var _ = Describe("channel rm", func() {
2727
})
2828

2929
AfterEach(func() {
30-
// ignore error, garbage collection
31-
api.DeleteApp(app.Id)
30+
deleteApp(t, app.Id)
3231
})
3332

3433
Context("when the channel ID exists", func() {

cli/test/release_create_test.go

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,6 @@ import (
1010
"github.com/stretchr/testify/assert"
1111
)
1212

13-
var yaml = `---
14-
replicated_api_version: 2.9.2
15-
name: "Test"
16-
17-
#
18-
# https://www.replicated.com/docs/packaging-an-application/application-properties
19-
#
20-
properties:
21-
app_url: http://{{repl ConfigOption "hostname" }}
22-
console_title: "Test"
23-
24-
#
25-
# https://www.replicated.com/docs/kb/supporting-your-customers/install-known-versions
26-
#
27-
host_requirements:
28-
replicated_version: ">=2.9.2"
29-
30-
#
31-
# Settings screen
32-
# https://www.replicated.com/docs/packaging-an-application/config-screen
33-
#
34-
config:
35-
- name: hostname
36-
title: Hostname
37-
description: Ensure this domain name is routable on your network.
38-
items:
39-
- name: hostname
40-
title: Hostname
41-
value: '{{repl ConsoleSetting "tls.hostname"}}'
42-
type: text
43-
test_proc:
44-
display_name: Check DNS
45-
command: resolve_host
46-
47-
#
48-
# Define how the application containers will be created and started
49-
# https://www.replicated.com/docs/packaging-an-application/components-and-containers
50-
#
51-
components: []
52-
`
53-
5413
var _ = Describe("release create", func() {
5514
t := GinkgoT()
5615
var app = &apps.App{Name: mustToken(8)}
@@ -62,8 +21,7 @@ var _ = Describe("release create", func() {
6221
})
6322

6423
AfterEach(func() {
65-
// ignore error, garbage collection
66-
api.DeleteApp(app.Id)
24+
deleteApp(t, app.Id)
6725
})
6826

6927
Context("with valid --yaml in an app with no releases", func() {

0 commit comments

Comments
 (0)