Skip to content

nullplatform/onboarding-setup-cli

Repository files navigation

Nullplatform Setup CLI

A wizard-style CLI tool for setting up nullplatform infrastructure with Terraform file generation.

Features

  • Interactive wizard interface with keyboard navigation
  • YAML-based question configuration with conditional logic
  • Multiple question types: select, multi-select, text input, and more
  • Configuration management with local storage and environment variable overrides
  • Review and edit functionality before generation
  • Automatic Terraform file generation
  • Support for multiple setup wizards (cluster, organization, scope)

Prerequisites

  • Go 1.21 or higher
  • Terminal with color support

Installation

# Clone the repository
git clone https://github.com/nullplatform/nullplatform-setup-cli.git
cd nullplatform-setup-cli

# Install dependencies
go mod download

# Build the application
go build -o nullplatform-setup .

Configuration

The application requires two pieces of configuration:

  1. Organization ID - Your nullplatform organization ID
  2. API Key - Your nullplatform API key

Configuration Priority (highest to lowest):

  1. Environment variables:

    • NP_ORGANIZATION_ID
    • NP_API_KEY
  2. Local configuration file:

    • Stored in ~/.np/nullplatform-setup-cli/config.json

If no configuration is found, the application will prompt you to set it up on first run.

Setting Configuration via Environment Variables

export NP_ORGANIZATION_ID="your-org-id"
export NP_API_KEY="your-api-key"
./nullplatform-setup

Usage

Running the Application

./nullplatform-setup

Main Menu

The main menu presents three wizard options:

  1. Setup my organization on nullplatform - Configure organization settings
  2. Setup a cluster (K8s) - Configure a Kubernetes cluster with full options
  3. Setup a scope - Configure an application scope

Navigation

Main Menu

  • ↑/↓ or j/k - Navigate through options
  • Enter - Select wizard
  • C - Change organization/API key configuration
  • Q - Quit

Within Wizards

  • ↑/↓ or j/k - Navigate through options
  • Space - Toggle selection (for multi-select questions)
  • Enter - Confirm selection and move to next question
  • Esc - Go back to previous question
  • Ctrl+C - Cancel and return to main menu

Review Screen

  • Enter - Generate Terraform files
  • E - Edit (return to first question)
  • X - Cancel

Question Schema

Questions are defined in YAML format in the schemas/wizards.yaml file.

Example Question Definition

wizards:
  - id: setup-cluster
    name: Setup a cluster (K8s)
    description: Configure a Kubernetes cluster
    questions:
      - id: cluster_provider
        type: select
        prompt: "Select the cluster provider:"
        required: true
        options:
          - value: aws-eks
            label: AWS EKS
          - value: azure-aks
            label: Azure AKS

      - id: dns_provider
        type: select
        prompt: "Which DNS provider will be used?"
        required: true
        options:
          - value: route53
            label: AWS Route 53
            condition:
              question: cluster_provider
              equals: aws-eks
          - value: cloudflare
            label: Cloudflare

Question Types

  • select - Single selection from options
  • multi-select - Multiple selections from options
  • input - Text input
  • multiple-input - Multiple text inputs (e.g., for forms)
  • confirm - Yes/No confirmation

Conditional Logic

Options and questions can have conditions based on previous answers:

condition:
  question: cluster_provider
  equals: aws-eks  # Show only if cluster_provider equals "aws-eks"

Or:

condition:
  question: cluster_provider
  oneOf: [aws-eks, aws-openshift]  # Show if value is one of these

Output

The application generates Terraform files in a timestamped directory:

setup-a-cluster-k8s-20240115-143022/
├── main.tf
├── variables.tf
└── providers.tf

Generated Files

  • main.tf - Main resource definitions based on your answers
  • variables.tf - Variable definitions including organization ID
  • providers.tf - Provider configuration for nullplatform and other providers

Project Structure

.
├── main.go                    # Application entry point
├── go.mod                     # Go module definition
├── schemas/
│   └── wizards.yaml          # Question definitions
├── internal/
│   ├── app/
│   │   └── app.go            # Application orchestration
│   ├── config/
│   │   └── config.go         # Configuration management
│   ├── schema/
│   │   └── schema.go         # Schema loading and validation
│   ├── ui/
│   │   ├── config_setup.go   # Configuration setup screen
│   │   ├── main_menu.go      # Main menu screen
│   │   └── wizard.go         # Wizard flow implementation
│   └── generator/
│       └── generator.go      # Terraform file generation
└── README.md

Customization

Adding New Wizards

  1. Add a new wizard definition to schemas/wizards.yaml
  2. Implement the Terraform generation logic in internal/generator/generator.go
  3. The wizard will automatically appear in the main menu

Adding Custom Validation

To add custom validation for organization ID and API key:

Edit internal/config/config.go in the IsValid() method:

func (c *Config) IsValid() (bool, error) {
    // Add your validation logic here
    // Example: Call an API to verify credentials
    if err := validateWithAPI(c.OrganizationID, c.APIKey); err != nil {
        return false, fmt.Errorf("invalid credentials: %w", err)
    }
    return true, nil
}

Dependencies

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published