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

cf

package
v2.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 12 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.Cf(cmdStarter, args...)
}
View Source
var CfRedact = func(stringToRedact string, args ...string) *gexec.Session {
	var (
		redactor          internal.Redactor
		redactingReporter internal.Reporter
	)
	cmdStarter := silentcommandstarter.NewCommandStarter()
	redactor = internal.NewRedactor(stringToRedact)
	redactingReporter = internal.NewRedactingReporter(ginkgo.GinkgoWriter, redactor)

	return internal.CfWithCustomReporter(cmdStarter, redactingReporter, args...)
}
View Source
var CfWithStdin = func(stdin io.Reader, args ...string) *gexec.Session {
	cmdStarter := commandstarter.NewCommandStarterWithStdin(stdin)
	return internal.Cf(cmdStarter, args...)
}

CfWithStdin can be used to prepare arbitrary terminal input from the user in the tests. Here is an example of how it can be used:

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

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
}

Jump to

Keyboard shortcuts

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