cf

package
v0.0.0-...-e56b6ec Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2017 License: Apache-2.0 Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ApiRequest = func(method, endpoint string, response interface{}, timeout time.Duration, data ...string) {
	args := []string{
		"curl",
		endpoint,
		"-X", method,
	}

	dataArg := strings.Join(data, "")
	if len(dataArg) > 0 {
		args = append(args, "-d", dataArg)
	}

	request := Cf(args...).Wait(timeout)
	Expect(request).To(Exit(0))

	if response != nil {
		err := json.Unmarshal(request.Out.Contents(), response)
		Expect(err).ToNot(HaveOccurred())
	}
}
View Source
var AsUser = func(userContext UserContext, timeout time.Duration, actions func()) {
	originalCfHomeDir, currentCfHomeDir := InitiateUserContext(userContext, timeout)
	defer func() {
		RestoreUserContext(userContext, timeout, originalCfHomeDir, currentCfHomeDir)
	}()

	TargetSpace(userContext, timeout)

	actions()
}
View Source
var Cf = func(args ...string) *gexec.Session {
	return runner.Run("cf", args...)
}
View Source
var CfAuth = func(user, password string) *gexec.Session {
	cmdStarter := runner.NewCommandStarterWithReporter(&sanitizedReporter{})
	return cmdStarter.Start("cf", "auth", user, password)
}

Functions

func InitiateUserContext

func InitiateUserContext(userContext UserContext, timeout time.Duration) (originalCfHomeDir, currentCfHomeDir string)

func RestoreUserContext

func RestoreUserContext(_ UserContext, timeout time.Duration, originalCfHomeDir, currentCfHomeDir string)

func TargetSpace

func TargetSpace(userContext UserContext, timeout time.Duration)

Types

type GenericResource

type GenericResource struct {
	Metadata struct {
		Guid string `json:"guid"`
	} `json:"metadata"`
}

type QueryResponse

type QueryResponse struct {
	Resources []GenericResource `struct:"resources"`
}

type UserContext

type UserContext struct {
	ApiUrl   string
	Username string
	Password string
	Org      string
	Space    string

	SkipSSLValidation bool
}

func NewUserContext

func NewUserContext(apiUrl, username, password, org, space string, skipSSLValidation bool) UserContext

Jump to

Keyboard shortcuts

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