infra

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ApplyCmd = &cli.Command{
	Name:  "apply",
	Usage: "Creates or updates infrastructure based off the apps and resources defined in app.json",
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:    "silent",
			Aliases: []string{"s"},
			Usage:   "Suppress informational output (only show Terraform output)",
		},
	},
	Action: cmdtools.Wrap(Apply),
}
View Source
var Command = &cli.Command{
	Name:        "infra",
	Usage:       "Provision and manage cloud infrastructure",
	Description: "Commands for planning and applying infrastructure changes defined in app.json",
	Commands: []*cli.Command{
		PlanCmd,
		ApplyCmd,
		DestroyCmd,
		OutputCmd,
		ImportCmd,
	},
	Before: func(ctx context.Context, command *cli.Command) (context.Context, error) {
		_, err := infra.ParseTFEnvironment()
		if err != nil {

			return ctx, errors.Wrap(err, "must include infra variables in PATH")
		}
		return ctx, nil
	},
}

Command defines the infra commands for provisioning and managing cloud infrastructure based on app.json definitions.

View Source
var DestroyCmd = &cli.Command{
	Name:  "destroy",
	Usage: "Tears down infrastructure defined in app.json",
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:    "silent",
			Aliases: []string{"s"},
			Usage:   "Suppress informational output (only show Terraform output)",
		},
	},
	Action: cmdtools.Wrap(Destroy),
}
View Source
var ImportCmd = &cli.Command{
	Name:  "import",
	Usage: "Import existing infrastructure resources or apps into Terraform state",
	Description: `Import allows you to bring existing cloud resources or apps under Terraform management.

This is useful when:
  - Migrating from manually created infrastructure
  - Adopting webkit for an existing project
  - Recovering from state loss

Examples:
  # Import a resource (database, storage, etc.)
  webkit infra import --resource db --id ca9f591d-f38h-462a-a5c6-5a8a74838081

  # Import an app
  webkit infra import --app web --id a1b2c3d4-e5f6-7890-abcd-ef1234567890

  # Import a DigitalOcean project
  webkit infra import --project --id 12345678-abcd-1234-5678-1234567890ab`,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:     "resource",
			Aliases:  []string{"r"},
			Usage:    "Name of the resource in app.json to import (mutually exclusive with --app and --project)",
			Required: false,
		},
		&cli.StringFlag{
			Name:     "app",
			Aliases:  []string{"a"},
			Usage:    "Name of the app in app.json to import (mutually exclusive with --resource and --project)",
			Required: false,
		},
		&cli.BoolFlag{
			Name:     "project",
			Aliases:  []string{"p"},
			Usage:    "Import a DigitalOcean project (mutually exclusive with --resource and --app)",
			Required: false,
		},
		&cli.StringFlag{
			Name:     "id",
			Usage:    "Provider-specific resource/app ID (e.g., DigitalOcean cluster ID or app ID)",
			Required: true,
		},
		&cli.StringFlag{
			Name:    "env",
			Aliases: []string{"e"},
			Usage:   "Environment to import into (development, staging, production)",
			Value:   env.Production.String(),
		},
		&cli.BoolFlag{
			Name:    "silent",
			Aliases: []string{"s"},
			Usage:   "Suppress informational output (only show Terraform output)",
		},
	},
	Action: cmdtools.Wrap(Import),
}

ImportCmd defines the command for importing existing infrastructure into Terraform state.

View Source
var OutputCmd = &cli.Command{
	Name:        "output",
	Usage:       "Retrieve Terraform outputs from a specific environment",
	Description: "Fetches infrastructure outputs for resources provisioned by Terraform",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:     "env",
			Usage:    "Environment to fetch outputs from (development, staging, production)",
			Aliases:  []string{"e"},
			Required: true,
		},
		&cli.StringFlag{
			Name:    "resource",
			Usage:   "Filter outputs to a specific resource name",
			Aliases: []string{"r"},
		},
		&cli.StringFlag{
			Name:    "app",
			Usage:   "Filter outputs to a specific app name",
			Aliases: []string{"a"},
		},
		&cli.BoolFlag{
			Name:    "silent",
			Aliases: []string{"s"},
			Usage:   "Suppress informational output (only show Terraform output)",
		},
	},
	Action: cmdtools.Wrap(Output),
}
View Source
var PlanCmd = &cli.Command{
	Name:  "plan",
	Usage: "Generates an executive plan from the apps and resources defined in app.json",
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:    "silent",
			Aliases: []string{"s"},
			Usage:   "Suppress informational output (only show Terraform output)",
		},
	},
	Action: cmdtools.Wrap(Plan),
}

Functions

func Apply

func Apply(ctx context.Context, input cmdtools.CommandInput) error

func Destroy

func Destroy(ctx context.Context, input cmdtools.CommandInput) error

func Import added in v0.0.9

func Import(ctx context.Context, input cmdtools.CommandInput) error

Import executes the import operation for the specified resource or app.

func Output

func Output(ctx context.Context, input cmdtools.CommandInput) error

Output retrieves Terraform outputs from the specified environment. Supports filtering by resource name or app name.

func Plan

func Plan(ctx context.Context, input cmdtools.CommandInput) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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