Documentation
¶
Index ¶
- Constants
- Variables
- func CreateSlugFromName(name string, minLength int, maxLength int) string
- func FindGitPathAndURL() (string, string, error)
- func InitForgeBase(env string)
- func NewTeaProgram(model tea.Model, opts ...tea.ProgramOption) *tea.Program
- func SaveForgeConfig(globalConfig Config) error
- type ChangeUserRoleInOrganizationCmd
- type CommandState
- type Config
- type CreateOrganizationCmd
- type CreateProjectCmd
- type Credential
- type DeleteProjectCmd
- type DeployCmd
- type DeployInfo
- type DeployStatus
- type DestroyCmd
- type HealthStatus
- type InviteUserToOrganizationCmd
- type KnownProject
- type LoginCmd
- type LoginStepRequirement
- type LogsCmd
- type OrganizationCmd
- type ProjectCmd
- type PromoteCmd
- type ResetCmd
- type StatusCmd
- type StepRequirement
- type SwitchOrganizationCmd
- type SwitchProjectCmd
- type UpdateProjectCmd
- type UpdateUserCmd
- type User
- type UserCmd
Constants ¶
const ( EnvLocal = "LOCAL" EnvDev = "DEV" EnvProd = "PROD" )
TODO: break this config into credentials and known projects. Don't save org/project id in the config. consider adding a .forge directory with project config alongside the world.toml file.
const ( DeploymentTypeDeploy = "deploy" DeploymentTypeForceDeploy = "forceDeploy" DeploymentTypeDestroy = "destroy" DeploymentTypeReset = "reset" DeploymentTypePromote = "promote" DeployStatusFailed DeployStatus = "failed" DeployStatusPassed DeployStatus = "passed" DeployStatusRunning DeployStatus = "running" DeployEnvPreview = "dev" DeployEnvLive = "prod" )
const MaxProjectNameLen = 50
const (
RetryBaseDelay time.Duration = 100 * time.Millisecond
)
Variables ¶
var ( ErrOrganizationSelectionCanceled = eris.New("Organization selection canceled") ErrOrganizationCreationCanceled = eris.New("Organization creation canceled") )
var ( ErrProjectSelectionCanceled = eris.New("Project selection canceled") ErrProjectCreationCanceled = eris.New("Project creation canceled") )
var (
// Env is the environment to use for the Forge API.
Env = "PROD"
)
var (
ErrLogin = eris.New("not logged in")
)
var ErrNotInGitRepository = eris.New("Not in a git repository")
var ForgeCmdPlugin struct { Login *LoginCmd `cmd:"" group:"Getting Started:" help:"Login to World Forge, creating a new account if necessary"` Deploy *DeployCmd `cmd:"" group:"Getting Started:" help:"Deploy your World Forge project to a TEST environment in the cloud"` Status *StatusCmd `cmd:"" group:"Getting Started:" help:"Check the status of your deployed World Forge project"` Promote *PromoteCmd `cmd:"" group:"Cloud Management Commands:" help:"Deploy your game project to a LIVE environment in the cloud"` Destroy *DestroyCmd `cmd:"" group:"Cloud Management Commands:" help:"Remove your game project's deployed infrastructure from the cloud"` Reset *ResetCmd `cmd:"" group:"Cloud Management Commands:" help:"Restart your game project with a clean state"` Logs *LogsCmd `cmd:"" group:"Cloud Management Commands:" help:"Tail logs for your game project"` Organization *OrganizationCmd `cmd:"" aliases:"org" group:"Organization Commands:" help:"Manage your organizations"` Project *ProjectCmd `cmd:"" aliases:"proj" group:"Project Commands:" help:"Manage your projects"` User *UserCmd `cmd:""` }
Functions ¶
func CreateSlugFromName ¶ added in v1.8.0
func FindGitPathAndURL ¶ added in v1.7.0
func InitForgeBase ¶ added in v1.8.0
func InitForgeBase(env string)
func NewTeaProgram ¶ added in v1.4.1
NewTeaProgram will create a BubbleTea program that automatically sets the no input option if you are not on a TTY, so you can run the debugger. Call it just as you would call tea.NewProgram().
func SaveForgeConfig ¶ added in v1.8.0
Types ¶
type ChangeUserRoleInOrganizationCmd ¶ added in v1.8.0
type ChangeUserRoleInOrganizationCmd struct {
ID string `flag:"" help:"The ID of the user to change the role of"`
Role string `flag:"" help:"The new role of the user"`
}
func (*ChangeUserRoleInOrganizationCmd) Run ¶ added in v1.8.0
func (c *ChangeUserRoleInOrganizationCmd) Run() error
type CommandState ¶ added in v1.8.0
type CommandState struct {
LoggedIn bool
CurrRepoKnown bool
User *User
Organization *organization
Project *project
}
func GetForgeCommandState ¶ added in v1.8.0
func GetForgeCommandState() *CommandState
so you can get the state from anywhere.
func SetupForgeCommandState ¶ added in v1.8.0
func SetupForgeCommandState( ctx context.Context, loginReq LoginStepRequirement, orgReq StepRequirement, projectReq StepRequirement, ) (*CommandState, error)
SetupForgeCommandState initializes the forge system and returns the completed state it should be called at the beginning of the command before doing the work of the command itself the requirements flags are used to tell the system what state we much be in before we can run the command the setup will go through each step and return an error if the state is not met some steps, such are reading the org or project data require a login; but you can control actual login behavior separately with the loginReq flag. For example:
NeedLogin, NeedData will try to login if needed, and only fail if it can't login.
IgnoreLogin, NeedData will fail if we are not already logged in, and will not attempt to login.
IgnoreLogin, NeedExistingIDOnly will not try to login, and will try different ways to figure out the OrgID
including sending requests to the server if we are logged in. But if we aren't logged in and
don't have an existing org id already known via config or other means, it will fail.
NOTE: we ALWAYS return the state, even if there is an error, so you can use it in your error handling.
type Config ¶ added in v1.8.0
type Config struct {
OrganizationID string `json:"organization_id"`
ProjectID string `json:"project_id"`
Credential Credential `json:"credential"`
KnownProjects []KnownProject `json:"known_projects"`
// the following are not saved in json
// TODO: get rid of these since they will be handled by the init flow state
CurrRepoKnown bool `json:"-"` // when true, the current repo and path are already in known_projects
CurrRepoURL string `json:"-"`
CurrRepoPath string `json:"-"`
CurrProjectName string `json:"-"`
}
func GetCurrentForgeConfig ¶ added in v1.8.0
func GetForgeConfig ¶ added in v1.8.0
type CreateOrganizationCmd ¶ added in v1.8.0
type CreateOrganizationCmd struct {
Name string `flag:"" help:"The name of the organization"`
Slug string `flag:"" help:"The slug of the organization"`
AvatarURL string `flag:"" help:"The avatar URL of the organization" type:"url"`
}
func (*CreateOrganizationCmd) Run ¶ added in v1.8.0
func (c *CreateOrganizationCmd) Run() error
type CreateProjectCmd ¶ added in v1.8.0
type CreateProjectCmd struct {
Name string `flag:"" help:"The name of the project"`
Slug string `flag:"" help:"The slug of the project"`
AvatarURL string `flag:"" help:"The avatar URL of the project" type:"url"`
}
func (*CreateProjectCmd) Run ¶ added in v1.8.0
func (c *CreateProjectCmd) Run() error
type Credential ¶ added in v1.8.0
type DeleteProjectCmd ¶ added in v1.8.0
type DeleteProjectCmd struct {
}
func (*DeleteProjectCmd) Run ¶ added in v1.8.0
func (c *DeleteProjectCmd) Run() error
type DeployCmd ¶ added in v1.8.0
type DeployCmd struct {
Force bool `flag:"" help:"Force the deployment"`
}
type DeployInfo ¶ added in v1.8.0
type DeployInfo struct {
DeployType string
DeployStatus DeployStatus
DeployDisplay string
}
type DeployStatus ¶ added in v1.8.0
type DeployStatus string
type DestroyCmd ¶ added in v1.8.0
type DestroyCmd struct {
}
func (*DestroyCmd) Run ¶ added in v1.8.0
func (c *DestroyCmd) Run() error
type HealthStatus ¶ added in v1.8.0
type HealthStatus string
const ( HealthStatusHealthy HealthStatus = "healthy" HealthStatusUnhealthy HealthStatus = "unhealthy" HealthStatusOffline HealthStatus = "offline" )
type InviteUserToOrganizationCmd ¶ added in v1.8.0
type InviteUserToOrganizationCmd struct {
ID string `flag:"" help:"The ID of the user to invite"`
Role string `flag:"" help:"The role of the user to invite"`
}
func (*InviteUserToOrganizationCmd) Run ¶ added in v1.8.0
func (c *InviteUserToOrganizationCmd) Run() error
type KnownProject ¶ added in v1.8.0
type LoginStepRequirement ¶ added in v1.8.0
type LoginStepRequirement int
/ LoginStepRequirement is the requirement for the login step.
const ( IgnoreLogin LoginStepRequirement = iota // don't care if we are logged in or not NeedLogin )
type LogsCmd ¶ added in v1.8.0
type OrganizationCmd ¶ added in v1.8.0
type OrganizationCmd struct {
Create *CreateOrganizationCmd `cmd:"" group:"Organization Commands:" help:"Create a new organization"`
Switch *SwitchOrganizationCmd `cmd:"" group:"Organization Commands:" help:"Switch to an organization"`
}
type ProjectCmd ¶ added in v1.8.0
type ProjectCmd struct {
Create *CreateProjectCmd `cmd:"" group:"Project Commands:" help:"Create a new project"`
Switch *SwitchProjectCmd `cmd:"" group:"Project Commands:" help:"Switch to a different project"`
Update *UpdateProjectCmd `cmd:"" group:"Project Commands:" help:"Update your project"`
Delete *DeleteProjectCmd `cmd:"" group:"Project Commands:" help:"Delete your project"`
}
type PromoteCmd ¶ added in v1.8.0
type PromoteCmd struct {
}
func (*PromoteCmd) Run ¶ added in v1.8.0
func (c *PromoteCmd) Run() error
type StepRequirement ¶ added in v1.8.0
type StepRequirement int
StepRequirement is the requirement used for the organization, and project steps.
const ( Ignore StepRequirement = iota NeedRepoLookup // we need to lookup the project from the git repo NeedIDOnly // we only need the id (not sure if we will use this or not) NeedExistingIDOnly // need id but can't create new one (not sure if we will use this or not) NeedData // we need all the data, can create new one NeedExistingData // we must all the data but we can't create a new one MustNotExist // we must not have this )
type SwitchOrganizationCmd ¶ added in v1.8.0
type SwitchOrganizationCmd struct {
Slug string `flag:"" help:"The slug of the organization to switch to"`
}
func (*SwitchOrganizationCmd) Run ¶ added in v1.8.0
func (c *SwitchOrganizationCmd) Run() error
type SwitchProjectCmd ¶ added in v1.8.0
type SwitchProjectCmd struct {
Slug string `flag:"" help:"The slug of the project to switch to"`
}
func (*SwitchProjectCmd) Run ¶ added in v1.8.0
func (c *SwitchProjectCmd) Run() error
type UpdateProjectCmd ¶ added in v1.8.0
type UpdateProjectCmd struct {
Name string `flag:"" help:"The new name of the project"`
Slug string `flag:"" help:"The new slug of the project"`
AvatarURL string `flag:"" help:"The new avatar URL of the project" type:"url"`
}
func (*UpdateProjectCmd) Run ¶ added in v1.8.0
func (c *UpdateProjectCmd) Run() error
type UpdateUserCmd ¶ added in v1.8.0
type UpdateUserCmd struct {
Email string `flag:"" help:"The email of the user to update"`
Name string `flag:"" help:"The new name of the user"`
AvatarURL string `flag:"" help:"The new avatar URL of the user" type:"url"`
}
func (*UpdateUserCmd) Run ¶ added in v1.8.0
func (c *UpdateUserCmd) Run() error
type UserCmd ¶ added in v1.8.0
type UserCmd struct {
Invite *InviteUserToOrganizationCmd `cmd:"" group:"User Commands:" optional:"" help:"Invite a user to an organization"`
Role *ChangeUserRoleInOrganizationCmd `cmd:"" group:"User Commands:" optional:"" help:"Change a user's role in an organization"`
Update *UpdateUserCmd `cmd:"" group:"User Commands:" optional:"" help:"Update a user"`
}