### CLI: Inspect, Edit, and Manage Releases and Channels Source: https://context7.com/replicatedhq/replicated/llms.txt This section provides command-line examples for interacting with Replicated releases and channels. It covers inspecting a specific release, editing a release configuration by piping output to a file and then creating a new release, listing all releases for an application, getting channel details including release history, and listing releases within a specific channel. These commands are useful for manual release management and debugging. ```bash # Inspect specific release replicated release inspect 130 # Edit and create new release from existing one replicated release inspect 130 | sed 1,4d > config.yaml vim config.yaml cat config.yaml | replicated release create --yaml - # List releases for an app replicated release ls --app test-rodent # Get channel details with release history replicated channel inspect --channel Stable # List channel releases replicated channel releases --channel Beta ``` -------------------------------- ### Install Replicated CLI on Linux Source: https://github.com/replicatedhq/replicated/blob/main/README.md Installs the Replicated CLI for Linux by downloading and executing an installation script. Requires curl and sudo privileges. ```shell curl -o install.sh -sSL https://raw.githubusercontent.com/replicatedhq/replicated/master/install.sh sudo bash ./install.sh ``` -------------------------------- ### Install Replicated CLI on macOS and Linux Source: https://context7.com/replicatedhq/replicated/llms.txt Instructions for installing the Replicated Vendor CLI using Homebrew on macOS and a script for Linux systems. The Linux installation fetches and executes an installation script from a remote URL. ```bash brew install replicatedhq/replicated/cli ``` ```bash curl -o install.sh -sSL https://raw.githubusercontent.com/replicatedhq/replicated/master/install.sh sudo bash ./install.sh ``` -------------------------------- ### Go Client Example: List Application Channels Source: https://github.com/replicatedhq/replicated/blob/main/README.md A Go program demonstrating how to use the Replicated platform client to fetch an application's details and list its distribution channels. It requires REPLICATED_API_TOKEN and REPLICATED_APP environment variables. ```golang 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) } } ``` -------------------------------- ### Build Replicated CLI Binary Source: https://github.com/replicatedhq/replicated/blob/main/README.md Command to build the Replicated CLI binary. This command installs the binary to the $GOPATH/bin directory. ```makefile build ``` -------------------------------- ### Replicated Linter Configuration Example with Helm Version Pinning Source: https://github.com/replicatedhq/replicated/blob/main/docs/lint-format.md An example of a Replicated linter configuration file demonstrating how to pin Helm versions and configure linters for Helm, Preflight, Support Bundle, Embedded Cluster, and KOTS. It includes app metadata, chart and preflight definitions, and tool versions. Note the use of 'disbabled' (likely a typo for 'disabled') in the example. ```yaml appId: "" appSlug: "" promoteToChannelIds: [] promoteToChannelNames: [] charts: [ { path: "./chart/something", chartVersion: "", appVersion: "", }, { path: "./chart/new-chart/*", chartVersion: "", appVersion: "", } ] preflights: [ { path: "./preflights/stuff", chartName: "something", chartVersion: "1.0.0", } ] releaseLabel: "" ## some sort of semver pattern? manifests: ["replicated/**/*.yaml"] repl-lint: version: 1 linters: helm: disbabled: false strict: false preflight: disabled: false strict: true support-bundle: disabled: false strict: false embedded-cluster: disabled: true strict: false kots: disabled: true strict: false tools: helm: "3.14.4" preflight: "0.123.9" support-bundle: "0.123.9" ``` -------------------------------- ### Install Replicated CLI on macOS Source: https://github.com/replicatedhq/replicated/blob/main/README.md Installs the Replicated CLI for macOS using Homebrew. Ensure Homebrew is installed and updated before running this command. ```shell brew install replicatedhq/replicated/cli ``` -------------------------------- ### Replicated Lint Configuration Example (.replicated) Source: https://github.com/replicatedhq/replicated/blob/main/testdata/README.md Defines the resources to lint, including application slug, charts, preflights, and linter configurations. This file is essential for setting up a test case. ```yaml appSlug: "test-case-name" charts: [ { path: "./charts/my-chart", chartVersion: "", appVersion: "", }, ] preflights: [] repl-lint: version: 1 linters: helm: disabled: false preflight: disabled: false support-bundle: disabled: true ``` -------------------------------- ### CircleCI Configuration for Automated Releases Source: https://github.com/replicatedhq/replicated/blob/main/README.md Example CircleCI configuration to trigger the release script for tagged deployments. It requires the release.sh script and necessary environment variables to be configured. ```yaml # circle.yml deployment: tag: tag: /v.*/ owner: replicatedcom commands: - ./release.sh "$CIRCLE_TAG" ``` -------------------------------- ### GitHub Actions CI/CD Integration for Replicated Releases Source: https://context7.com/replicatedhq/replicated/llms.txt A GitHub Actions workflow file that automatically creates a Replicated release when a new Git tag starting with 'v' is pushed. It installs the Replicated CLI and uses environment secrets for API token and application ID to create and promote the release. ```yaml # .github/workflows/release.yml name: Create Replicated Releaseon: push: tags: - 'v*' jobs: release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Install Replicated CLI run: | curl -o install.sh -sSL https://raw.githubusercontent.com/replicatedhq/replicated/master/install.sh sudo bash ./install.sh - name: Create Release env: REPLICATED_API_TOKEN: ${{ secrets.REPLICATED_API_TOKEN }} REPLICATED_APP: ${{ secrets.REPLICATED_APP }} run: | VERSION=${GITHUB_REF#refs/tags/v} replicated release create \ --yaml-dir ./manifests \ --promote Unstable \ --version "$VERSION" \ --release-notes "Release $VERSION from GitHub Actions" ``` -------------------------------- ### CI: Create and Promote Release on Tag (Bash) Source: https://context7.com/replicatedhq/replicated/llms.txt This script is executed after a successful build in Travis CI. It checks if a Git tag is present, then downloads and installs the Replicated CLI. If a tag exists, it creates a new release from 'manifests.yaml' and promotes it to the 'Unstable' channel using the Git tag as the version. ```bash if [ -n "$TRAVIS_TAG" ]; then curl -sSL https://raw.githubusercontent.com/replicatedhq/replicated/master/install.sh | sudo bash cat manifests.yaml | replicated release create --yaml - --promote Unstable --version "$TRAVIS_TAG" fi ``` -------------------------------- ### Automate Release Creation using Replicated CLI Source: https://github.com/replicatedhq/replicated/blob/main/README.md A bash script to create a new release from a replicated.yaml file and promote it to a specified channel. It handles versioning and requires the Replicated CLI to be installed. ```bash #!/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 ``` -------------------------------- ### TravisCI Configuration for Automated Releases Source: https://github.com/replicatedhq/replicated/blob/main/README.md Example TravisCI configuration to trigger the release script on tagged builds. It assumes the release.sh script is present and environment variables REPLICATED_APP and REPLICATED_API_TOKEN are set. ```yaml # .travis.yml sudo: required after_success: - ./release.sh "$TRAVIS_TAG" ``` -------------------------------- ### Configuration: Release Properties and Deployment Settings Source: https://context7.com/replicatedhq/replicated/llms.txt This is an example of a Replicated configuration file (.replicated.yaml) used to define release properties and deployment strategies. It specifies application identifiers, channels to promote to, paths for Helm charts and preflight checks, release labels, support bundle locations, and repl-lint configurations for various tools. This file is essential for automating release builds and deployments. ```yaml # .replicated.yaml appId: "2FOfwth3fHauBqCvsZ1OaBAr7MU" appSlug: "my-app" promoteToChannelIds: [] promoteToChannelNames: ["Beta", "Unstable"] charts: - path: "./helm-chart" chartVersion: "1.0.0" appVersion: "1.0.0" preflights: - path: "./preflights/**" chartName: "helm-chart" chartVersion: "1.0.0" releaseLabel: "v1.0.0" manifests: ["./support-bundles/**"] repl-lint: version: 1 linters: helm: disabled: false preflight: disabled: false support-bundle: disabled: false tools: helm: "latest" preflight: "latest" support-bundle: "latest" ``` -------------------------------- ### Add New Test Case Configuration (.replicated) Source: https://github.com/replicatedhq/replicated/blob/main/testdata/README.md Example of creating a `.replicated` configuration file for a new test case. It specifies the application slug and charts to be linted. ```bash cat > testdata/my-new-test/.replicated << EOF appSlug: "my-new-test" charts: [ { path: "./my-chart", chartVersion: "", appVersion: "", }, ] repl-lint: version: 1 linters: helm: disabled: false EOF ``` -------------------------------- ### Automated Release Script for CI/CD (Bash) Source: https://context7.com/replicatedhq/replicated/llms.txt A bash script designed for CI/CD pipelines to automate the release process. It installs the Replicated CLI, creates a new release from YAML manifests, and promotes it to a specified channel with a given version and release notes. ```bash #!/bin/bash # release.sh - Automated release script for CI/CD set -e VERSION=$1 CHANNEL=${2:-Unstable} if [ -z "$VERSION" ]; then echo "No version; skipping replicated release" exit fi # Install replicated CLI curl -sSL https://raw.githubusercontent.com/replicatedhq/replicated/master/install.sh | sudo bash # Create and promote release cat manifests/app.yaml | replicated release create \ --yaml - \ --promote "$CHANNEL" \ --version "$VERSION" \ --release-notes "Release $VERSION from CI" echo "Successfully created release $VERSION on channel $CHANNEL" ``` -------------------------------- ### Replicated Linter Glob Pattern Examples for File Discovery Source: https://github.com/replicatedhq/replicated/blob/main/docs/lint-format.md Demonstrates the use of glob patterns in Replicated's linting configuration for discovering Helm charts, Preflight definitions, and Support Bundle manifests. It covers basic wildcard, recursive, character set, and brace expansion patterns. These patterns allow flexible file selection for linting. ```yaml charts: - path: "./charts/*" # All charts in charts/ - path: "./charts/{app,api,web}" # Specific charts only - path: "./environments/*/charts/*" # Charts in any environment preflights: - path: "./preflights/**/*.yaml" # All YAML files recursively - path: "./checks/{basic,advanced}.yaml" # Specific check files manifests: # Support Bundles - "./k8s/**/*.yaml" # All YAML in k8s/, recursively - "./manifests/{dev,staging,prod}/**/*" # Multiple environments ``` -------------------------------- ### Get Application URL with Kubernetes Ingress Source: https://github.com/replicatedhq/replicated/blob/main/testdata/chart-with-required-values/charts/required-values/templates/NOTES.txt This snippet generates the application URL when Kubernetes Ingress is enabled. It iterates through configured hosts and paths to construct the full URL. No external dependencies are required beyond a valid Kubernetes configuration. ```Go/Templating {{- if .Values.ingress.enabled }} {{- range $host := .Values.ingress.hosts }} {{- range .paths }} http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} {{- end }} {{- end }} {{- end }} ``` -------------------------------- ### HelmChart Manifest Structure for Replicated Source: https://github.com/replicatedhq/replicated/blob/main/docs/lint-format.md Example of a `HelmChart` manifest (custom resource) required for Replicated. It links a chart to its name and version, used for preflight rendering, image extraction, and air gapped builds. ```yaml apiVersion: kots.io/v1beta2 kind: HelmChart metadata: name: my-app spec: chart: name: my-app # Must match Chart.yaml name chartVersion: 1.0.0 # Must match Chart.yaml version builder: {} # Values for rendering (can be empty) ``` -------------------------------- ### Get Application URL with Kubernetes LoadBalancer Service Source: https://github.com/replicatedhq/replicated/blob/main/testdata/chart-with-required-values/charts/required-values/templates/NOTES.txt This snippet determines the application URL for a Kubernetes LoadBalancer service. It fetches the LoadBalancer IP and uses the configured service port to construct the URL. It also provides a command to monitor the LoadBalancer status. Requires kubectl access. ```Shell {{- else if contains "LoadBalancer" .Values.service.type }} NOTE: It may take a few minutes for the LoadBalancer IP to be available. You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "required-values.fullname" . }}' export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "required-values.fullname" . }} --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}") echo http://$SERVICE_IP:{{ .Values.service.port }} {{- end }} ``` -------------------------------- ### Get Application URL with Kubernetes NodePort Service Source: https://github.com/replicatedhq/replicated/blob/main/testdata/chart-with-required-values/charts/required-values/templates/NOTES.txt This snippet retrieves the application URL for a Kubernetes NodePort service. It obtains the NodePort and Node IP using kubectl commands and then echoes the constructed URL. Requires kubectl access to the Kubernetes cluster. ```Shell {{- else if contains "NodePort" .Values.service.type }} export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "required-values.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT {{- end }} ``` -------------------------------- ### Replicated Linter Inline Ignore Directives Source: https://github.com/replicatedhq/replicated/blob/main/docs/lint-format.md Shows how to use inline directives within YAML files to control Replicated's linter behavior. It includes examples for ignoring the next line, ignoring a block of code, and ignoring an entire file. These directives provide fine-grained control over linting. ```yaml # repl-lint-ignore-next image: nginx:latest ``` ```yaml # repl-lint-ignore-start apiVersion: v1 kind: ConfigMap data: KEY: VALUE # repl-lint-ignore-end ``` ```yaml # repl-lint-ignore-file ``` -------------------------------- ### Go Client: Basic Platform Application Operations (Go) Source: https://context7.com/replicatedhq/replicated/llms.txt This Go program demonstrates basic usage of the Replicated platform client. It retrieves an API token and application slug/ID from environment variables, initializes the client, fetches application details, and lists available channels along with their current release sequences. Requires REPLICATED_API_TOKEN and REPLICATED_APP environment variables. ```go package main import ( "context" "fmt" "log" "os" "github.com/replicatedhq/replicated/pkg/platformclient" ) func main() { token := os.Getenv("REPLICATED_API_TOKEN") appSlugOrID := os.Getenv("REPLICATED_APP") // Create client api := platformclient.New(token) // Get application app, err := api.GetApp(appSlugOrID) if err != nil { log.Fatal(err) } fmt.Printf("App: %s (ID: %s, Scheduler: %s)\n", app.Name, app.Id, app.Scheduler) // List channels 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) } } ``` -------------------------------- ### Go Client: Customer Management and License Operations (Go) Source: https://context7.com/replicatedhq/replicated/llms.txt This Go program demonstrates customer management within the Replicated ecosystem. It shows how to create a new customer with specific license details (channel, expiry, type), list all customers for an application, and download a customer's license file. It requires REPLICATED_API_TOKEN and REPLICATED_APP environment variables and uses a hardcoded ChannelID for customer creation. ```go package main import ( "context" "fmt" "log" "os" "github.com/replicatedhq/replicated/client" "github.com/replicatedhq/replicated/pkg/kotsclient" ) func main() { token := os.Getenv("REPLICATED_API_TOKEN") appID := os.Getenv("REPLICATED_APP") c := client.NewClient("https://api.replicated.com/vendor", token, "") // Get app type app, appType, err := c.GetAppType(context.Background(), appID, false) if err != nil { log.Fatal(err) } // Create customer with license customer, err := c.CreateCustomer(appType, kotsclient.CreateCustomerOpts{ AppID: app.ID, Name: "Example Corp", Email: "admin@example.com", ChannelID: "2FOfwru7Rq1plkqyZFLH6MLR1fk", ExpiresAt: "2025-12-31T23:59:59Z", Type: "prod", }) if err != nil { log.Fatal(err) } fmt.Printf("Created customer: %s (ID: %s)\n", customer.Name, customer.ID) // List all customers customers, err := c.ListCustomers(app.ID, appType, false) if err != nil { log.Fatal(err) } for _, cust := range customers { fmt.Printf("Customer: %s, Type: %s, Channel: %s\n", cust.Name, cust.Type, cust.Channels[0].Name) } // Download license file licenseData, err := c.DownloadLicense(appType, app.ID, customer.ID) if err != nil { log.Fatal(err) } // Save license to file err = os.WriteFile("customer-license.yaml", licenseData, 0644) if err != nil { log.Fatal(err) } fmt.Println("License saved to customer-license.yaml") } ``` -------------------------------- ### Go Client: Create and Promote Release (Go) Source: https://context7.com/replicatedhq/replicated/llms.txt This Go program utilizes the Replicated client library to manage application releases. It reads a YAML manifest file, creates a new release for a specified application, retrieves a channel by name, and then promotes the newly created release to that channel with versioning and release notes. It requires REPLICATED_API_TOKEN and REPLICATED_APP environment variables and a local './manifests/app.yaml' file. ```go package main import ( "context" "fmt" "io/ioutil" "log" "os" "github.com/replicatedhq/replicated/client" "github.com/replicatedhq/replicated/pkg/platformclient" ) func main() { token := os.Getenv("REPLICATED_API_TOKEN") appID := os.Getenv("REPLICATED_APP") // Create unified client (supports both platform and KOTS apps) c := client.NewClient("https://api.replicated.com/vendor", token, "") // Determine app type app, appType, err := c.GetAppType(context.Background(), appID, false) if err != nil { log.Fatalf("Failed to get app: %v", err) } fmt.Printf("Managing %s app: %s\n", appType, app.Name) // Read YAML manifest yamlContent, err := ioutil.ReadFile("./manifests/app.yaml") if err != nil { log.Fatalf("Failed to read manifest: %v", err) } // Create release release, err := c.CreateRelease(app.ID, appType, string(yamlContent)) if err != nil { log.Fatalf("Failed to create release: %v", err) } fmt.Printf("Created release sequence: %d\n", release.Sequence) // Get channel by name channel, err := c.GetChannelByName(app.ID, appType, "Unstable") if err != nil { log.Fatalf("Failed to get channel: %v", err) } // Promote release to channel err = c.PromoteRelease( app.ID, appType, release.Sequence, "v1.0.0", // version label "Initial release", // release notes false, // required update channel.ID, // channel ID ) if err != nil { log.Fatalf("Failed to promote release: %v", err) } fmt.Printf("Promoted release %d to channel %s\n", release.Sequence, channel.Name) } ``` -------------------------------- ### Create New Channels using Replicated CLI Source: https://context7.com/replicatedhq/replicated/llms.txt Demonstrates creating a new release channel with a specified name and description. It also shows how to create a release and immediately promote it to this newly created channel, ensuring the channel exists before promotion. ```bash # Create a new channel replicated channel create --name "QA" --description "Quality Assurance testing" # Create and promote release to new channel replicated release create \ --yaml-dir ./manifests \ --promote "QA" \ --ensure-channel \ --version "1.0.0-qa" ``` -------------------------------- ### Go: Create and Promote Release with Error Handling Source: https://context7.com/replicatedhq/replicated/llms.txt This Go function demonstrates how to programmatically create a new release and promote it to a specified channel using the Replicated client library. It includes error handling for API interactions, environment variable checks, and permission errors during promotion. Dependencies include the 'context', 'fmt', 'log', 'os' packages, and external libraries 'github.com/pkg/errors', 'github.com/replicatedhq/replicated/client', and 'github.com/replicatedhq/replicated/pkg/platformclient'. It takes application ID, YAML directory, channel name, and version as input and returns an error if any operation fails. ```go package main import ( "context" "fmt" "log" "os" "github.com/pkg/errors" "github.com/replicatedhq/replicated/client" "github.com/replicatedhq/replicated/pkg/platformclient" ) func createAndPromoteRelease(appID, yamlDir, channelName, version string) error { token := os.Getenv("REPLICATED_API_TOKEN") if token == "" { return errors.New("REPLICATED_API_TOKEN not set") } c := client.NewClient("https://api.replicated.com/vendor", token, "") // Get app type app, appType, err := c.GetAppType(context.Background(), appID, false) if err != nil { return errors.Wrap(err, "get app type") } // Read manifest files yamlContent, err := os.ReadFile(yamlDir + "/app.yaml") if err != nil { return errors.Wrap(err, "read yaml file") } // Create release release, err := c.CreateRelease(app.ID, appType, string(yamlContent)) if err != nil { return errors.Wrap(err, "create release") } fmt.Printf("Created release %d\n", release.Sequence) // Get or create channel opts := client.GetOrCreateChannelOptions{ AppID: app.ID, AppType: appType, NameOrID: channelName, Description: "Automated channel", CreateIfAbsent: true, } channel, err := c.GetOrCreateChannelByName(opts) if err != nil { return errors.Wrap(err, "get or create channel") } // Promote to channel err = c.PromoteRelease( app.ID, appType, release.Sequence, version, fmt.Sprintf("Automated release %s", version), false, channel.ID, ) if err != nil { if errors.Is(err, platformclient.ErrForbidden) { return errors.New("insufficient permissions to promote release") } return errors.Wrap(err, "promote release") } fmt.Printf("Successfully promoted release %d to channel %s\n", release.Sequence, channel.Name) return nil } func main() { err := createAndPromoteRelease( "2FOfwth3fHauBqCvsZ1OaBAr7MU", "./manifests", "Beta", "1.2.3", ) if err != nil { log.Fatalf("Error: %v", err) } } ``` -------------------------------- ### Create New Release by Editing Existing Source: https://github.com/replicatedhq/replicated/blob/main/README.md This recipe details how to create a new release by inspecting and modifying an existing release's configuration. It involves inspecting a release, saving its configuration to a YAML file, editing the file, and then creating a new release using the modified configuration. ```bash replicated release inspect 130 | sed 1,4d > config.yaml vim config.yaml cat config.yaml | replicated release create --yaml - ``` -------------------------------- ### Create Release (Major, Minor, Patch) Source: https://github.com/replicatedhq/replicated/blob/main/README.md This command initiates the release process for the Replicated project. It supports creating major, minor, or patch releases by specifying the version type. The process includes updating the codebase, creating git tags, building and publishing binaries, and pushing Docker images. ```makefile make release version=major make release version=minor make release version=patch ``` -------------------------------- ### Create and Promote Releases using Replicated CLI Source: https://context7.com/replicatedhq/replicated/llms.txt Commands for creating new releases from YAML manifests. Supports creating from standard input or a directory, promoting to specific channels, setting version numbers, and including release notes. The `--ensure-channel` flag creates the channel if it doesn't exist. ```bash # Create release from stdin cat manifests.yaml | replicated release create --yaml - --promote Unstable --version "1.0.0" # Create release from directory (KOTS) replicated release create --yaml-dir ./manifests --promote Beta --version "2.0.1" # Create release with all options replicated release create \ --yaml-dir ./manifests \ --promote Stable \ --version "3.0.0" \ --release-notes "Bug fixes and performance improvements" \ --required \ --ensure-channel # Example output: # SEQUENCE: 42 # Channel Stable successfully set to release 42 ``` -------------------------------- ### Run All Lint Tests (Makefile) Source: https://github.com/replicatedhq/replicated/blob/main/testdata/README.md Executes all integration tests for the `replicated lint` command. This command builds the `replicated` binary if necessary, runs `replicated lint` for each test case, and compares the results against `expect.json`. ```bash make test-lint ``` -------------------------------- ### List Applications using Replicated CLI Source: https://context7.com/replicatedhq/replicated/llms.txt Commands to list all applications, search for specific applications by name, and output the list in JSON format. This is useful for retrieving application identifiers needed for other CLI operations. ```bash # List all applications replicated app ls # Example output: # ID NAME SLUG SCHEDULER # 2FOfwth3fHauBqCvsZ1OaBAr7MU test test-rodent kots # 2FOvdw6IR0oewVPVCcmH12tSRoL nginx nginx-sheepdog kots # Search for specific application replicated app ls "nginx" # Output in JSON format replicated app ls --output json ``` -------------------------------- ### List Applications using Replicated CLI Source: https://github.com/replicatedhq/replicated/blob/main/README.md Lists all available applications in the Replicated Vendor portal. This command requires the REPLICATED_API_TOKEN to be set. ```shell replicated app ls ``` -------------------------------- ### LicenseInstanceVersionHistory Model Source: https://github.com/replicatedhq/replicated/blob/main/gen/go/v1/docs/LicenseInstanceVersionHistory.md Details the properties available for the LicenseInstanceVersionHistory model, including their types, descriptions, and optionality. ```APIDOC ## LicenseInstanceVersionHistory Model ### Description Represents the history of a license instance version. ### Properties * **InstanceId** (string) - Optional - The ID of the license instance. * **Start** (time.Time) - Optional - The start time of the version history entry. * **Stop** (time.Time) - Optional - The stop time of the version history entry. * **VersionChannel** (string) - Optional - The channel of the version. * **VersionLabel** (string) - Optional - The label of the version. * **VersionSequence** (int64) - Optional - The sequence number of the version. ``` -------------------------------- ### Go: Construct Test Fixture Paths Source: https://github.com/replicatedhq/replicated/blob/main/testdata/image-extraction/README.md Demonstrates how to construct relative file paths to access image extraction test fixtures using Go's `filepath.Join`. This is crucial for referencing test data within your test suite. ```go chartPath := filepath.Join("testdata", "image-extraction", "chart-with-required-values-test", "chart") manifestPath := filepath.Join("testdata", "image-extraction", "chart-with-required-values-test", "manifests", "*.yaml") ``` -------------------------------- ### List Applications Source: https://github.com/replicatedhq/replicated/blob/main/gen/go/v2/docs/Body.md Retrieves a list of applications with various filtering and pagination options. ```APIDOC ## GET /v1/applications ### Description Retrieves a list of applications, allowing for filtering by status (active, archived, dev, inactive, paid, trial) and custom query parameters. Supports pagination with offset and page size, and custom sorting. ### Method GET ### Endpoint /v1/applications ### Parameters #### Query Parameters - **IncludeActive** (bool) - Optional - If true, include active applications. - **IncludeArchived** (bool) - Optional - If true, include archived applications. - **IncludeDev** (bool) - Optional - If true, include development applications. - **IncludeInactive** (bool) - Optional - If true, include inactive applications. - **IncludePaid** (bool) - Optional - If true, include paid applications. - **IncludeTrial** (bool) - Optional - If true, include trial applications. - **Offset** (int64) - Optional - The number of records to skip. Defaults to 0. - **PageSize** (int64) - Optional - The maximum number of records to return. Defaults to 50. - **Query** (string) - Optional - A search query to filter applications. - **SortDirection** (string) - Optional - The direction to sort the results (e.g., 'asc', 'desc'). - **SortField** (string) - Optional - The field to sort the results by. ### Response #### Success Response (200) - **Applications** (array) - A list of application objects. - **ID** (string) - The unique identifier of the application. - **Name** (string) - The name of the application. - **Created** (string) - The timestamp when the application was created. - **Updated** (string) - The timestamp when the application was last updated. #### Response Example ```json { "Applications": [ { "ID": "app-12345", "Name": "My Awesome App", "Created": "2023-10-27T10:00:00Z", "Updated": "2023-10-27T10:30:00Z" } ] } ``` ``` -------------------------------- ### List Channels for an Application using Replicated CLI Source: https://context7.com/replicatedhq/replicated/llms.txt Lists all channels associated with a given application ID or uses the REPLICATED_APP environment variable. Supports JSON output for programmatic parsing. Channels manage the lifecycle and promotion of releases. ```bash # List channels for an application replicated channel ls --app 2FOfwth3fHauBqCvsZ1OaBAr7MU # Example output: # ID NAME RELEASE VERSION # 2FOfwru7Rq1plkqyZFLH6MLR1fk Stable 1 0.0.1 # 2FOfwu2zcDbqR24BVPSjjnkVwIe Beta 1 0.0.1 # 2FOfwreTFbmkXtf9bukwh8s1ewb Unstable 1 0.0.1 # Using environment variable for app export REPLICATED_APP=2FOfwth3fHauBqCvsZ1OaBAr7MU replicated channel ls # JSON output replicated channel ls --output json ``` -------------------------------- ### Manually Run Lint Tests (Shell Script) Source: https://github.com/replicatedhq/replicated/blob/main/testdata/README.md Allows manual execution of the lint tests. It first requires building the `replicated` binary using `make build`, and then runs the test script `./scripts/test-lint.sh`. ```bash # Build the binary first make build # Run the test script ./scripts/test-lint.sh ``` -------------------------------- ### Troubleshooting: Create Missing HelmChart Manifest Source: https://github.com/replicatedhq/replicated/blob/main/docs/lint-format.md A template for creating a `HelmChart` manifest when one is missing for a configured chart. Ensure the `name` and `chartVersion` match the chart's `Chart.yaml`. ```yaml apiVersion: kots.io/v1beta2 kind: HelmChart metadata: name: spec: chart: name: chartVersion: builder: {} ``` -------------------------------- ### Set Environment Variables for Release Source: https://github.com/replicatedhq/replicated/blob/main/CONTRIBUTING.md Sets necessary GitHub token and OnePassword service account credentials for the release process. These variables are required before running the make release command. ```bash export GITHUB_TOKEN= export OP_SERVICE_ACCOUNT_PRODUCTION= ``` -------------------------------- ### Configure Replicated CLI with API Token Source: https://github.com/replicatedhq/replicated/blob/main/README.md Sets the REPLICATED_API_TOKEN environment variable to authenticate the CLI with the Replicated Vendor portal. Replace with your actual token. ```shell export REPLICATED_API_TOKEN= ``` -------------------------------- ### Create a New CLI Release Source: https://github.com/replicatedhq/replicated/blob/main/CONTRIBUTING.md Uses a make target to build and release a new version of the CLI. The version can be specified as an exact number (e.g., x.y.z) or as a relative bump (major, minor, patch). Requires Dagger and previously set environment variables. ```bash make release version=x.y.z ``` ```bash make release version=patch ``` -------------------------------- ### List Channels for an Application using Replicated CLI Source: https://github.com/replicatedhq/replicated/blob/main/README.md Lists the distribution channels for a specific application, identified by its slug or ID. Requires REPLICATED_API_TOKEN and optionally REPLICATED_APP environment variables. ```shell replicated channel ls --app ``` -------------------------------- ### Create Release Source: https://github.com/replicatedhq/replicated/blob/main/gen/go/v1/docs/Body9.md This endpoint allows for the creation of a new release within a Replicated project. It supports copying YAML from existing releases or using default placeholder YAML. ```APIDOC ## POST /v1/releases ### Description Creates a new release for the application. Supports copying YAML from an existing release or using default placeholder YAML. ### Method POST ### Endpoint /v1/releases ### Parameters #### Query Parameters - **Source** (string) - Optional - Supported values are "copy" and "latest". - If "copy", `Sourcedata` must be set to the release number to copy YAML from. - If "latest", YAML will be copied from the latest app release. - If omitted, the release will be created with default placeholder YAML. #### Request Body - **Sourcedata** (integer) - Optional - If `Source` is set to "copy", this must be the release number to copy YAML from. ### Request Example ```json { "Sourcedata": 123 } ``` ### Response #### Success Response (201 Created) - **ID** (string) - The unique identifier for the newly created release. - **Sequence** (integer) - The sequence number of the release. - **ChannelSequence** (integer) - The sequence number of the release within its channel. - **CreatedAt** (string) - The timestamp when the release was created. #### Response Example ```json { "ID": "release-abc123xyz", "Sequence": 5, "ChannelSequence": 5, "CreatedAt": "2023-10-27T10:00:00Z" } ``` #### Error Handling - **400 Bad Request**: Invalid input parameters or configuration. - **500 Internal Server Error**: An unexpected error occurred on the server. ``` -------------------------------- ### CI Integration for Lint Tests (YAML) Source: https://github.com/replicatedhq/replicated/blob/main/testdata/README.md Demonstrates how to integrate the lint tests into a CI pipeline using a simple YAML configuration. This ensures consistent linting behavior across code changes. ```yaml - name: Run lint tests run: make test-lint ``` -------------------------------- ### License Properties Source: https://github.com/replicatedhq/replicated/blob/main/gen/go/v1/docs/License.md This section details the properties available for a License object. Each property includes its type, a description, and whether it is optional. ```APIDOC ## License Object ### Description Represents a license with various configuration properties. ### Properties - **ActivationEmail** (string) - Optional - The email address for license activation. - **ActiveInstanceCount** (int64) - Optional - The number of currently active instances. - **AirgapDownloadEnabled** (bool) - Optional - Flag indicating if airgap download is enabled. - **AirgapDownloadPassword** ([]int32) - Optional - Password for airgap downloads. - **Anonymous** (bool) - Optional - Flag indicating if the license is anonymous. - **AppId** (string) - Optional - The application ID associated with the license. - **AppStatus** (string) - Optional - The current status of the application. - **Archived** (bool) - Optional - Flag indicating if the license is archived. - **Assignee** (string) - Optional - The assignee of the license. - **AssistedSetupEnabled** (bool) - Optional - Flag indicating if assisted setup is enabled. - **Billing** (LicenseBilling) - Optional - Billing information for the license. - **BillingEvents** ([]LicenseBillingEvent) - Optional - A list of billing events associated with the license. - **ChannelId** (string) - Optional - The ID of the channel associated with the license. - **ChannelName** (string) - Optional - The name of the channel associated with the license. - **Clouds** (string) - Optional - Cloud platform information. - **ExpirationPolicy** (string) - Optional - The expiration policy for the license. - **ExpireDate** (time.Time) - Optional - The expiration date of the license. - **ExternalSupportBundle** (bool) - Optional - Flag indicating if external support bundles are enabled. - **FieldValues** ([]LicenseFieldValue) - Optional - Custom field values for the license. - **GrantDate** (time.Time) - Optional - The date the license was granted. - **Id** (string) - Optional - The unique identifier for the license. - **InactiveInstanceCount** (int64) - Optional - The number of inactive instances. - **IsAppVersionLocked** (bool) - Optional - Flag indicating if the application version is locked. - **IsInstanceTracked** (bool) - Optional - Flag indicating if instances are tracked. - **LastSync** (time.Time) - Optional - The last synchronization time. - **LicenseType** (string) - Optional - The type of the license. - **LicenseVersions** (LicenseVersions) - Optional - Version information for the license. - **LockedAppVersion** (int64) - Optional - The locked application version number. - **RequireActivation** (bool) - Optional - Flag indicating if license activation is required. - **RevokationDate** (time.Time) - Optional - The date the license was revoked. - **UntrackedInstanceCount** (int64) - Optional - The number of untracked instances. - **UpdatePolicy** (string) - Optional - The update policy for the license. - **UseConsoleSupportSpec** (bool) - Optional - Flag indicating if console support specifications are used. ### Notes - Default values are `null` for most optional fields. - References to other models like `LicenseBilling.md` indicate nested objects. ``` -------------------------------- ### Configure Replicated CLI Authentication Source: https://context7.com/replicatedhq/replicated/llms.txt Sets environment variables for API token and optionally the default application slug or ID. The API token is essential for authenticating with the Replicated Vendor API and can be obtained from the Replicated vendor portal. ```bash # Set your API token (create one at https://vendor.replicated.com/account-settings) export REPLICATED_API_TOKEN=your_api_token_here # Optionally set default app export REPLICATED_APP=your_app_slug_or_id ``` -------------------------------- ### Configure Preflight Chart Reference Source: https://github.com/replicatedhq/replicated/blob/main/docs/lint-format.md Defines the chart name and version required for rendering preflight templates. Both `chartName` and `chartVersion` are mandatory and must align with the chart's `Chart.yaml`. ```yaml charts: - path: "./chart" preflights: - path: "./preflight.yaml" chartName: "my-chart" # Must match chart name in Chart.yaml chartVersion: "1.0.0" # Must match chart version in Chart.yaml ``` -------------------------------- ### Regenerate Client Code from Swagger Spec Source: https://github.com/replicatedhq/replicated/blob/main/README.md This command regenerates client code based on the project's swagger definitions. It is used when API specifications change to ensure the client libraries are up-to-date. Note that models for the v2 API may not be fully functional yet. ```makefile make get-spec-prod gen-models ``` -------------------------------- ### Configure HelmChart Manifest Paths Source: https://github.com/replicatedhq/replicated/blob/main/docs/lint-format.md Specifies the locations for `HelmChart` manifests within the Replicated configuration. The `manifests` section is mandatory when `charts` are configured. ```yaml charts: - path: "./charts/my-app" - path: "./charts/my-api" manifests: - "./manifests/**/*.yaml" # HelmChart manifests must be in these paths ``` -------------------------------- ### AppReleaseInfo Model Source: https://github.com/replicatedhq/replicated/blob/main/gen/go/v1/docs/AppReleaseInfo.md Details the properties of the AppReleaseInfo model. ```APIDOC ## AppReleaseInfo Model ### Description Represents information about an application release, including its channels, version, creation time, and preflight checks. ### Properties - **ActiveChannels** ([]AppChannel) - Optional - The active channels. - **AppId** (string) - Optional - The application ID. - **CreatedAt** (time.Time) - Optional - The time at which the release was created. - **Editable** (bool) - Optional - If the release is editable. - **EditedAt** (time.Time) - Optional - The last time at which the release was changed. - **PreflightChecks** ([]PreflightCheck) - Optional - Release preflight checks. - **Sequence** (int64) - Optional - The app sequence number. - **Version** (string) - Optional - The vendor supplied version. ### Request Body Example ```json { "ActiveChannels": [ { "name": "string", "uri": "string" } ], "AppId": "string", "CreatedAt": "2023-10-27T10:00:00Z", "Editable": true, "EditedAt": "2023-10-27T10:00:00Z", "PreflightChecks": [ { "apiEndpoint": "string", "command": "string", "args": [ "string" ], "timeoutSeconds": 0, " செய்யப்பட்டது": "string" } ], "Sequence": 0, "Version": "string" } ``` ### Response Body Example ```json { "ActiveChannels": [ { "name": "string", "uri": "string" } ], "AppId": "string", "CreatedAt": "2023-10-27T10:00:00Z", "Editable": true, "EditedAt": "2023-10-27T10:00:00Z", "PreflightChecks": [ { "apiEndpoint": "string", "command": "string", "args": [ "string" ], "timeoutSeconds": 0, " செய்யப்பட்டது": "string" } ], "Sequence": 0, "Version": "string" } ``` ``` -------------------------------- ### Access Application with Kubernetes ClusterIP Service Source: https://github.com/replicatedhq/replicated/blob/main/testdata/chart-with-required-values/charts/required-values/templates/NOTES.txt This snippet facilitates access to an application using a Kubernetes ClusterIP service by setting up port-forwarding. It retrieves the pod name and container port and then forwards a local port (8080) to the container port. Requires kubectl access. ```Shell {{- else if contains "ClusterIP" .Values.service.type }} export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "required-values.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") echo "Visit http://127.0.0.1:8080 to use your application" kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT {{- end }} ``` -------------------------------- ### Generate Documentation Source: https://github.com/replicatedhq/replicated/blob/main/README.md This command generates updated documentation, typically after changes to CLI commands or parameters. It creates a pull request to the replicated-docs repository for review and merging, ensuring documentation stays in sync with the codebase. ```bash make docs ```