feat: add docblocks to appjson structs
This commit is contained in:
@@ -23,65 +23,130 @@ var (
|
|||||||
|
|
||||||
// AppJSON is a struct that represents an app.json file as understood by Dokku
|
// AppJSON is a struct that represents an app.json file as understood by Dokku
|
||||||
type AppJSON struct {
|
type AppJSON struct {
|
||||||
Cron []CronCommand `json:"cron"`
|
// Cron is a list of cron commands to execute
|
||||||
Formation map[string]Formation `json:"formation"`
|
Cron []CronCommand `json:"cron"`
|
||||||
|
|
||||||
|
// Formation is a map of process types to scale
|
||||||
|
Formation map[string]Formation `json:"formation"`
|
||||||
|
|
||||||
|
// Healthchecks is a map of process types to healthchecks
|
||||||
Healthchecks map[string][]Healthcheck `json:"healthchecks"`
|
Healthchecks map[string][]Healthcheck `json:"healthchecks"`
|
||||||
Scripts struct {
|
|
||||||
|
// Scripts is a map of scripts to execute
|
||||||
|
Scripts struct {
|
||||||
|
// Dokku is a map of scripts to execute for Dokku-specific events
|
||||||
Dokku struct {
|
Dokku struct {
|
||||||
Predeploy string `json:"predeploy"`
|
// Predeploy is a script to execute before a deploy
|
||||||
|
Predeploy string `json:"predeploy"`
|
||||||
|
|
||||||
|
// Postdeploy is a script to execute after a deploy
|
||||||
Postdeploy string `json:"postdeploy"`
|
Postdeploy string `json:"postdeploy"`
|
||||||
} `json:"dokku"`
|
} `json:"dokku"`
|
||||||
|
|
||||||
|
// Postdeploy is a script to execute after a deploy
|
||||||
Postdeploy string `json:"postdeploy"`
|
Postdeploy string `json:"postdeploy"`
|
||||||
} `json:"scripts"`
|
} `json:"scripts"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CronCommand is a struct that represents a single cron command from an app.json file
|
// CronCommand is a struct that represents a single cron command from an app.json file
|
||||||
type CronCommand struct {
|
type CronCommand struct {
|
||||||
Command string `json:"command"`
|
// Command is the command to execute
|
||||||
|
Command string `json:"command"`
|
||||||
|
|
||||||
|
// Schedule is the cron schedule to execute the command on
|
||||||
Schedule string `json:"schedule"`
|
Schedule string `json:"schedule"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Formation is a struct that represents the scale for a process from an app.json file
|
// Formation is a struct that represents the scale for a process from an app.json file
|
||||||
type Formation struct {
|
type Formation struct {
|
||||||
Quantity *int `json:"quantity"`
|
// Quantity is the number of processes to run
|
||||||
|
Quantity *int `json:"quantity"`
|
||||||
|
|
||||||
|
// MaxParallel is the maximum number of processes to start in parallel
|
||||||
MaxParallel *int `json:"max_parallel"`
|
MaxParallel *int `json:"max_parallel"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Healthcheck is a struct that represents a single healthcheck from an app.json file
|
||||||
type Healthcheck struct {
|
type Healthcheck struct {
|
||||||
Attempts int32 `json:"attempts,omitempty"`
|
// Attempts is the number of attempts to make before considering a healthcheck failed
|
||||||
Command []string `json:"command,omitempty"`
|
Attempts int32 `json:"attempts,omitempty"`
|
||||||
Content string `json:"content,omitempty"`
|
|
||||||
HTTPHeaders []HTTPHeader `json:"httpHeaders,omitempty"`
|
// Command is the command to execute for the healthcheck
|
||||||
InitialDelay int32 `json:"initialDelay,omitempty"`
|
Command []string `json:"command,omitempty"`
|
||||||
Listening bool `json:"listening,omitempty"`
|
|
||||||
Name string `json:"name,omitempty"`
|
// Content is the content to check for in the healthcheck response
|
||||||
Path string `json:"path,omitempty"`
|
Content string `json:"content,omitempty"`
|
||||||
Port int `json:"port,omitempty"`
|
|
||||||
Scheme string `json:"scheme,omitempty"`
|
// HTTPHeaders is a list of HTTP headers to send with the healthcheck request
|
||||||
Timeout int32 `json:"timeout,omitempty"`
|
HTTPHeaders []HTTPHeader `json:"httpHeaders,omitempty"`
|
||||||
Type HealthcheckType `json:"type,omitempty"`
|
|
||||||
Uptime int32 `json:"uptime,omitempty"`
|
// InitialDelay is the number of seconds to wait before starting healthchecks
|
||||||
Wait int32 `json:"wait,omitempty"`
|
InitialDelay int32 `json:"initialDelay,omitempty"`
|
||||||
Warn bool `json:"warn,omitempty"`
|
|
||||||
OnFailure *OnFailure `json:"onFailure,omitempty"`
|
// Listening is whether or not this is a listening check
|
||||||
|
Listening bool `json:"listening,omitempty"`
|
||||||
|
|
||||||
|
// Name is the name of the healthcheck
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
|
||||||
|
// Path is the path to check for in the healthcheck response
|
||||||
|
Path string `json:"path,omitempty"`
|
||||||
|
|
||||||
|
// Port is the port to check for in the healthcheck response
|
||||||
|
Port int `json:"port,omitempty"`
|
||||||
|
|
||||||
|
// Scheme is the scheme to use for the healthcheck request
|
||||||
|
Scheme string `json:"scheme,omitempty"`
|
||||||
|
|
||||||
|
// Timeout is the number of seconds to wait before considering a healthcheck failed
|
||||||
|
Timeout int32 `json:"timeout,omitempty"`
|
||||||
|
|
||||||
|
// Type is the type of healthcheck
|
||||||
|
Type HealthcheckType `json:"type,omitempty"`
|
||||||
|
|
||||||
|
// Uptime is the number of seconds to wait before considering a container running
|
||||||
|
Uptime int32 `json:"uptime,omitempty"`
|
||||||
|
|
||||||
|
// Wait is the number of seconds to wait between healthchecks
|
||||||
|
Wait int32 `json:"wait,omitempty"`
|
||||||
|
|
||||||
|
// Warn is whether or not to warn on a failed healthcheck instead of error out
|
||||||
|
Warn bool `json:"warn,omitempty"`
|
||||||
|
|
||||||
|
// OnFailure is the action to take on a failed healthcheck
|
||||||
|
OnFailure *OnFailure `json:"onFailure,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HealthcheckType is a string that represents the type of a healthcheck from an app.json file
|
||||||
type HealthcheckType string
|
type HealthcheckType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
HealthcheckType_Liveness HealthcheckType = "liveness"
|
// HealthcheckType_Liveness is a healthcheck type that represents a liveness check
|
||||||
|
HealthcheckType_Liveness HealthcheckType = "liveness"
|
||||||
|
|
||||||
|
// HealthcheckType_Readiness is a healthcheck type that represents a readiness check
|
||||||
HealthcheckType_Readiness HealthcheckType = "readiness"
|
HealthcheckType_Readiness HealthcheckType = "readiness"
|
||||||
HealthcheckType_Startup HealthcheckType = "startup"
|
|
||||||
|
// HealthcheckType_Startup is a healthcheck type that represents a startup check
|
||||||
|
HealthcheckType_Startup HealthcheckType = "startup"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// HTTPHeader is a struct that represents a single HTTP header associated with a healthcheck
|
||||||
type HTTPHeader struct {
|
type HTTPHeader struct {
|
||||||
Name string `json:"name,omitempty"`
|
// Name is the name of the HTTP header
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
|
||||||
|
// Value is the value of the HTTP header
|
||||||
Value string `json:"value,omitempty"`
|
Value string `json:"value,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OnFailure is a struct that represents the on failure action for a healthcheck
|
||||||
type OnFailure struct {
|
type OnFailure struct {
|
||||||
|
// Command is the command to execute on failure
|
||||||
Command []string `json:"command,omitempty"`
|
Command []string `json:"command,omitempty"`
|
||||||
Url string `json:"url,omitempty"`
|
|
||||||
|
// Url is the URL to call on failure
|
||||||
|
Url string `json:"url,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAppjsonDirectory returns the directory containing a given app's extracted app.json file
|
// GetAppjsonDirectory returns the directory containing a given app's extracted app.json file
|
||||||
|
|||||||
Reference in New Issue
Block a user