Help us shape the future of Go! Take the 2026 Go Developer Survey

cf

package
v2.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 13 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cf = func(args ...string) *gexec.Session {
	cmdStarter := commandstarter.NewCommandStarter()
	return internal.CfWithCustomReporter(cmdStarter, defaultReporter(), args...)
}
View Source
var CfRedact = func(stringToRedact string, args ...string) *gexec.Session {
	cmdStarter := silentcommandstarter.NewCommandStarter()
	redactor := internal.NewRedactor(stringToRedact)
	reporter := internal.NewRedactingReporter(ginkgo.GinkgoWriter, redactor)
	return internal.CfWithCustomReporter(cmdStarter, reporter, args...)
}
View Source
var CfWithStdin = func(stdin io.Reader, args ...string) *gexec.Session {
	cmdStarter := commandstarter.NewCommandStarterWithStdin(stdin)
	return internal.CfWithCustomReporter(cmdStarter, defaultReporter(), args...)
}

CfWithStdin can be used to prepare arbitrary terminal input from the user in the tests.

inputConfirmingPrompt := bytes.NewBufferString("yes\n") session := cf.CfWithStdin(inputConfirmingPrompt, "update-service", "my-service", "--upgrade") Eventually(session).Should(Exit(0))

View Source
var Push = func(appName string, args ...string) *gexec.Session {
	tmpDir, err := os.MkdirTemp("", "")
	if err != nil {
		panic(err)
	}

	app := Application{
		Name: appName,
	}

	for i := 0; i < len(args); i += 2 {
		flag := args[i]
		flagValue := args[i+1]

		switch flag {
		case "-b":
			app.Buildpacks = append(app.Buildpacks, flagValue)
		case "-c":
			app.Command = flagValue
		case "-d":
			app.Routes = append(app.Routes, map[string]string{"route": fmt.Sprintf("%s.%s", appName, flagValue)})
		case "-i":
			instances, err := strconv.Atoi(flagValue)
			if err != nil {
				panic(err)
			}
			app.Instances = instances
		case "-m":
			app.Memory = flagValue
		case "-p":
			path, err := filepath.Abs(flagValue)
			if err != nil {
				panic(err)
			}
			app.Path = path
		case "-s":
			app.Stack = flagValue
		}
	}

	manifest := Manifest{}

	manifest.Applications = append(manifest.Applications, app)

	manifestText, err := yaml.Marshal(manifest)
	if err != nil {
		panic(err)
	}

	manifestPath := filepath.Join(tmpDir, "manifest.yml")
	err = os.WriteFile(manifestPath, manifestText, 0644)
	if err != nil {
		panic(err)
	}

	_, err = fmt.Fprintf(
		ginkgo.GinkgoWriter,
		"\n[%s]> Generated app manifest:\n%s\n",
		time.Now().UTC().Format("2006-01-02 15:04:05.00 (MST)"),
		string(manifestText),
	)
	if err != nil {
		panic(err)
	}

	return Cf("push",
		"-f", manifestPath,
	)
}

Functions

func CfSilent

func CfSilent(args ...string) *gexec.Session

func RegisterObserver added in v2.15.0

func RegisterObserver(observer Observer)

func UnregisterObserver added in v2.15.0

func UnregisterObserver()

Types

type Application

type Application struct {
	Buildpacks []string `yaml:",omitempty"`
	Stack      string   `yaml:",omitempty"`
	Command    string   `yaml:",omitempty"`
	Instances  int      `yaml:",omitempty"`
	Memory     string   `yaml:",omitempty"`
	Name       string
	Path       string              `yaml:",omitempty"`
	Routes     []map[string]string `yaml:",omitempty"`
}

type Manifest

type Manifest struct {
	Applications []Application
}

type Observer added in v2.15.0

type Observer = internal.CommandObserver

Observer is exported here so downstream packages need not import .../internal.

Jump to

Keyboard shortcuts

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