This repository provides a Go client and CLI for interacting with the Replicated Vendor API.
brew install replicatedhq/replicated/cli
curl -o install.sh -sSL https://raw.githubusercontent.com/replicatedhq/replicated/master/install.sh
sudo bash ./install.sh
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 - either an app slug or app ID
- REPLICATED_API_TOKEN
Then the above command would be simply
replicated channel ls
Creating a new release for every tagged build is a common use of the replicated command.
Assume the app's yaml config is checked in at replicated.yaml and you have configured TravisCI or CircleCI with your REPLICATED_APP and REPLICATED_API_TOKEN environment variables.
Then add a release.sh script to your project something like this:
#!/bin/bash
# Create a new release from replicated.yaml and promote the Unstable channel to use it.
# Aborts if version tag is empty.
set -e
VERSION=$1
INSTALL_SCRIPT=https://raw.githubusercontent.com/replicatedhq/replicated/master/install.sh
CHANNEL=Unstable
if [ -z "$VERSION" ]; then
echo "No version; skipping replicated release"
exit
fi
# install replicated
curl -sSL "$INSTALL_SCRIPT" > install.sh
sudo bash ./install.sh
cat replicated.yaml | replicated release create --yaml - --promote=Unstable --version "$VERSION"
# Channel ee9d99e87b4a5acc2863f68cb2a0c390 successfully set to release 15
Now you can automate tagged releases in TravisCI or CircleCI:
# .travis.yml
sudo: required
after_success:
- ./release.sh "$TRAVIS_TAG"
# circle.yml
deployment:
tag:
tag: /v.*/
owner: replicatedcom
commands:
- ./release.sh "$CIRCLE_TAG"
package main
import (
"fmt"
"log"
"os"
"github.com/replicatedhq/replicated/pkg/platformclient"
)
func main() {
token := os.Getenv("REPLICATED_API_TOKEN")
appSlugOrID := os.Getenv("REPLICATED_APP")
api := platformclient.New(token)
app, err := api.GetApp(appSlugOrID)
if err != nil {
log.Fatal(err)
}
channels, err := api.ListChannels(app.Id)
if err != nil {
log.Fatal(err)
}
for _, c := range channels {
fmt.Printf("channel %s is on release %d\n", c.Name, c.ReleaseSequence)
}
}
make build
installs the binary to $GOPATH/bin
The models are generated from the API's swagger spec.
REPLICATED_API_ORIGIN
may be set to override the API endpointVENDOR_USER_EMAIL
andVENDOR_USER_PASSWORD
should be set to delete apps created for testing
Releases are created on Travis when a tag is pushed. This will also update the docs container.
git tag -a v0.1.0 -m "First release" && git push upstream v0.1.0
When the swagger definitions change, you can regenerate the Client code from the swagger spec with
make get-spec-prod gen-models
models for the v2 api isn't really working yet, need to find the URL for that OpenAPI spec.
replicated release inspect 130 | sed 1,4d > config.yaml
vim config.yaml
cat config.yaml | replicated release create --yaml -
# SEQUENCE: 131