ocfp-cli

module
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: Apache-2.0

README

OCFP CLI - Go Implementation

A command-line interface for the Open Cloud Foundry Platform (OCFP), rewritten in Go for improved speed, cross-platform compatibility, and maintainability.

Features

  • Multi-Cloud Support: Works with STACKIT, OpenStack, AWS, Azure, GCP, and VMware
  • Infrastructure Management: Bootstrap, configure, and teardown cloud infrastructure
  • SSH/SCP/Rsync: Secure access and file transfer to bastion hosts
  • Environment Management: Switch between multiple deployment environments
  • High Performance: 2x faster than the original Perl implementation
  • Cross-Platform: Native binaries for Linux, macOS, and Windows
  • Plugin Architecture: Extensible provider system for adding new cloud platforms

Installation

From Source
# Clone the repository
git clone https://github.com/fivetwenty-io/ocfp-cli.git
cd ocfp-cli

# Build the binary
make build

# Install to system (optional)
make install
Pre-built Binaries

Download the latest release from the releases page. Each release ships signed and notarized macOS builds, Linux and Windows archives for amd64 and arm64, deb and rpm packages, and a SHA256SUMS file.

Using Homebrew (macOS/Linux)
brew install --cask fivetwenty-io/tap/ocfp

Quick Start

1. Configure your environment

Create a configuration file at ~/.config/ocfp/config.yml (provider comes from bloc config):

name: production
provider: stackit
region: eu01  # For STACKIT, defaults to eu01 if omitted
project_id: your-project-id
auth_token: your-auth-token
network:
  name: ocfp-network
  cidr: 10.0.0.0/16
bastion:
  flavor: m1.small
  image: ubuntu-22.04
  keypair: bastion-key
2. Bootstrap infrastructure
# Bootstrap cloud infrastructure
ocfp bootstrap --bloc production

# Configure networking and security
ocfp configure --bloc production

Runs of ocfp configure made before rule matching normalized direction and addresses could leave exact duplicate security group rules behind. To clean them up, list them first and then delete them.

# List the duplicates in ocfp-owned groups; this changes nothing
ocfp configure --bloc production --prune-duplicate-rules

# Delete them, highest rule position first
ocfp configure --bloc production --prune-duplicate-rules --apply

The prune option works only on PVE blocs, because it deletes rules by the numeric position PVE reports, and it stops with an error on any other provider before it lists anything. It runs on its own, so it cannot be combined with --dry-run or the --skip-* options, and --apply is only valid with it. Rules are twins only when direction, protocol, port range, remote address, comment, and every other field the rule carries match after normalization. The lowest position in each set of twins is always kept, so the last copy of a rule is never removed. Only groups named <bloc>-<name> that ocfp defines rules for are touched. Before each delete the command re-lists the group, and it stops with an error if the rule at the next position is not the duplicate it expected.

Labs bootstrapped before 2026-09-14 created the Proxmox role OCFPCpi without Pool.Audit, and the CPI's pools preflight fails without it. We can check any lab's role with --check-cpi-role, which reads the role through pmx.

# Report missing privileges; exits non-zero when any are missing
ocfp configure --check-cpi-role

# Add the missing privileges, then read the role again to confirm
ocfp configure --check-cpi-role --apply

# Pick the PVE cluster explicitly when pmx knows several
ocfp configure --check-cpi-role --pmx-context lab-b

The output names the pmx context and endpoint it checked, which privileges are missing, and the exact pmx pve access role set command that --apply would run. That command always carries --append, so it only adds privileges and never removes one. Privileges the role holds beyond the required list are shown for information and are never treated as wrong. If the role does not exist the command stops with an error that points at the runbook, because ocfp does not create the role. The check runs on its own and returns before any provisioning, so it cannot be combined with --prune-duplicate-rules, --dry-run, or the --skip-* options. It needs pmx on the PATH, and --pmx-context is passed to pmx as -c. The check uses the pmx context and never reads the bloc config, so --bloc does not pick the cluster. When PMX_API_ENDPOINT is set, pmx talks to that endpoint instead of the context's, and the output reports it.

3. Access bastion host
# SSH to bastion
ocfp ssh --bloc production

# SSH to the artifacts VM, hopping through the bastion
ocfp ssh --bloc production artifacts

# Copy files
ocfp scp local-file.txt bastion:/tmp/

# Sync directories
ocfp rsync --archive /local/dir/ bastion:/remote/dir/

# Hand rsync any flag we do not model, after a -- separator
ocfp rsync /local/dir/ bastion:/remote/dir/ -- --itemize-changes --info=progress2

These commands log in with the bloc's own SSH key when it is on your machine, and --key <path> picks another key. When neither is there, they say so in one line and fall back to plain ssh, so your ssh-agent, your default keys, and your ssh config decide how to log in, for example your own key on the bastion or Tailscale SSH.

4. Environment management
# List environments
ocfp env list

# Switch environment
ocfp env set production

# Show environment details
ocfp env show

# Export environment variables
eval $(ocfp env export)
Inspecting blocs

Before we change anything, it helps to see which blocs ocfp knows about. The bloc command is read-only, so we can run it any time without touching config, state, or infrastructure.

# List every bloc found in config and state
ocfp bloc list

# The same data as JSON, for scripts
ocfp bloc list --json

# Summarize one bloc, or the current bloc when we leave the name off
ocfp bloc show ocfp-lab-wayneeseguin

# Add the power state of the bastion and artifacts VMs from the provider
ocfp bloc show ocfp-lab-wayneeseguin --live

ocfp bloc list merges every place a bloc can be defined into one row per bloc. Those places are the blocs: map in each config file the CLI searches, flat config files with a top-level name and provider, and the per-bloc state directories under both the XDG state home and the legacy ~/.ocfp home. The SOURCE column says whether a bloc has config, state, or both, and a state file that exists but cannot be parsed shows up as broken instead of disappearing. The CURRENT column marks the bloc ocfp resolves as current. ocfp env list reads the same inventory, so the two commands agree.

ocfp bloc show prints a Bloc, Config, and State section. The Config section lists only an allowlist of safe fields, and the State section reports counts and a few names, so the output never includes tokens, keys, or passwords. With --live, the command makes read-only provider calls and adds a Live section. A live call that fails appears in that section and never hides the local output, and --live still works when artifacts is disabled for the bloc. Both commands accept --json.

Unicode vs ASCII Tables

The CLI renders rich Unicode box-drawn tables by default. If your terminal/font does not display these cleanly, enable ASCII-only tables globally with either of:

  • CLI flag: --ascii (e.g., ocfp --ascii bootstrap --bloc production --dry-run)
  • Environment variable: OCFP_ASCII=true
Global Flags
Flag Shorthand Description Env Var Default
--config -f Config file path OCFP_CONFIG –
--bloc – Bloc/environment name (key under blocs:) OCFP_BLOC –
--debug -d Enable debug output OCFP_DEBUG false
--verbose -v Enable verbose output OCFP_VERBOSE false
--trace – Enable trace-level debugging OCFP_TRACE false
--no-log – Disable logging to ~/.local/state/ocfp/{bloc}/logs/ OCFP_NO_LOG false
--region – Cloud region OCFP_REGION –
--debug-lookup – Print bastion lookup strategy matches OCFP_DEBUG_LOOKUP false
--ascii – Use ASCII-only tables in output OCFP_ASCII false

Commands

Core Commands
Command Description
bootstrap Provision cloud infrastructure (network, subnets, security groups, bastion)
configure Apply configuration to provisioned resources
teardown Remove cloud infrastructure (with dependency awareness)
ssh Connect to bastion host via SSH
scp Copy files to/from bastion
rsync Synchronize files with bastion
env Manage deployment environments
bloc List the blocs ocfp knows about and show a safe summary of one, with optional read-only live provider checks
Management Commands
Command Description
init Initialize OCFP components (PostgreSQL, CF, BOSH)
test Run validation suites against the CF foundation (see docs/commands/test.md)
vault Manage secrets in Vault
endpoints List DNS/endpoint facts for a bloc (see docs/networking/endpoints.md)
lb Load balancer management (see go/docs/cmds/lb.md)
scale Scale resources
backup Backup configurations
restore Restore from backup
config migrate Move a legacy ~/.ocfp layout into the XDG config/state/data directories
artifacts Manage the artifacts VM with the actions lookup, status, disks, provision, ca, start, stop, restart, and destroy
Checking disk discard on PVE

A managed data disk on thin storage needs discard=on, or its pool never gets freed blocks back. Artifacts VMs created before the fix carry their data disk without it, and an overfull thin pool gives every VM on it write errors. The disks action checks the artifacts VM and the bastion and prints a verdict for each root and data disk.

# Report each disk's pool type, discard state, and verdict; exits non-zero on drift
ocfp artifacts disks --bloc production

# Add discard=on to each data disk that lacks it, keeping every other option
ocfp artifacts disks --bloc production --fix

The verdicts are ok, missing-on-thin, pending-restart, pending-delete, thick-not-needed, and unknown-pool. The discard column shows what the running VM uses, so a disk whose discard=on is queued for the next cold start reads as pending-restart rather than ok. A disk whose removal is queued reads as pending-delete, and --fix leaves it alone. The command exits non-zero when a managed data disk on thin storage lacks discard, or when it can't read a VM's disks or find and classify its data disk. A pending-restart or pending-delete disk doesn't fail the check.

Root disks are shown for information only, and --fix never changes them. The fix writes the disk's config on the node it was read from, under the digest it just read, so it fails rather than overwrite a config that changed in between. It never stops, starts, or reboots a VM. Afterwards the command reads the disk again and says what happened. A stopped VM takes the change at once, and a running VM needs a cold stop and start, because a guest reboot does not reload the disk config. The disk's data is untouched, and the guest still has to trim, which re-running ocfp artifacts provision sets up with fstrim.timer. ocfp artifacts status shows a one-line warning when a managed data disk is missing discard or has it only pending.

State Management

The state command provides operations for viewing and synchronizing infrastructure state.

Viewing State

Display current infrastructure state for a bloc:

# Display all resources (default)
ocfp state --bloc dev

# Display specific resource types
ocfp state --bloc dev --servers
ocfp state --bloc dev --volumes --buckets
ocfp state --bloc dev --networks --subnets --security-groups
State Sync

Reconcile cloud infrastructure into state file:

# Sync all resources
ocfp state sync --bloc dev

# Preview sync changes without applying
ocfp state sync --bloc dev --dry-run

# Sync specific resource types
ocfp state sync --bloc dev --servers --volumes
ocfp state sync --bloc dev --networks --subnets --security-groups --dry-run
Resource Filtering Flags

By default, all resources are displayed. Use flags to filter specific resource types:

Flag Aliases Description
--all – Show all resources (default)
--servers --instances Show compute instances
--volumes – Show block volumes
--buckets – Show object storage buckets
--load-balancers --lbs Show load balancers
--public-ips – Show public IP addresses
--keys --key-pairs Show SSH key pairs
--networks --nets Show networks/VPCs
--subnets – Show subnets
--security-groups --sgs Show security groups
--routers – Show routers
--snapshots – Show volume snapshots

Multiple flags can be combined to show multiple resource types:

# Show compute and storage resources
ocfp state --bloc dev --servers --volumes --buckets

# Show network infrastructure
ocfp state --bloc dev --networks --subnets --security-groups

# Sync only specific resources
ocfp state sync --bloc dev --servers --volumes --dry-run

Each resource type is displayed in a separate table with emoji icons for easy identification:

  • 💻 Compute Instances
  • 💾 Block Volumes
  • 🗄️ Object Storage Buckets
  • ⚖️ Load Balancers
  • 🌐 Public IPs
  • 🔑 SSH Key Pairs
  • 📡 Networks
  • 🔌 Subnets
  • 🔒 Security Groups
  • 🔄 Routers
  • 📸 Volume Snapshots

Logging

OCFP stores command logs in a bloc-specific hierarchical structure under ~/.local/state/ocfp/ (or $XDG_STATE_HOME/ocfp if set):

~/.local/state/ocfp/
  ├── {bloc}/
  │   └── logs/
  │       ├── {command}/
  │       │   └── {timestamp}.log
  │       └── {command}/
  │           └── {subcommand}/
  │               └── {timestamp}.log
  └── logs/  # For commands without --bloc flag
      ├── {command}/
      │   └── {timestamp}.log
      └── {command}/
          └── {subcommand}/
              └── {timestamp}.log
Examples
  • Simple command with bloc: ocfp --bloc dev bootstrap

    • Logs to: ~/.local/state/ocfp/dev/logs/bootstrap/20250122-143022.log
  • Subcommand with bloc: ocfp --bloc prod state sync

    • Logs to: ~/.local/state/ocfp/prod/logs/state/sync/20250122-143022.log
  • Command without bloc: ocfp teardown

    • Logs to: ~/.local/state/ocfp/logs/teardown/20250122-143022.log
  • Complex subcommand: ocfp --bloc staging lb ops

    • Logs to: ~/.local/state/ocfp/staging/logs/lb/ops/20250122-143022.log

Logs are stored in JSON format for structured parsing and contain:

  • Timestamp
  • Log level
  • Message
  • Contextual fields (bloc, operation, request ID, etc.)

To disable file logging, use the --no-log flag or set OCFP_NO_LOG=true.

Configuration

File Locations

OCFP uses XDG Base Directory specification for organizing configuration, state, and data files. By default:

  • Configuration: ~/.config/ocfp/ (or $XDG_CONFIG_HOME/ocfp)
  • State & Logs: ~/.local/state/ocfp/ (or $XDG_STATE_HOME/ocfp)
  • Data (SSH keys, bloc state): ~/.local/share/ocfp/ (or $XDG_DATA_HOME/ocfp)

For backward compatibility, OCFP looks for files in the legacy ~/.ocfp/ directory if the XDG path does not exist, and emits a single deprecation warning per session. A bloc's own directory follows a stricter rule, because it can hold the bloc's inception vault. OCFP uses whichever of ~/.local/share/ocfp/<bloc> and ~/.ocfp/<bloc> holds the vault, so an empty or vault-less XDG directory never hides a legacy vault, and it refuses to choose when both hold one. The inception vault guide describes the rule in full and how to settle a bloc with two vaults.

To force the legacy flat-directory layout entirely, set:

export OCFP_HOME=~/.ocfp

This overrides all three XDG directories and disables the deprecation warning.

To move an existing ~/.ocfp installation onto the XDG layout permanently, run:

ocfp config migrate --dry-run  # preview the moves
ocfp config migrate            # move config.yml, other config.* files, and configs/ under XDG_CONFIG_HOME,
                                # state.yml/state/logs/checkpoints/backups/markers under XDG_STATE_HOME,
                                # and keys/per-bloc directories under XDG_DATA_HOME
                                # (a per-bloc directory's own state/ and logs/
                                # subdirectories split to XDG_STATE_HOME first)

ocfp config migrate refuses to run while OCFP_HOME is set, because that override means the flat layout is intentional. It also waits for any other ocfp command to finish first, since that command's lock and log files are among the things being moved. It also refuses while any bloc it would move still has its inception vault running, because moving the bloc's directory would pull the vault's data and keys out from under it. It checks each bloc's vault API port and its tmux session, names every bloc that is up, and moves nothing, on a dry run as well. Stop each vault with tmux kill-session -t <bloc>-inception-vault, run the migration, and then bring the vault back with ocfp vault start --bloc <bloc>. The check finds a vault only on the port that OCFP_VAULT_INCEPTION_PORT or the bloc's vault_inception_port names, so stop any vault you started by hand on some other port before you migrate. While it moves the blocs, the command holds each one's inception vault lock, which it takes in name order, and it checks the vaults once more after it has them. It refuses and moves nothing when another ocfp run, such as ocfp vault inception, holds one of those locks, and a vault command that starts during the moves waits for them to finish. A dry run takes no lock. Destination directories that already exist are merged, so the command locks and per-bloc logs that everyday use has already written under ~/.local/state/ocfp are kept alongside what moves in. The command refuses when a file would be overwritten, or when a bloc's vault/ directory holds something in both ~/.ocfp and the XDG data directory, because it won't merge two vaults. It lists every such conflict so you can resolve them by hand first. It also refuses a bloc whose vault is part way through a migration to raft storage, because the migration's journal names the bloc's paths in full, and every vault command would refuse the bloc once it moved. Finish that migration with ocfp vault inception --bloc <bloc> first. Files it does not recognize are left in ~/.ocfp and reported rather than guessed at. The old spelling, ocfp migrate, still works but prints a deprecation notice.

Configuration File Structure
# Basic configuration (provider is read from bloc config)
name: environment-name
provider: stackit
region: eu01  # For STACKIT, defaults to eu01 if omitted
project_id: project-123
org_id: org-456
auth_token: ${STACKIT_AUTH_TOKEN}

# Network configuration
network:
  name: ocfp-network
  cidr: 10.0.0.0/16
  dns:
    - 8.8.8.8
    - 8.8.4.4

# Subnet defaults (see go/docs/networking/subnets.md)

- Non-STACKIT providers: If `subnets` are omitted, bootstrap derives two subnets named `mgmt` (public) and `ocf` (private) by splitting the bloc network into two equal subnets (e.g., `/20` → two `/21`). Bastion prefers `mgmt`.
- STACKIT: No real provider subnets are created. A single virtual subnet `ocfp-0` equals the bloc network CIDR and is treated as public for placement and IP assignment semantics. Bastion uses the network directly and records a dependency on `subnet.<bloc>-ocfp-0` in state.

Subnet strategies (STACKIT) (see go/docs/networking/subnets.md)

- `subnet_strategy: ocfp-triple`: Splits the bloc network into 4 equal CIDRs and uses the last three for virtual subnets `ocfp-0..2` (e.g., `/20` → `10.4.4.0/22`, `10.4.8.0/22`, `10.4.12.0/22`).
- Reserved IPs: For each virtual subnet, state outputs include service IPs and ranges used by load balancers and kits, e.g.:
  - `reserved_<bloc>-ocfp-0_bastion_ip`, `reserved_<bloc>-ocfp-0_bosh_ip`, `reserved_<bloc>-ocfp-0_vault_ip`
  - `reserved_<bloc>-ocfp-1_doomsday_ip`, `reserved_<bloc>-ocfp-2_ocfp_ui_ip`
  - Ranges: `reserved_<subnet>_available_a/b` and `reserved_<subnet>_reserved_a/b[/c/d]`
  - Named-slot offsets mirror the Perl defaults (bastion .3, bosh .4, vault .5, jumpbox .6, concourse .7, prometheus .8, shield .9 on ocfp-0, doomsday .9 on ocfp-1, ocfp_ui .9 on ocfp-2). The available/reserved ranges come from the selected network strategy's mgmt band: under the default `wide` strategy, available 32-63 and reserved 0-10 plus 64 onward (see go/docs/networking/reserved-ip-strategies.md).

### Load balancer management (see go/docs/cmds/lb.md)

- Add a backend by IP:
  - `ocfp lb add-service cf-router 10.0.1.10 --port 8080 --target-port 80`
- STACKIT reserved IP integration:
  - `ocfp lb add-service ops-https reserved:vault_ip`
  - `ocfp lb add-service doomsday-mgmt reserved:doomsday_ip:1` (uses ocfp-1)
  - Format: `reserved:<key>[:index]` where index selects ocfp subnet (default 0).

- Sync from config (lbs:) and reconcile pool members:
  - Define LBs in bloc config under `lbs:` and sync with: `ocfp lb sync --name <key> [--remove-unused]`
  - Example config:
    lbs:
      ops-https:
        protocol: tcp
        port: 443
        targets:
          - reserved:vault_ip
          - reserved:prometheus_ip
          - reserved:shield_ip
          - reserved:doomsday_ip:1
      router-80:
        protocol: http
        port: 80
        targets:
          - public-ip:router:0
          - public-ip:router:1
      cf-ssh:
        protocol: tcp
        port: 2222
        targets:
          - 10.4.0.50

- Target token formats:
  - `reserved:<key>[:index]` uses reserved IPs computed at bootstrap (STACKIT virtual subnets), e.g. `reserved:vault_ip`, `reserved:doomsday_ip:1`.
  - `public-ip:<job>[:index]` uses public IP resources discovered/created during bootstrap for job labels, e.g. `public-ip:router:0`, `public-ip:cf-ssh:0`, `public-ip:tcp-router:1`.

### Typed load balancer commands

- `ocfp lb ops`:
  - Ensures an external HTTPS LB for ops endpoints (default name `<bloc>-ops-https`, port 443).
  - Default behavior: if `lbs.ops-https` exists in config, pool members are reconciled from it (adds missing, with `--remove-unused` to prune).
  - Fallback: if no config, auto-add reserved IPs `vault_ip`, `prometheus_ip`, `shield_ip` from `ocfp-0`; optional `--with-doomsday` to add `doomsday_ip` from `ocfp-1`.
  - Flags: `--name`, `--port`, `--protocol` (default https), `--remove-unused`, `--with-doomsday`.

- `ocfp lb routers`:
  - Ensures external LBs for CF routers (HTTP/HTTPS) with names `<bloc>-router-80` and `<bloc>-router-443` by default.
  - Default behavior: if a matching key exists in `lbs:` (e.g., `router-80`), pool members are reconciled from it (with `--remove-unused`). Else, it falls back to public IPs labeled `job=router` from state.
  - Flags: `--name-prefix`, `--http`, `--https`, `--http-port`, `--https-port`, `--remove-unused`.

- `ocfp lb tcp-routers`:
  - Ensures an external TCP router LB (operator supplies `--port`).
  - Default behavior: if `lbs.<name>` exists, pool members are reconciled from it (with `--remove-unused`). Else, it falls back to public IPs labeled `job=tcp-router` from state.
  - Flags: `--name`, `--port` (default 1024), `--remove-unused`.

- `ocfp lb cf-ssh`:
  - Ensures an external LB for CF SSH (default name `<bloc>-cf-ssh`, port 2222).
  - Default behavior: if `lbs.<name>` exists, pool members are reconciled from it (with `--remove-unused`). Else, it falls back to public IPs labeled `job=cf-ssh` from state.
  - Flags: `--name`, `--port`, `--remove-unused`.

# Bastion configuration
bastion:
  flavor: m1.small
  image: ubuntu-22.04
  keypair: bastion-key

## Deployments Repository

Configure how Genesis deployments are sourced by adding a `deployments` block to your OCFP YAML:

```yaml
deployments:
  url: git@github.com:example/ocfp-deployments.git  # optional global repo
  bosh:
    mode: release                                    # default when url is present
  vault:
    mode: dev                                        # stays local and symlinked into repo
  • When deployments.url is set, the bastion clones (or updates) that repository under ~/ocfp/deployments during dry runs and real provisioning.
  • Deployments marked mode: dev still use kits under ~/ocfp/kits/<name>; the bastion keeps a dev/ symlink inside the global repository so workflows remain unchanged.
  • Without a global URL, all deployments default to dev mode, matching the legacy behaviour.

Availability zones

azs: z1: zone: eu-central-1a z2: zone: eu-central-1b

Blocs (deployment groups)

blocs:

  • name: management type: mgmt network: cidr: 10.0.1.0/24
  • name: deployment type: deploy network: cidr: 10.0.2.0/24

### Blobstore Policies (optional)

Object storage bucket policies (versioning/lifecycle) are disabled by default. To enable and tune them per bucket:

```yaml
blobstore:
  enable_policies: true
  bosh_blobstore:
    versioning: true
    noncurrent_days: 30
  cf_buildpacks:
    versioning: true
    noncurrent_days: 90
  cf_droplets:
    versioning: true
    noncurrent_days: 7
  cf_app_packages:
    versioning: false
    noncurrent_days: 30

Alternatively, set OCFP_ENABLE_BUCKET_POLICIES=1 to enable policies from the environment. Applied settings are persisted to state on bootstrap.

Environment Variables
Variable Description
OCFP_CONFIG Path to configuration file
OCFP_BLOC Current bloc/environment name
OCFP_PROVIDER Cloud provider
OCFP_REGION Cloud region
OCFP_DEBUG Enable debug logging
OCFP_VERBOSE Enable verbose logging
OCFP_TRACE Enable trace-level logging
OCFP_NO_LOG Disable file logging to ~/.local/state/ocfp/{bloc}/logs/
OCFP_DEBUG_LOOKUP Print bastion lookup strategy matches
OCFP_ASCII Use ASCII-only tables (equivalent to --ascii)

Note: For the STACKIT provider, if no region is specified via config, --region, or OCFP_REGION, OCFP defaults to eu01.

PVE Robustness

Recent work hardened the Proxmox VE provider against a set of real-cluster failure modes discovered during lab operations. Key changes: Tailscale provisioning is now opt-in per bloc (tailscale.enabled: true), the VMID range default was corrected to 100, PVE credentials are validated at config load, and the BOSH Director flavor was resized to 8 vCPU / 16 GiB / 128 GiB.

Provider Support

Currently Implemented
  • STACKIT: Full support for compute, network, and storage operations
  • OpenStack: (In development)
  • AWS: (Planned)
  • Azure: (Planned)
  • GCP: (Planned)
Adding a New Provider
  1. Implement the Provider interface in internal/cpi/
  2. Register the provider in internal/cpi/registry.go
  3. Add provider-specific configuration handling
  4. Write unit tests for the provider

Development

Prerequisites
  • Go 1.27.3 or later
  • Make
  • Git
  • Bash and jq (for guest-boot shell regression tests)
Building
# Build for current platform
make build

# Build for all platforms
make build-all

# Run tests
make test

# Run linting
make lint

# Run security checks
make security
Project Structure
go/
├── cmd/ocfp/           # Main application entry point
├── internal/
│   ├── bootstrap/      # Bootstrap orchestration
│   ├── cli/           # CLI framework and root command
│   ├── commands/      # Command implementations
│   ├── config/        # Configuration management
│   ├── cpi/           # Cloud Provider Interface
│   │   └── stackit/   # STACKIT provider implementation
│   ├── logger/        # Structured logging
│   ├── state/         # State management
│   └── version/       # Version information
├── pkg/               # Public APIs (future)
├── tests/             # Test suites
├── scripts/           # Build and deployment scripts
└── docs/              # Documentation
Testing
# Run unit tests
go test ./...

# Run with coverage
go test -cover ./...

# Run integration tests
make test-integration

# Run security scan
make security

CI/CD

The project uses GitHub Actions for continuous integration and deployment:

  • Lint: Code quality checks with golangci-lint
  • Test: Unit tests with coverage reporting
  • Security: Vulnerability scanning with govulncheck and gosec
  • Build: Cross-platform builds for Linux, macOS, and Windows
  • Release: Automated releases with checksums

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request
Coding Standards
  • Follow Go best practices and idioms
  • Maintain test coverage above 80%
  • Use structured logging with context
  • Handle errors explicitly
  • Document exported functions and types

Migration from Perl CLI

The Go implementation maintains compatibility with existing configuration files and command syntax. To migrate:

  1. Install the Go CLI alongside the Perl version
  2. Test with your existing configuration files
  3. Verify all workflows function correctly
  4. Remove the Perl CLI once validated
Breaking Changes
  • None currently - full backward compatibility maintained

Security

  • All credentials are handled securely
  • TLS/SSL verification enforced
  • Sensitive data never logged
  • Regular security scanning with govulncheck and gosec
Reporting Security Issues

Please report security vulnerabilities to security@ocfp.io

License

Apache License 2.0

Support

Acknowledgments

  • Original Perl implementation team
  • Cloud Foundry Foundation
  • All contributors and users

Built with ❤️ by the OCFP Team

Directories

Path Synopsis
cmd
ocfp command
Package main is the entry point for the OCFP CLI.
Package main is the entry point for the OCFP CLI.
internal
artifacts
Package artifacts orchestrates the ocfp-artifacts VM (RustFS S3 blobstore).
Package artifacts orchestrates the ocfp-artifacts VM (RustFS S3 blobstore).
bastion
Package bastion orchestrates bastion host initialization and provisioning.
Package bastion orchestrates bastion host initialization and provisioning.
bastion/deployments
Package deployments resolves deployment modes and paths for bastion provisioning.
Package deployments resolves deployment modes and paths for bastion provisioning.
bastion/providers
Package providers implements cloud provider-specific bastion initialization.
Package providers implements cloud provider-specific bastion initialization.
bastion/provision
Package provision handles bastion provisioning script generation and configuration.
Package provision handles bastion provisioning script generation and configuration.
bastion/ssh
Package ssh provides SSH client operations for bastion host communication.
Package ssh provides SSH client operations for bastion host communication.
bastion/test
Package test provides test helpers and mock implementations for bastion tests.
Package test provides test helpers and mock implementations for bastion tests.
blocinv
Package blocinv builds the inventory of blocs the CLI knows about.
Package blocinv builds the inventory of blocs the CLI knows about.
bootstrap
Package bootstrap handles infrastructure bootstrapping operations for OCFP environments.
Package bootstrap handles infrastructure bootstrapping operations for OCFP environments.
cli
Package cli implements the root command and subcommand registration for the OCFP CLI.
Package cli implements the root command and subcommand registration for the OCFP CLI.
commands
Package commands implements the CLI command handlers for OCFP operations.
Package commands implements the CLI command handlers for OCFP operations.
config
Package config handles OCFP CLI configuration file loading, validation, and bloc management.
Package config handles OCFP CLI configuration file loading, validation, and bloc management.
cpi
Package cpi provides the cloud provider interface abstraction layer.
Package cpi provides the cloud provider interface abstraction layer.
cpi/aws
Package aws implements the CPI provider for Amazon Web Services.
Package aws implements the CPI provider for Amazon Web Services.
cpi/azure
Package azure implements the CPI provider for Microsoft Azure.
Package azure implements the CPI provider for Microsoft Azure.
cpi/gcp
Package gcp implements the CPI provider for Google Cloud Platform.
Package gcp implements the CPI provider for Google Cloud Platform.
cpi/ownedvm
Package ownedvm finds a VM by name among those that carry a bloc's ownership tags, whichever provider holds it.
Package ownedvm finds a VM by name among those that carry a bloc's ownership tags, whichever provider holds it.
cpi/pve
Package pve implements the CPI provider for Proxmox Virtual Environment.
Package pve implements the CPI provider for Proxmox Virtual Environment.
cpi/stackit
Package stackit implements the CPI provider for STACKIT cloud.
Package stackit implements the CPI provider for STACKIT cloud.
exec
Package exec provides subprocess helpers that keep secrets out of argv.
Package exec provides subprocess helpers that keep secrets out of argv.
keyfile
Package keyfile reads, writes, and protects the key files of an inception vault: the root token in root.key, the unseal key, and the copy of the root token that safe holds for the bloc's own target.
Package keyfile reads, writes, and protects the key files of an inception vault: the root token in root.key, the unseal key, and the copy of the root token that safe holds for the bloc's own target.
logger
Package logger provides structured file-based logging for the OCFP CLI using zap.
Package logger provides structured file-based logging for the OCFP CLI using zap.
netlayout
Package netlayout defines the reserved-IP layout strategy abstraction shared by Layer A (bootstrap subnet carving) and Layer B (vault reserved-ips population).
Package netlayout defines the reserved-IP layout strategy abstraction shared by Layer A (bootstrap subnet carving) and Layer B (vault reserved-ips population).
output
Package output provides a multi-mode output rendering system for CLI operations.
Package output provides a multi-mode output rendering system for CLI operations.
precompile
Package precompile populates the artifacts blobstore with compiled BOSH release tarballs and emits ops files that pin deployment releases to those tarballs, so create-env and CF deploys skip source compilation.
Package precompile populates the artifacts blobstore with compiled BOSH release tarballs and emits ops files that pin deployment releases to those tarballs, so create-env and CF deploys skip source compilation.
progress
Package progress writes and reads the progress stream that a long-running ocfp command produces, one JSON object per line.
Package progress writes and reads the progress stream that a long-running ocfp command produces, one JSON object per line.
progress/progresstest
Package progresstest holds golden progress streams for tests.
Package progresstest holds golden progress streams for tests.
providers
Package providers defines interfaces and base types for cloud provider vault operations.
Package providers defines interfaces and base types for cloud provider vault operations.
pve/capacity
Package capacity resolves PVE cloud-config capacity values (workers, cf_max_in_flight) using a three-level priority chain per Decision D1:
Package capacity resolves PVE cloud-config capacity values (workers, cf_max_in_flight) using a three-level priority chain per Decision D1:
pve/netvalidate
Package netvalidate detects mismatch between a BOSH director network CIDR and a CF cloud-config CIDR.
Package netvalidate detects mismatch between a BOSH director network CIDR and a CF cloud-config CIDR.
pve/opsfiles
Package opsfiles embeds PVE-specific BOSH ops files and writes them to the bastion deployments ops directory during `ocfp init pve`.
Package opsfiles embeds PVE-specific BOSH ops files and writes them to the bastion deployments ops directory during `ocfp init pve`.
pve/probes
Package probes provides a pre-deploy probe framework for PVE BOSH director environments.
Package probes provides a pre-deploy probe framework for PVE BOSH director environments.
pve/stemcell
Package stemcell provides idempotent BOSH stemcell upload helpers for PVE environments.
Package stemcell provides idempotent BOSH stemcell upload helpers for PVE environments.
pve/verify
Package verify provides out-of-band PVE REST API predicates independent of the CPI RPC channel.
Package verify provides out-of-band PVE REST API predicates independent of the CPI RPC channel.
recycle
Package recycle replaces a VM's operating system while carrying its persistent data disk across to the replacement.
Package recycle replaces a VM's operating system while carrying its persistent data disk across to the replacement.
reservedip
Package reservedip computes per-tier reserved IP addresses for a subnet from its CIDR plus a static per-envType assignment table.
Package reservedip computes per-tier reserved IP addresses for a subnet from its CIDR plus a static per-envType assignment table.
security
Package security provides path validation, input sanitization, and shell metacharacter detection.
Package security provides path validation, input sanitization, and shell metacharacter detection.
state
Package state manages OCFP bloc state persistence, backup, reconciliation, and resource tracking.
Package state manages OCFP bloc state persistence, backup, reconciliation, and resource tracking.
ui
Package ui provides terminal user interface components for the OCFP CLI.
Package ui provides terminal user interface components for the OCFP CLI.
vault
Package vault provides Vault integration for secret management, initialization, migration, and cloud provider-specific vault configuration operations.
Package vault provides Vault integration for secret management, initialization, migration, and cloud provider-specific vault configuration operations.
vaultboot
Package vaultboot renders the systemd unit that brings a bloc's inception vault back when a bastion boots, and names the per-bloc instance of it.
Package vaultboot renders the systemd unit that brings a bloc's inception vault back when a bastion boots, and names the per-bloc instance of it.
version
Package version provides build and version information for the OCFP CLI.
Package version provides build and version information for the OCFP CLI.
Package scripts embeds the provisioning scripts into the ocfp binary so an installed binary works from any directory, without a copy of the source tree.
Package scripts embeds the provisioning scripts into the ocfp binary so an installed binary works from any directory, without a copy of the source tree.
namecheck command
Command namecheck scans text for client terms held outside the repository.
Command namecheck scans text for client terms held outside the repository.
tests
integration/cfgloader
Package cfgloader reads tests/integration/config.yml, validates required keys per-tier, resolves secrets via an injected BoshInt function, and synthesizes a CPI JSON config map.
Package cfgloader reads tests/integration/config.yml, validates required keys per-tier, resolves secrets via an injected BoshInt function, and synthesizes a CPI JSON config map.
integration/cleanup
Package cleanup provides ResourceTracker for best-effort reverse-order teardown of CPI-managed resources created during integration test runs.
Package cleanup provides ResourceTracker for best-effort reverse-order teardown of CPI-managed resources created during integration test runs.
integration/cpirpc
Package cpirpc provides a Go client for the BOSH CPI JSON-RPC protocol.
Package cpirpc provides a Go client for the BOSH CPI JSON-RPC protocol.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL