Skip to content

SaaShup/paashup-cli

Repository files navigation

paashup-cli

paashup-cli is a command-line tool for managing your paashup environment, including Docker containers, hosts, images, and Netbox configurations. This tool provides various commands to list, inspect, start, stop, and execute operations on Docker containers, as well as managing Docker hosts, images, and Netbox configurations.

Build

using docker:

docker run -it --rm -v ./:/go golang:1.22 go build -buildvcs=false -ldflags "-X main.version=<VERSION> -X main.PLATFORM_URL=<PLATFORM_URL> -X main.PLATFORM_PUB_KEY=<PUB_KEY>" -o bin/ ./...

Installation

To install paashup-cli, ensure you have Go installed and run:

go get github.com/saashup/paashup-cli

Setup

First you need to define the netbox source:

paashup-cli netbox set-config name http://netbox.local mytoken

For autocompletion, download the completion script (autocompletion.bash) and then source it like this:

PROG=paashup-cli source autocompletion.bash

Documentation Generation

For Stack jsonschema generation, you can use the following command:

paashup-cli doc jsonschema 

Usage

paashup-cli provides multiple commands categorized under platforms, Docker resources, Netbox configurations, and stack deployments.

Global Flags

  • --format, -f: Choose between yaml, json, or json-pretty formats. Default is json.

Commands Overview

The CLI is structured with several main commands, each with its own set of subcommands.

1. Platform Commands

Manage platforms within your paashup environment.

  • Create an Account

    paashup-cli platform account create <username> <password>

    Creates a new account. Example:

    paashup-cli platform account create user1 password123
  • Login in Platform

    paashup-cli platform login <username> <password>
  • Initialize a Platform

    paashup-cli platform init

    Initializes a platform. Example:

    paashup-cli platform init
  • List Platforms

    paashup-cli platform ls

2. Netbox Commands

Manage Netbox configurations for your paashup environment.

  • Set Netbox Configuration

    paashup-cli netbox set-config NAME NETBOX_URL NETBOX_TOKEN

    Sets a Netbox configuration. Example:

    paashup-cli netbox set-config myconfig http://netbox.example.com token123
  • Use Netbox Configuration

    paashup-cli netbox use NAME

    Selects a Netbox configuration by name. Example:

    paashup-cli netbox use myconfig

3. Stack Commands

Manage and deploy stacks.

  • Deploy a Stack

    paashup-cli stack deploy YAMLFILE

    Deploys a stack from a YAML file. Example:

    paashup-cli stack deploy stack.yaml

4. Docker Commands

Manage Docker resources including containers, hosts, images, volumes, and registries.

  • Docker Container Commands

    • List Containers

      paashup-cli docker container ls [hostname]

      Lists all containers. Example:

      paashup-cli docker container ls myhost
    • Get Logs

      paashup-cli docker container logs <hostname> <containername>

      Fetches logs for a specific container. Example:

      paashup-cli docker container logs myhost mycontainer
    • Start a Container

      paashup-cli docker container start [--nowait] <hostname> <containername>

      Starts a specific container. Example:

      paashup-cli docker container start --nowait myhost mycontainer
    • Stop a Container

      paashup-cli docker container stop [--nowait] <hostname> <containername>

      Stops a specific container. Example:

      paashup-cli docker container stop --nowait myhost mycontainer
    • Inspect a Container

      paashup-cli docker container inspect <hostname> <containername>

      Inspects a specific container. Example:

      paashup-cli docker container inspect myhost mycontainer
    • Execute Command in a Container

      paashup-cli docker container exec <hostname> <containername> '<command>'

      Executes a command within a specific container. Example:

      paashup-cli docker container exec myhost mycontainer 'ls -la'
  • Docker Host Commands

    • List Hosts

      paashup-cli docker host ls

      Lists all hosts. Example:

      paashup-cli docker host ls
    • Inspect a Host

      paashup-cli docker host inspect <hostname>

      Inspects a specific host. Example:

      paashup-cli docker host inspect myhost
  • Docker Image Commands

    • List Images

      paashup-cli docker image ls

      Lists all images. Example:

      paashup-cli docker image ls
  • Docker Volume Commands

    • List Volumes

      paashup-cli docker volume ls

      Lists all volumes. Example:

      paashup-cli docker volume ls
  • Docker Registry Commands

    • List Registries

      paashup-cli docker registry ls

      Lists all registries. Example:

      paashup-cli docker registry ls

Example Workflows

Set Up a New Environment

  1. Set Netbox Configuration

    paashup-cli netbox set-config myconfig http://netbox.example.com token123
  2. Initialize a Platform

    paashup-cli platform init
  3. Deploy a Stack

    paashup-cli stack deploy stack.yaml

Manage Docker Containers

  1. List All Containers

    paashup-cli docker container ls
  2. Start a Container

    paashup-cli docker container start --nowait myhost mycontainer
  3. Get Logs from a Container

    paashup-cli docker container logs myhost mycontainer

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.