commands

package
v1.12.3 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const MaxFileSize = 1073741824 // 1GB

MaxFileSize is the tarball file size allowed to be uploaded in bytes.

Variables

View Source
var (
	Green     = color.New(color.Bold, color.FgGreen).SprintfFunc()
	HiGreen   = color.New(color.Bold, color.FgHiGreen).SprintfFunc()
	Cyan      = color.New(color.Bold, color.FgCyan).SprintfFunc()
	HiCyan    = color.New(color.Bold, color.FgHiCyan).SprintfFunc()
	Magenta   = color.New(color.Bold, color.FgMagenta).SprintfFunc()
	HiMagenta = color.New(color.Bold, color.FgHiMagenta).SprintfFunc()
	Red       = color.New(color.Bold, color.FgRed).SprintfFunc()
	HiRed     = color.New(color.Bold, color.FgHiRed).SprintfFunc()
	Blue      = color.New(color.Bold, color.FgBlue).SprintfFunc()
	HiBlue    = color.New(color.Bold, color.FgHiBlue).SprintfFunc()
	HiWhite   = color.New(color.Bold, color.FgHiWhite).SprintfFunc()
	White     = color.New(color.Bold, color.FgWhite).SprintfFunc()
	Yellow    = color.New(color.Bold, color.FgYellow).SprintfFunc()
	HiYellow  = color.New(color.Bold, color.FgHiYellow).SprintfFunc()
)

Functions

func BuildFilelist

func BuildFilelist(dir string, ignores []string) (files []string, err error)

BuildFilelist builds a list of files to be tarballed, with optional ignores.

func CreateTarball

func CreateTarball(w io.Writer, filePaths []string) error

CreateTarball creates a tarball containing all the files in filePaths and writes it to w.

func IsValidNodeApp added in v0.0.6

func IsValidNodeApp(dir string) (errs []error)

IsValidNodeApp detects if a Node.js app is present in a given directory

func NewSpinner added in v1.3.1

func NewSpinner(txt string, logWriters *LogWriters) (s *spinner.Spinner)

NewSpinner returns a nicely formatted spinner for display while users are waiting.

func NewTable

func NewTable(cli *CLI, out io.Writer) (t *tablewriter.Table)

NewTable returns a table with sectionctl standard formatting

func PackageJSONResolver added in v1.12.0

func PackageJSONResolver(r io.Reader) (kong.Resolver, error)

JSON returns a Resolver that retrieves values from a JSON source.

Hyphens in flag names are replaced with underscores.

func PrettyBool added in v1.3.0

func PrettyBool(b bool) (s string)

PrettyBool pretty prints a bool value

func Split added in v1.8.0

func Split(r rune) bool

Split helps differentiate between different directory delimiters. / or \

Types

type AccountsCmd

type AccountsCmd struct {
	List AccountsListCmd `cmd help:"List accounts on Section." default:"1"`
}

AccountsCmd manages accounts on Section

type AccountsCreateCmd

type AccountsCreateCmd struct{}

AccountsCreateCmd handles creating apps on Section

type AccountsListCmd

type AccountsListCmd struct{}

AccountsListCmd handles listing accounts on Section

func (*AccountsListCmd) Run

func (c *AccountsListCmd) Run(cli *CLI, ctx *kong.Context, logWriters *LogWriters) (err error)

Run executes the command

type AppsCmd

type AppsCmd struct {
	List   AppsListCmd   `cmd help:"List apps on Section." default:"1"`
	Info   AppsInfoCmd   `cmd help:"Show detailed app information on Section."`
	Create AppsCreateCmd `cmd help:"Create new app on Section."`
	Delete AppsDeleteCmd `cmd help:"DANGER ZONE. This deletes an existing app on Section."`
	Stacks AppsStacksCmd `cmd help:"See the available stacks to create new apps with."`
}

AppsCmd manages apps on Section

type AppsCreateCmd

type AppsCreateCmd struct {
	AccountID int    `required short:"a" help:"ID of account to create the app under"`
	Hostname  string `required short:"d" help:"FQDN the app can be accessed at"`
	Origin    string `required short:"g" help:"URL to fetch the origin"`
	StackName string `required short:"s" help:"Name of stack to deploy. Try, for example, nodejs-basic"`
}

AppsCreateCmd handles creating apps on Section

func (*AppsCreateCmd) Run added in v1.5.0

func (c *AppsCreateCmd) Run(logWriters *LogWriters) (err error)

Run executes the command

type AppsDeleteCmd added in v1.5.0

type AppsDeleteCmd struct {
	AccountID int `required short:"a" help:"ID of account the app belongs to"`
	AppID     int `required short:"i" help:"ID of the app to delete"`
}

AppsDeleteCmd handles deleting apps on Section

func (*AppsDeleteCmd) Run added in v1.5.0

func (c *AppsDeleteCmd) Run(logWriters *LogWriters) (err error)

Run executes the command

type AppsInfoCmd

type AppsInfoCmd struct {
	AccountID int `required short:"a"`
	AppID     int `required short:"i"`
}

AppsInfoCmd shows detailed information on an app running on Section

func (*AppsInfoCmd) Run

func (c *AppsInfoCmd) Run(cli *CLI, logWriters *LogWriters) (err error)

Run executes the command

type AppsListCmd

type AppsListCmd struct {
	AccountID int `short:"a" help:"Account ID to find apps under"`
}

AppsListCmd handles listing apps running on Section

func (*AppsListCmd) Run

func (c *AppsListCmd) Run(cli *CLI, logWriters *LogWriters) (err error)

Run executes the command

type AppsStacksCmd added in v1.9.0

type AppsStacksCmd struct{}

AppsStacksCmd lists available stacks to create new apps with

func (*AppsStacksCmd) Run added in v1.9.0

func (c *AppsStacksCmd) Run(cli *CLI, logWriters *LogWriters) (err error)

Run executes the command

type CLI added in v1.11.0

type CLI struct {
	Login              LoginCmd                     `cmd help:"Authenticate to Section's API"`
	Logout             LogoutCmd                    `cmd help:"Revoke authentication tokens to Section's API"`
	Accounts           AccountsCmd                  `cmd help:"Manage accounts on Section"`
	Apps               AppsCmd                      `cmd help:"Manage apps on Section"`
	Domains            DomainsCmd                   `cmd help:"Manage domains on Section"`
	Certs              CertsCmd                     `cmd help:"Manage certificates on Section"`
	Deploy             DeployCmd                    `cmd help:"Deploy an app to Section"`
	Logs               LogsCmd                      `cmd help:"Show logs from running applications"`
	Ps                 PsCmd                        `cmd help:"Show status of running applications"`
	Version            VersionCmd                   `cmd help:"Print sectionctl version"`
	WhoAmI             WhoAmICmd                    `cmd name:"whoami" help:"Show information about the currently authenticated user"`
	Debug              debugFlag                    `env:"DEBUG" default:"false" help:"Enable debug output"`
	DebugOutput        debugOutputFlag              `short:"out" help:"Enable logging on the debug output."`
	DebugFile          DebugFileFlag                `help:"File path where debug output should be written"`
	SectionToken       string                       `env:"SECTION_TOKEN" help:"Secret token for API auth"`
	SectionAPIPrefix   *url.URL                     `default:"https://aperture.section.io" env:"SECTION_API_PREFIX"`
	SectionAPITimeout  time.Duration                `default:"30s" env:"SECTION_API_TIMEOUT" help:"Request timeout for the Section API"`
	InstallCompletions kongplete.InstallCompletions `cmd:"" help:"install shell completions"`
	Quiet              quietFlag                    `env:"SECTION_CI" help:"Enables minimal logging, for use in continuous integration."`
}

CLI exposes all the subcommands available

type CertsCmd added in v1.1.0

type CertsCmd struct {
	Renew CertsRenewCmd `cmd help:"Renew a certificate for a domain."`
}

CertsCmd manages certificates on Section

type CertsRenewCmd added in v1.1.0

type CertsRenewCmd struct {
	Hostname string `arg help:"The domain name to renew the cert for"`
}

CertsRenewCmd handles renewing a certificate

func (*CertsRenewCmd) Run added in v1.1.0

func (c *CertsRenewCmd) Run(ctx *kong.Context, logWriters *LogWriters) (err error)

Run executes the command

type DebugFileFlag added in v1.11.0

type DebugFileFlag string

type DeployCmd

type DeployCmd struct {
	AccountID      int           `short:"a" help:"AccountID to deploy application to."`
	AppID          int           `short:"i" help:"AppID to deploy application to."`
	Environment    string        `` /* 133-byte string literal not displayed */
	Directory      string        `short:"C" default:"." help:"Directory which contains the application to deploy."`
	ServerURL      *url.URL      `default:"https://aperture.section.io/new/code_upload/v1/upload" help:"URL to upload application to"`
	Timeout        time.Duration `default:"600s" help:"Timeout of individual HTTP requests."`
	SkipDelete     bool          `help:"Skip delete of temporary tarball created to upload app."`
	SkipValidation bool          `help:"Skip validation of the workload before pushing into Section. Use with caution."`
	AppPath        string        `default:"nodejs" help:"Path of NodeJS application in environment repository."`
}

DeployCmd handles deploying an app to Section.

func (*DeployCmd) Run

func (c *DeployCmd) Run(ctx *kong.Context, logWriters *LogWriters) (err error)

Run deploys an app to Section's edge

type DomainsCmd added in v1.7.0

type DomainsCmd struct {
	List DomainsListCmd `cmd help:"List domains on Section." default:"1"`
}

DomainsCmd manages domains on Section

type DomainsListCmd added in v1.7.0

type DomainsListCmd struct {
	AccountID int `short:"a" help:"ID of account to list domains under"`
}

DomainsListCmd handles listing domains on Section

func (*DomainsListCmd) Run added in v1.7.0

func (c *DomainsListCmd) Run(cli *CLI, logWriters *LogWriters) (err error)

Run executes the command

type GS added in v1.10.0

type GS struct{}

GS ...

func (*GS) UpdateGitViaGit added in v1.10.0

func (g *GS) UpdateGitViaGit(ctx *kong.Context, c *DeployCmd, response UploadResponse, logWriters *LogWriters) error

UpdateGitViaGit clones the application repository to a temporary directory then updates it with the latest payload id and pushes a new commit

type GitService added in v1.10.0

type GitService interface {
	UpdateGitViaGit(ctx *kong.Context, c *DeployCmd, response UploadResponse, logWriters *LogWriters) error
}

GitService interface provides a way to interact with Git

type LogWriters added in v1.11.0

type LogWriters struct {
	ConsoleWriter        io.Writer
	FileWriter           io.Writer
	ConsoleOnly          io.Writer
	CarriageReturnWriter io.Writer
}

type LoginCmd

type LoginCmd struct {
	// contains filtered or unexported fields
}

LoginCmd handles authenticating the CLI against Section's API

func (*LoginCmd) In added in v1.3.0

func (c *LoginCmd) In() io.Reader

In returns the input to read from

func (*LoginCmd) Out added in v1.3.0

func (c *LoginCmd) Out() io.Writer

Out returns the output to write to

func (*LoginCmd) Run

func (c *LoginCmd) Run() (err error)

Run executes the command

type LogoutCmd added in v1.4.0

type LogoutCmd struct{}

LogoutCmd handles revoking previously set up authentication

func (*LogoutCmd) Run added in v1.4.0

func (c *LogoutCmd) Run(logWriters *LogWriters) (err error)

Run executes the command

type LogsCmd added in v1.5.0

type LogsCmd struct {
	AccountID    int    `required short:"a" help:"ID of account to query"`
	AppID        int    `required short:"i" help:"ID of app to query"`
	AppPath      string `default:"nodejs" help:"Path of NodeJS application in environment repository."`
	InstanceName string `default:"" help:"Specific instance of NodeJS application running on Section platform."`
	Number       int    `short:"n" default:100 help:"Number of log lines to fetch."`
	Follow       bool   `help:"Displays recent logs and leaves the session open for logs to stream in. --instance-name required."`
}

LogsCmd returns logs from an application on Section's delivery platform

func (*LogsCmd) Run added in v1.5.0

func (c *LogsCmd) Run(cli *CLI, logWriters *LogWriters) (err error)

Run executes the command

type MinimalPackageJSON added in v1.11.0

type MinimalPackageJSON struct {
	Section struct {
		AccountID   string `json:"accountId"`
		AppID       string `json:"appId"`
		Environment string `json:"environment"`
		ModuleName  string `json:"module-name"`
		StartScript string `json:"start-script"`
	} `json:"section"`
	X map[string]interface{} `json:"-"` // Rest of the fields should go here.
}

type PackageJSON added in v1.11.0

type PackageJSON struct {
	Name         string            `json:"name"`
	Version      string            `json:"version"`
	Dependencies map[string]string `json:"dependencies"`
	Scripts      map[string]string `json:"scripts"`
	Section      struct {
		AccountID   string `json:"accountId"`
		AppID       string `json:"appId"`
		Environment string `json:"environment"`
		ModuleName  string `json:"module-name"`
		StartScript string `json:"start-script"`
	} `json:"section"`
	X map[string]interface{} `json:"-"` // Rest of the fields should go here.
}

func ParsePackageJSON added in v1.11.0

func ParsePackageJSON(packageJSONContents string) (PackageJSON, error)

Try to fit the contents of the package.json into one of the three structs defined above, as JSON isn't strictly typed.

type PayloadValue added in v0.0.5

type PayloadValue struct {
	ID string `json:"section_payload_id"`
}

PayloadValue represents the value of a trigger update payload.

type PotentialIntValues added in v1.11.0

type PotentialIntValues struct {
	Section struct {
		AccountID int `json:"accountId"`
		AppID     int `json:"appId"`
	} `json:"section"`
}

type PsCmd added in v1.3.0

type PsCmd struct {
	AccountID int           `short:"a" help:"ID of account to query"`
	AppID     int           `short:"i" help:"ID of app to query"`
	AppPath   string        `default:"nodejs" help:"Path of NodeJS application in environment repository."`
	Watch     bool          `short:"w" help:"Run repeatedly, output status"`
	Interval  time.Duration `short:"t" default:"10s" help:"Interval to poll if watching"`
}

PsCmd checks an application's status on Section's delivery platform

func (*PsCmd) Run added in v1.3.0

func (c *PsCmd) Run(cli *CLI, logWriters *LogWriters) (err error)

Run executes the command

type SectionConfigJSON added in v1.11.0

type SectionConfigJSON struct {
	Proxychain []struct {
		Name  string `json:"name"`
		Image string `json:"image"`
	} `json:"proxychain"`
	X map[string]interface{} `json:"-"` // Rest of the fields should go here.
}

func ParseSectionConfig added in v1.11.0

func ParseSectionConfig(sectionConfigContents string) (SectionConfigJSON, error)

type UploadResponse added in v0.0.5

type UploadResponse struct {
	PayloadID string `json:"payloadID"`
}

UploadResponse represents the response from a request to the upload service.

type VersionCmd

type VersionCmd struct {
	LatestReleaseURL *url.URL      `hidden default:"https://api.github.com/repos/section/sectionctl/releases/latest"`
	Timeout          time.Duration `hidden default:"5s"`
	// contains filtered or unexported fields
}

VersionCmd handles authenticating the CLI against Section's API

func (*VersionCmd) In added in v1.7.0

func (c *VersionCmd) In() io.Reader

In returns the input to read from

func (*VersionCmd) Out added in v1.7.0

func (c *VersionCmd) Out() io.Writer

Out returns the output to write to

func (*VersionCmd) Run

func (c *VersionCmd) Run() (err error)

Run executes the `login` command

func (VersionCmd) String added in v1.9.0

func (c VersionCmd) String() string

type WhoAmICmd added in v1.3.0

type WhoAmICmd struct{}

WhoAmICmd returns information about the currently authenticated user

func (*WhoAmICmd) Run added in v1.3.0

func (c *WhoAmICmd) Run(cli *CLI, logWriters *LogWriters) (err error)

Run executes the command

Jump to

Keyboard shortcuts

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