Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
gen/
vendor/
dist/
.glide
36 changes: 36 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
project_name: replicated
release:
github:
owner: replicatedhq
name: replicated
brew:
github: {}
install: bin.install "replicated"
builds:
- goos:
- linux
- darwin
goarch:
- amd64
- "386"
main: cli/main.go
ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}
binary: replicated
hooks: {}
archive:
format: tar.gz
name_template: '{{ .Binary }}_{{.Version}}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{
.Arm }}{{ end }}'
files:
- licence*
- LICENCE*
- license*
- LICENSE*
- readme*
- README*
- changelog*
- CHANGELOG*
snapshot:
name_template: SNAPSHOT-{{ .Commit }}
build:
hooks: {}
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: go
go: 1.8.3
install:
- make build
script:
- make test
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ RUN go get github.com/spf13/cobra/cobra

RUN go get github.com/go-swagger/go-swagger/cmd/swagger

RUN curl --location -o goreleaser.deb https://github.com/goreleaser/goreleaser/releases/download/v0.24.0/goreleaser_Linux_x86_64.deb
RUN dpkg -i goreleaser.deb

WORKDIR $PROJECTPATH

CMD ["/bin/bash"]
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ shell:
--volume `pwd`:/go/src/github.com/replicatedhq/replicated \
replicatedhq.replicated

clean:
sudo rm -rf gen/go

deps:
docker run --rm \
--volume `pwd`:/go/src/github.com/replicatedhq/replicated \
Expand Down Expand Up @@ -39,6 +36,7 @@ get-spec-local:
-o gen/spec/$$PKG.json; \
done'

# generate from the specs in gen/spec, which come from either get-spec-prod or get-spec-local
gen-models:
for PKG in ${API_PKGS}; do \
docker run --rm \
Expand All @@ -50,8 +48,13 @@ gen-models:
-o /local/gen/go/$$PKG; \
done

build: deps gen-models

install:
build:
go build -o replicated cli/main.go
mv replicated ${GOPATH}/bin

# release the latest tag
release:
docker run --rm -it \
--volume `pwd`:/go/src/github.com/replicatedhq/replicated \
--env GITHUB_TOKEN=${GITHUB_TOKEN} \
replicatedhq.replicated goreleaser
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,28 @@
This repository provides a client and CLI for interacting with the Replicated Vendor API.
The models are generated from the API's swagger spec.

Grab the latest [release](https://github.com/replicatedhq/replicated/releases) and extract it to your path.

```
replicated channel ls --app my-app-slug --token e8d7ce8e3d3278a8b1255237e6310069
```

Set the following env vars to avoid passing them as arguments to each command.
* REPLICATED_APP_SLUG
* REPLICATED_API_TOKEN
```REPLICATED_API_ORIGIN``` may also be set for testing.
* REPLICATED_APP_SLUG
* REPLICATED_API_TOKEN

## Development
```make build``` installs the binary to ```$GOPATH/bin```

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

### Releases
Releases are created locally with [goreleaser](https://github.com/goreleaser/goreleaser).
Tag the commit to release then run goreleaser.
Ensure GITHUB_TOKEN is [set](https://github.com/settings/tokens/new).

```
git tag -a v0.1.0 -m "First release" && git push origin v0.1.0
make release
```
20 changes: 0 additions & 20 deletions cli/cmd/cmd_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (

var appSlug string
var apiToken string
var apiOrigin = "https://api.replicated.com"
var apiOrigin = "https://api.replicated.com/vendor"

func init() {
RootCmd.PersistentFlags().StringVar(&appSlug, "app", "", "The app slug to use in all calls")
Expand Down
44 changes: 0 additions & 44 deletions cli/yaml.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions client/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func (c *HTTPClient) ArchiveChannel(appID, channelID string) error {
}
resp.Body.Close()
if resp.StatusCode != http.StatusNoContent {
if resp.StatusCode == http.StatusNotFound {
return ErrNotFound
}
return fmt.Errorf("ArchiveChannel (%s %s): status %d", req.Method, endpoint, resp.StatusCode)
}
return nil
Expand Down
24 changes: 24 additions & 0 deletions gen/go/apps/app.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Vendor API V1
*
* Apps documentation
*
* OpenAPI spec version: 1.0.0
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/

package swagger

// An app belongs to a team. It contains channels onto which releases can be promoted.
type App struct {

// The ID of the app
Id string `json:"Id"`

// The name of the app
Name string `json:"Name"`

// A unique slug for the app
Slug string `json:"Slug"`
}
19 changes: 19 additions & 0 deletions gen/go/apps/app_and_channels.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Vendor API V1
*
* Apps documentation
*
* OpenAPI spec version: 1.0.0
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/

package swagger

type AppAndChannels struct {

App App `json:"App"`

// Channels of the app
Channels []AppChannel `json:"Channels"`
}
40 changes: 40 additions & 0 deletions gen/go/apps/app_channel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Vendor API V1
*
* Apps documentation
*
* OpenAPI spec version: 1.0.0
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/

package swagger

// An app channel belongs to an app. It contains references to the top (current) release in the channel.
type AppChannel struct {

Adoption ChannelAdoption `json:"Adoption,omitempty"`

// Description that will be shown during license installation
Description string `json:"Description"`

// The ID of the channel
Id string `json:"Id"`

LicenseCounts LicenseCounts `json:"LicenseCounts,omitempty"`

// The name of channel
Name string `json:"Name"`

// The position for which the channel occurs in a list
Position int64 `json:"Position,omitempty"`

// The label of the current release sequence
ReleaseLabel string `json:"ReleaseLabel,omitempty"`

// Release notes for the current release sequence
ReleaseNotes string `json:"ReleaseNotes,omitempty"`

// A reference to the current release sequence
ReleaseSequence int64 `json:"ReleaseSequence,omitempty"`
}
17 changes: 17 additions & 0 deletions gen/go/apps/body.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Vendor API V1
*
* Apps documentation
*
* OpenAPI spec version: 1.0.0
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/

package swagger

type Body struct {

// Name of the app that is to be created.
Name string `json:"name"`
}
17 changes: 17 additions & 0 deletions gen/go/apps/body_1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Vendor API V1
*
* Apps documentation
*
* OpenAPI spec version: 1.0.0
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/

package swagger

type Body1 struct {

// Password of the user
Password string `json:"password"`
}
27 changes: 27 additions & 0 deletions gen/go/apps/channel_adoption.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Vendor API V1
*
* Apps documentation
*
* OpenAPI spec version: 1.0.0
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/

package swagger

// ChannelAdoption represents the versions that licenses are on in the channel
type ChannelAdoption struct {

CurrentVersionCountActive map[string]int64 `json:"current_version_count_active,omitempty"`

CurrentVersionCountAll map[string]int64 `json:"current_version_count_all,omitempty"`

OtherVersionCountActive map[string]int64 `json:"other_version_count_active,omitempty"`

OtherVersionCountAll map[string]int64 `json:"other_version_count_all,omitempty"`

PreviousVersionCountActive map[string]int64 `json:"previous_version_count_active,omitempty"`

PreviousVersionCountAll map[string]int64 `json:"previous_version_count_all,omitempty"`
}
12 changes: 12 additions & 0 deletions gen/go/apps/docs/App.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# App

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Id** | **string** | The ID of the app | [default to null]
**Name** | **string** | The name of the app | [default to null]
**Slug** | **string** | A unique slug for the app | [default to null]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


11 changes: 11 additions & 0 deletions gen/go/apps/docs/AppAndChannels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# AppAndChannels

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**App** | [**App**](App.md) | | [default to null]
**Channels** | [**[]AppChannel**](AppChannel.md) | Channels of the app | [default to null]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


Loading