cf

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Never = AppCleanupSetting(iota)
	Always
	OnSuccess
)

Supported cleanup settings include: - Never, leaves the app no matter if push worked or not - Always, removes the app after a push attempt - OnSuccess, removes the app if the push went through without issues

Variables

This section is empty.

Functions

func DeleteApps

func DeleteApps(apps []AppDetails) error

DeleteApps iterates over the apps in the slice and delete them

func HasBuildpack added in v0.12.1

func HasBuildpack(buildpackName string) (bool, error)

HasBuildpack returns true if Cloud Foundry reports that a buildpack with the given name exists in the list of installed buildpacks

func HumanReadableDuration added in v1.0.0

func HumanReadableDuration(duration time.Duration) string

HumanReadableDuration returns a human readable version of the time duration

Types

type AppCleanupSetting

type AppCleanupSetting int

AppCleanupSetting specifies supported cleanup options

type AppDetails

type AppDetails struct {
	Metadata struct {
		GUID      string    `json:"guid"`
		URL       string    `json:"url"`
		CreatedAt time.Time `json:"created_at"`
		UpdatedAt time.Time `json:"updated_at"`
	} `json:"metadata"`
	Entity struct {
		Name                     string      `json:"name"`
		Production               bool        `json:"production"`
		SpaceGUID                string      `json:"space_guid"`
		StackGUID                string      `json:"stack_guid"`
		Buildpack                interface{} `json:"buildpack"`
		DetectedBuildpack        string      `json:"detected_buildpack"`
		DetectedBuildpackGUID    string      `json:"detected_buildpack_guid"`
		EnvironmentJSON          interface{} `json:"environment_json"`
		Memory                   int         `json:"memory"`
		Instances                int         `json:"instances"`
		DiskQuota                int         `json:"disk_quota"`
		State                    string      `json:"state"`
		Version                  string      `json:"version"`
		Command                  interface{} `json:"command"`
		Console                  bool        `json:"console"`
		Debug                    interface{} `json:"debug"`
		StagingTaskID            string      `json:"staging_task_id"`
		PackageState             string      `json:"package_state"`
		HealthCheckType          string      `json:"health_check_type"`
		HealthCheckTimeout       interface{} `json:"health_check_timeout"`
		HealthCheckHTTPEndpoint  interface{} `json:"health_check_http_endpoint"`
		StagingFailedReason      interface{} `json:"staging_failed_reason"`
		StagingFailedDescription interface{} `json:"staging_failed_description"`
		Diego                    bool        `json:"diego"`
		DockerImage              interface{} `json:"docker_image"`
		DockerCredentials        struct {
			Username interface{} `json:"username"`
			Password interface{} `json:"password"`
		} `json:"docker_credentials"`
		PackageUpdatedAt     time.Time `json:"package_updated_at"`
		DetectedStartCommand string    `json:"detected_start_command"`
		EnableSSH            bool      `json:"enable_ssh"`
		Ports                []int     `json:"ports"`
		SpaceURL             string    `json:"space_url"`
		StackURL             string    `json:"stack_url"`
		RoutesURL            string    `json:"routes_url"`
		EventsURL            string    `json:"events_url"`
		ServiceBindingsURL   string    `json:"service_bindings_url"`
		RouteMappingsURL     string    `json:"route_mappings_url"`
	} `json:"entity"`
}

AppDetails is the Go struct for the /v2/apps/<guid> result JSON

func GetApps

func GetApps() ([]AppDetails, error)

GetApps gets all Apps of the targeted org and space

type AppsPage

type AppsPage struct {
	// TotalResults string `json:"total_results"`
	// TotalPages string `json:"total_pages"`
	// PrevURL     string       `json:"prev_url"`
	NextURL   string       `json:"next_url"`
	Resources []AppDetails `json:"resources"`
}

AppsPage represents the result from cf curl /v2/apps page

type BuildpackDetails

type BuildpackDetails struct {
	Metadata struct {
		GUID      string    `json:"guid"`
		URL       string    `json:"url"`
		CreatedAt time.Time `json:"created_at"`
		UpdatedAt time.Time `json:"updated_at"`
	} `json:"metadata"`
	Entity struct {
		Name     string      `json:"name"`
		Stack    interface{} `json:"stack"`
		Position int         `json:"position"`
		Enabled  bool        `json:"enabled"`
		Locked   bool        `json:"locked"`
		Filename string      `json:"filename"`
	} `json:"entity"`
}

BuildpackDetails is the Go struct for the /v2/buildpacks/<guid> result JSON

type BuildpackPage added in v0.12.1

type BuildpackPage struct {
	TotalResults int                `json:"total_results"`
	TotalPages   int                `json:"total_pages"`
	PrevURL      string             `json:"prev_url"`
	NextURL      string             `json:"next_url"`
	Resources    []BuildpackDetails `json:"resources"`
}

BuildpackPage represents the result of cf curl /v2/buildpacks output

type CloudFoundryConfig

type CloudFoundryConfig struct {
	ConfigVersion         int    `json:"ConfigVersion"`
	Target                string `json:"Target"`
	APIVersion            string `json:"APIVersion"`
	AuthorizationEndpoint string `json:"AuthorizationEndpoint"`
	DopplerEndPoint       string `json:"DopplerEndPoint"`
	UaaEndpoint           string `json:"UaaEndpoint"`
	RoutingAPIEndpoint    string `json:"RoutingAPIEndpoint"`
	AccessToken           string `json:"AccessToken"`
	SSHOAuthClient        string `json:"SSHOAuthClient"`
	UAAOAuthClient        string `json:"UAAOAuthClient"`
	UAAOAuthClientSecret  string `json:"UAAOAuthClientSecret"`
	RefreshToken          string `json:"RefreshToken"`
	OrganizationFields    struct {
		GUID            string `json:"GUID"`
		Name            string `json:"Name"`
		QuotaDefinition struct {
			GUID                    string `json:"guid"`
			Name                    string `json:"name"`
			MemoryLimit             int    `json:"memory_limit"`
			InstanceMemoryLimit     int    `json:"instance_memory_limit"`
			TotalRoutes             int    `json:"total_routes"`
			TotalServices           int    `json:"total_services"`
			NonBasicServicesAllowed bool   `json:"non_basic_services_allowed"`
			AppInstanceLimit        int    `json:"app_instance_limit"`
			TotalReservedRoutePorts int    `json:"total_reserved_route_ports"`
		} `json:"QuotaDefinition"`
	} `json:"OrganizationFields"`
	SpaceFields struct {
		GUID     string `json:"GUID"`
		Name     string `json:"Name"`
		AllowSSH bool   `json:"AllowSSH"`
	} `json:"SpaceFields"`
	SSLDisabled  bool   `json:"SSLDisabled"`
	AsyncTimeout int    `json:"AsyncTimeout"`
	Trace        string `json:"Trace"`
	ColorEnabled string `json:"ColorEnabled"`
	Locale       string `json:"Locale"`
	PluginRepos  []struct {
		Name string `json:"Name"`
		URL  string `json:"URL"`
	} `json:"PluginRepos"`
	MinCLIVersion            string `json:"MinCLIVersion"`
	MinRecommendedCLIVersion string `json:"MinRecommendedCLIVersion"`
}

CloudFoundryConfig defines the structure used by the Cloud Foundry CLI configuration JSONs

type DomainDetails added in v1.0.0

type DomainDetails struct {
	Metadata struct {
		GUID      string    `json:"guid"`
		URL       string    `json:"url"`
		CreatedAt time.Time `json:"created_at"`
		UpdatedAt time.Time `json:"updated_at"`
	} `json:"metadata"`
	Entity struct {
		Name            string      `json:"name"`
		Internal        bool        `json:"internal"`
		RouterGroupGUID interface{} `json:"router_group_guid"`
		RouterGroupType interface{} `json:"router_group_type"`
	} `json:"entity"`
}

DomainDetails is the Go struct for the curl /v2/shared_domains/<guid> result JSON

type PushReport

type PushReport struct {
	AppName string

	InitStart      time.Time
	CreatingStart  time.Time
	UploadingStart time.Time
	StagingStart   time.Time
	StartingStart  time.Time
	PushEnd        time.Time

	StatusCode int
	// contains filtered or unexported fields
}

PushReport encapsules details of a Cloud Foundry push command

func PushApp

func PushApp(caption string, appName string, directory files.Directory, cleanupSetting AppCleanupSetting, noPingSetting bool) (*PushReport, error)

PushApp performs a Cloud Foundry CLI based push operation

func (PushReport) Buildpack

func (report PushReport) Buildpack() string

Buildpack provides the name of the buildpack used (if detectable)

func (PushReport) CreatingTime

func (report PushReport) CreatingTime() time.Duration

CreatingTime is the time it takes to create the app in Cloud Foundry

func (PushReport) ElapsedTime

func (report PushReport) ElapsedTime() time.Duration

ElapsedTime is the overall elapsed time it takes to push an app in Cloud Foundry

func (*PushReport) Export added in v0.14.0

func (report *PushReport) Export() yaml.MapSlice

Export creates a less technical representation of the report

func (*PushReport) ExportTable added in v1.0.0

func (report *PushReport) ExportTable() [][]string

ExportTable creates a less technical representation of the report in form of a two-dimensional array

func (*PushReport) HasTimeDetails

func (report *PushReport) HasTimeDetails() bool

HasTimeDetails returns true if detailed times for each push step are available

func (PushReport) InitTime

func (report PushReport) InitTime() time.Duration

InitTime is the time it takes to initialise the Cloud Foundry app push setup

func (*PushReport) ParseUpdate

func (report *PushReport) ParseUpdate(text string) string

ParseUpdate parses a line from the CF CLI push output

func (PushReport) Stack

func (report PushReport) Stack() string

Stack provides the name of the stack used (if detectable)

func (PushReport) StagingTime

func (report PushReport) StagingTime() time.Duration

StagingTime is the time it takes to stage (compile) the app in Cloud Foundry

func (PushReport) StartingTime

func (report PushReport) StartingTime() time.Duration

StartingTime is the time it takes to start the compiled app in Cloud Foundry

func (PushReport) UploadingTime

func (report PushReport) UploadingTime() time.Duration

UploadingTime is the time it takes to upload the app bits to Cloud Foundry

type RouteDetails added in v1.0.0

type RouteDetails struct {
	Metadata struct {
		GUID      string    `json:"guid"`
		URL       string    `json:"url"`
		CreatedAt time.Time `json:"created_at"`
		UpdatedAt time.Time `json:"updated_at"`
	} `json:"metadata"`
	Entity struct {
		Host                string      `json:"host"`
		Path                string      `json:"path"`
		DomainGUID          string      `json:"domain_guid"`
		SpaceGUID           string      `json:"space_guid"`
		ServiceInstanceGUID interface{} `json:"service_instance_guid"`
		Port                interface{} `json:"port"`
		DomainURL           string      `json:"domain_url"`
		SpaceURL            string      `json:"space_url"`
		AppsURL             string      `json:"apps_url"`
		RouteMappingsURL    string      `json:"route_mappings_url"`
	} `json:"entity"`
}

RouteDetails is the Go struct for the /v2/apps/<guid>/routes result JSON

type RoutePage added in v1.0.0

type RoutePage struct {
	// TotalResults int            `json:"total_results"`
	// TotalPages   int            `json:"total_pages"`
	// PrevURL      string         `json:"prev_url"`
	// NextURL      string         `json:"next_url"`
	Resources []RouteDetails `json:"resources"`
}

RoutePage represents the result of cf curl /v2/apps/<guid>/routes output

type StackDetails

type StackDetails struct {
	Metadata struct {
		GUID      string    `json:"guid"`
		URL       string    `json:"url"`
		CreatedAt time.Time `json:"created_at"`
		UpdatedAt time.Time `json:"updated_at"`
	} `json:"metadata"`
	Entity struct {
		Name        string `json:"name"`
		Description string `json:"description"`
	} `json:"entity"`
}

StackDetails is the Go struct for the /v2/stacks/<guid> result JSON

Jump to

Keyboard shortcuts

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