apputil

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppOptionLabel added in v1.12.0

func AppOptionLabel(
	cfg config.IConfig,
	profileApps map[string]bool,
	cs *iostreams.ColorScheme,
	app dashboard.Application,
) string

func ConfigureProfile

func ConfigureProfile(
	io *iostreams.IOStreams,
	cfg config.IConfig,
	appDetails *dashboard.Application,
	profileName string,
	setDefault bool,
) error

ConfigureProfile persists the application credentials in the new model (state.toml + OS keychain) and optionally makes it the current application.

func CreateAndFetchApplication

func CreateAndFetchApplication(
	io *iostreams.IOStreams,
	client *dashboard.Client,
	accessToken, region, appName string,
	tracker *telemetry.FlowTracker,
) (*dashboard.Application, string, error)

CreateAndFetchApplication creates an application (with region retry) and generates an API key for it. It returns the region the application was actually created in, which may differ from the requested one.

func CreateApplicationWithRetry

func CreateApplicationWithRetry(
	io *iostreams.IOStreams,
	client *dashboard.Client,
	accessToken string,
	region string,
	appName string,
	tracker *telemetry.FlowTracker,
) (*dashboard.Application, string, error)

CreateApplicationWithRetry creates an application, retrying with a different region if the selected one has no available cluster.

The optional tracker (nil-safe) records which step the flow is in, so the telemetry of the calling flow can tell where the user stopped.

func EnsureAPIKey

func EnsureAPIKey(
	io *iostreams.IOStreams,
	client *dashboard.Client,
	accessToken string,
	app *dashboard.Application,
) error

EnsureAPIKey generates a write API key for the application. Callers should skip this if the local profile already has a key.

func FindFreePlan added in v1.11.0

func FindFreePlan(plans []dashboard.Plan) *dashboard.Plan

FindFreePlan returns the free-tier plan, or nil if none is present.

func KnownPaidPlan added in v1.11.0

func KnownPaidPlan(value string) *dashboard.Plan

KnownPaidPlan recognizes a documented paid --plan value even when the self-serve endpoint omits it (paid plans appear only once billing is on file).

func PickPlan added in v1.11.0

func PickPlan(candidates []dashboard.Plan) (*dashboard.Plan, error)

PickPlan shows an interactive selector over the candidate plans.

func PlanAvailable added in v1.11.0

func PlanAvailable(plans []dashboard.Plan, id string) bool

PlanAvailable reports whether a plan with the given id is in the list.

func PlanChoices added in v1.11.0

func PlanChoices(plans []dashboard.Plan) []string

PlanChoices returns the user-facing plan identifiers (the free plan is shown as "free" regardless of its underlying id).

func PlanTelemetryID added in v1.11.0

func PlanTelemetryID(p dashboard.Plan) string

PlanTelemetryID returns the plan identifier used in telemetry properties: the user-facing "free" for the free tier (whose underlying template id is not fixed and can be "build"), the plan id otherwise.

func ProfileApplicationIDs added in v1.12.0

func ProfileApplicationIDs(profiles []*config.Profile) map[string]bool

ProfileApplicationIDs returns the set of application IDs backed by a legacy config.toml profile. Built once by the caller so a per-application loop tests membership in O(1) instead of re-parsing config.toml on every iteration.

func PromptName added in v1.13.0

func PromptName() (string, error)

PromptName prompts the user for the application name.

func PromptRegion

func PromptRegion(
	io *iostreams.IOStreams,
	client *dashboard.Client,
	accessToken string,
) (string, error)

PromptRegion fetches regions from the API and prompts the user to select one.

func ResolvePlan added in v1.11.0

func ResolvePlan(plans []dashboard.Plan, value string) (*dashboard.Plan, error)

ResolvePlan maps a --plan value to one of the available plans. An exact match on the plan id wins; the user-facing "free" choice maps to the free-type template, whose id is not fixed (it can be "build"), so it is matched on type.

func ReuseExistingAPIKey added in v1.12.0

func ReuseExistingAPIKey(cfg config.IConfig, app *dashboard.Application) bool

ReuseExistingAPIKey looks for an API key already stored for the application (keychain first, then legacy config.toml profiles). If found, it sets app.APIKey and returns true so callers skip creating a new key. A key reused from a legacy profile has no known UUID, so api_key_uuid is left as-is.

func SelectablePlans added in v1.11.0

func SelectablePlans(plans []dashboard.Plan, hideNonFree bool) []dashboard.Plan

SelectablePlans returns the plans a user may choose from. When hideNonFree is true (no payment method on file) only the free plan(s) are offered, because paid plans require billing details the CLI can't collect.

Types

type ConfiguredStatus added in v1.12.0

type ConfiguredStatus int
const (
	StatusUnknown ConfiguredStatus = iota
	StatusOutOfSync
	StatusConfigured
)

func ApplicationStatus added in v1.12.0

func ApplicationStatus(cfg config.IConfig, profileApps map[string]bool, appID string) ConfiguredStatus

Jump to

Keyboard shortcuts

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