Skip to content
/ cockpit Public

Cockpit is CLI tool that communicate with project Constellations gateway.

License

Notifications You must be signed in to change notification settings

c12s/cockpit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cockpit CLI Documentation

Cockpit CLI is a command-line interface (CLI) tool designed for managing various resources within the Cockpit project. This CLI facilitates user registration, node management, labeling, schema validation, configuration management, and more. The goal of this tool is to provide an easy-to-use and maintainable interface for interacting with the Cockpit project's resources.

Features

  • User Management: Register and login to the system.
  • Node Management: List, query, and claim nodes based on specific criteria.
  • Label Management: Add, update, and delete labels for nodes.
  • Schema Management: Create, retrieve, validate, and delete schemas.
  • Configuration Management: Manage both config groups and standalone configs, including placing, listing, and diffing configurations.

Table of Contents

Prerequisites

Ensure you have the following installed:

  • Go (version 1.16 or higher)
  • Git
  • Docker (for running the complete environment)

Additionally, you need to clone and set up the tools repository from https://github.com/c12s/tools, which includes scripts to pull all other repositories and start Docker containers.

Installation

  1. Clone the tools repository:

    git clone https://github.com/c12s/tools.git
  2. Navigate to the tools directory and follow the setup instructions in the README.md file of the tools repository to pull all necessary repositories and start Docker containers:

    cd tools
    ./install.sh
    ./start.sh

    or for Windows:

    ./start-windows.sh
  3. Clone the cockpit repository in the same parent directory where the tools repository is located:

    cd ..
    git clone https://github.com/bunjo01/cockpit.git
  4. Navigate to the cockpit project directory:

    cd cockpit
  5. Build the CLI:

    go build -o cockpit
  6. Add the executable to your PATH:

  • On Linux/macOS:

    export PATH=$PATH:$(pwd)
  • On Windows (Command Prompt):

    set PATH=%PATH%;%cd%
  • On Windows (PowerShell):

    $env:PATH += ";$PWD"

Command Reference

User Management

Register

Register a new user.

  • Command: cockpit register

  • Options:

    • --email: Email address of the user.
    • --name: Name of the user.
    • --org: Organization of the user.
    • --surname: Surname of the user.
    • --username: Username of the user.
  • Example:

    cockpit register --email 'user@gmail.com' --name 'name' --org 'c12s' --surname 'surname' --username 'user'

Login

Login with an existing user.

  • Command: cockpit login

  • Options:

    • --username: Username of the user.
  • Example:

    cockpit login --username 'user'

Node Management

List Nodes

List all nodes.

  • Command: cockpit list nodes

  • Options:

    • --query: Query to filter nodes.
  • Example:

    cockpit list nodes
    cockpit list nodes --query 'memory-totalGB > 2'

Claim Nodes

Claim nodes based on specific criteria.

  • Command: cockpit claim nodes

  • Options:

    • --org: Organization.
    • --query: Query to filter nodes.
  • Example:

    cockpit claim nodes --org 'c12s' --query 'memory-totalGB > 2'

List Allocated Nodes

List nodes allocated to an organization.

  • Command: cockpit list nodes allocated

  • Options:

    • --org: Organization.
    • --query: Query to filter nodes.
  • Example:

    cockpit list nodes allocated --org 'c12s'
    cockpit list nodes allocated --org 'c12s' --query 'memory-totalGB > 2'

Relationship Management

Create Relations

Create relations between entities.

  • Command: cockpit create relations

  • Options:

    • --ids: IDs of the entities.
    • --kinds: Kinds of the entities.
  • Example:

    cockpit create relations --ids 'c12s|dev' --kinds 'org|namespace'

Label Management

Add Label

Add a label to a node.

  • Command: cockpit put label

  • Options:

    • --org: Organization of the node.
    • --node-id: ID of the node.
    • --key: Key of the label.
    • --value: Value of the label.
  • Example:

    cockpit put label --org 'c12s' --node-id 'nodeId' --key 'newlabel' --value '25.00'

Delete Label

Delete a label from a node.

  • Command: cockpit delete label

  • Options:

    • --org: Organization of the node.
    • --nodeId: ID of the node.
    • --key: Key of the label.
  • Example:

    cockpit delete label --org 'c12s' --node-id 'nodeId' --key 'newlabel'

Schema Management

Create Schema

Create a new schema.

  • Command: cockpit create schema

  • Options:

    • --org: Organization.
    • --schema-name: Name of the schema.
    • --version: Version of the schema.
    • --path: Path to the schema file.
  • Example:

    cockpit create schema --org 'c12s' --schema-name 'schema' --version 'v1.0.0' --path 'request/schema/create-schema.yaml'

Get Schema Version

Retrieve schema version details.

  • Command: cockpit get schema version

  • Options:

    • --org: Organization.
    • --schema: Name of the schema.
  • Example:

    cockpit get schema version --org 'c12s' --schema-name 'schema'

Get Schema

Retrieve a specific schema.

  • Command: cockpit get schema

  • Options:

    • --org: Organization.
    • --schema: Name of the schema.
    • --version: Version of the schema.
  • Example:

    cockpit get schema --org 'c12s' --schema-name 'schema' --version 'v1.0.0'

Validate Schema

Validate a schema.

  • Command: cockpit validate schema

  • Options:

    • --org: Organization.
    • --schema: Name of the schema.
    • --version: Version of the schema.
    • --path: Path to the validation file.
  • Example:

    cockpit validate schema --org 'c12s' --schema-name 'schema' --version 'v1.0.0' --path 'request/schema/validate-schema.yaml'

Delete Schema

Delete a schema.

  • Command: cockpit delete schema

  • Options:

    • --org: Organization.
    • --schema: Name of the schema.
    • --version: Version of the schema.
  • Example:

    cockpit delete schema --org 'c12s' --schema-name 'schema' --version 'v1.0.0'

Config Group Management

Add Config Group

Add a configuration group.

  • Command: cockpit put config group

  • Options:

    • --path: Path to the config group file.
  • Example:

    cockpit put config group --path 'request/config-group/create-config-group.yaml'

Get Config Group

Retrieve a configuration group.

  • Command: cockpit get config group

  • Options:

    • --org: Organization.
    • --name: Name of the config group.
    • --version: Version of the config group.
    • --output: Output format (json, yaml).
  • Example:

    cockpit get config group --org 'c12s' --name 'app_config' --version 'v1.0.1'

List Config Groups

List all configuration groups.

  • Command: cockpit list config group

  • Options:

    • --org: Organization.
    • --output: Output format (json, yaml).
  • Example:

    cockpit list config group --org 'c12s'

Diff Config Groups

Compare differences between configuration groups.

  • Command: cockpit diff config group

  • Options:

    • --org: Organization.
    • --names: Names of the config groups.
    • --versions: Versions of the config groups.
    • --output: Output format (json, yaml).
  • Example:

    cockpit diff config group --org 'c12s' --names 'app_config|app_config' --versions 'v1.0.0|v1.0.1'
    cockpit diff config group --org 'c12s' --names 'app_config' --versions 'v1.0.0|v1.0.1'
    cockpit diff config group --org 'c12s' --names 'app_config|app_config' --versions 'v1.0.0'

Place Config Group

Place a configuration group.

  • Command: cockpit place config group

  • Options:

    • --path: Path to the placement file.
  • Example:

    cockpit place config group --path 'request/config-group/create-config-group-placements.yaml'

List Config Group Placements

List all placements of a configuration group.

  • Command: cockpit list config group placements

  • Options:

    • --org: Organization.
    • --name: Name of the config group.
    • --version: Version of the config group.
  • Example:

    cockpit list config group placements --org 'c12s' --name 'app_config' --version 'v1.0.0'

Delete Config Group

Delete a configuration group.

  • Command: cockpit delete config group

  • Options:

    • --org: Organization.
    • --name: Name of the config group.
    • --version: Version of the config group.
    • --output: Output format (json, yaml).
  • Example:

    cockpit delete config group --org 'c12s' --name 'app_config' --version 'v1.0.1'

Standalone Config Management

Add Standalone Config

Add a standalone configuration.

  • Command: cockpit put standalone config

  • Options:

    • --path: Path to the config file.
  • Example:

    cockpit put standalone config --path 'request/standalone-config/create-standalone-config.json'

Get Standalone Config

Retrieve a standalone configuration.

  • Command: cockpit get standalone config

  • Options:

    • --org: Organization.
    • --name: Name of the config.
    • --version: Version of the config.
    • --output: Output format (json, yaml).
  • Example:

    cockpit get standalone config --org 'c12s' --name 'db_config' --version 'v1.0.1'

List Standalone Configs

List all standalone configurations.

  • Command: cockpit list standalone config

  • Options:

    • --org: Organization.
    • --output: Output format (json, yaml).
  • Example:

    cockpit list standalone config --org 'c12s'

Diff Standalone Configs

Compare differences between standalone configurations.

  • Command: cockpit diff standalone config

  • Options:

    • --org: Organization.
    • --names: Names of the configs.
    • --versions: Versions of the configs.
    • --output: Output format (json, yaml).
  • Example:

    cockpit diff standalone config --org 'c12s' --names 'db_config|db_config' --versions 'v1.0.1|v1.0.0'
    cockpit diff standalone config --org 'c12s' --names 'db_config' --versions 'v1.0.1|v1.0.0'
    cockpit diff standalone config --org 'c12s' --names 'db_config|db_config' --versions 'v1.0.1'

Place Standalone Config

Place a standalone configuration.

  • Command: cockpit place standalone config

  • Options:

    • --path: Path to the placement file.
  • Example:

    cockpit place standalone config --path 'request/standalone-config/create-standalone-config-placements.yaml'

List Standalone Config Placements

List all placements of a standalone configuration.

  • Command: cockpit list standalone config placements

  • Options:

    • --org: Organization.
    • --name: Name of the config.
    • --version: Version of the config.
  • Example:

    cockpit list standalone config placements --org 'c12s' --name 'db_config' --version 'v1.0.0'

Delete Standalone Config

Delete a standalone configuration.

  • Command: cockpit delete standalone config

  • Options:

    • --org: Organization.
    • --name: Name of the config.
    • --version: Version of the config.
    • --output: Output format (json, yaml).
  • Example:

    cockpit delete standalone config --org 'c12s' --name 'db_config' --version 'v1.0.1'

Node Metrics Management

Get Node Metrics

Retrieve metrics for a specific node.

  • Command: cockpit get node metrics

  • Options:

    • --node-id: Node ID (required).
    • --all: Display all metrics (optional).
    • --sort: Sort metrics by 'cpu', 'memory', 'disk', 'network receive', 'network transmit' or 'bandwidth'.
  • Example:

    cockpit get node metrics --node-id 'nodeID'
    cockpit get node metrics --node-id 'nodeID' --all --sort 'memory'

Contributing

Contributions are welcome! Please follow these steps to contribute:

  1. Fork the repository.

  2. Create a new branch:

    git checkout -b feature/YourFeature
  3. Make your changes.

  4. Commit your changes:

    git commit -m 'Add new feature'
  5. Push to the branch:

    git push origin feature/YourFeature
  6. Open a pull request and describe your changes.

License

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

About

Cockpit is CLI tool that communicate with project Constellations gateway.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published