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

containers

package
v1.5.2-0...-36bfd17 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetermineTomcatVersion

func DetermineTomcatVersion(version string) string

based on the JBP_CONFIG_TOMCAT field from manifest. It looks for a tomcat block with a version of the form "<major>.+" (e.g. "9.+", "10.+", "10.1.+"). Returns the pattern with "+" replaced by "*" (e.g. "9.*", "10.*", "10.1.*") so libbuildpack can resolve it. Masterminds/semver treats x, X, and * as equivalent wildcards.

func FindMainGroovyScript

func FindMainGroovyScript(scripts []string) (string, error)

FindMainGroovyScript determines which Groovy script should be executed. Following Ruby buildpack logic, a file is a candidate if it has a static void main() method, is not a POGO, or has a shebang. Returns the single candidate if exactly one matches, empty string otherwise.

func JavaExecCommand

func JavaExecCommand(depsIdx, javaArgs string) string

JavaExecCommand builds a start command of the form:

exec $DEPS_DIR/<idx>/bin/javaexec "$JAVA_HOME/bin/java" <javaArgs>

The javaexec launcher reads JAVA_OPTS from the environment and tokenizes it without a shell, so glob characters, quotes, and shell metacharacters in user-provided JAVA_OPTS are never expanded or executed. This replaces the previous `eval "exec $JAVA_HOME/bin/java $JAVA_OPTS <javaArgs>"` form, which let the shell glob-expand $JAVA_OPTS and execute embedded command substitutions.

javaArgs are buildpack-generated (jar paths, Main-Class, classpath, and shell expansions like ${CLASSPATH} or BOOT-INF/lib/*) and are placed on a normal command line, where the shell expands them exactly as before.

func SelectTomcatVersionPattern

func SelectTomcatVersionPattern(javaHome, configVersion string) (string, error)

SelectTomcatVersionPattern determines the Tomcat version pattern to use based on the detected Java version and any user-configured Tomcat version. Returns ("", nil) when Java version cannot be determined — the caller should fall back to the manifest default (matching Ruby buildpack behaviour).

Types

type AccessLoggingSupport

type AccessLoggingSupport struct {
	AccessLogging string `yaml:"access_logging"`
}

type Container

type Container interface {
	// Detect returns true if this container should handle the application
	// Returns the container name and version if detected
	Detect() (string, error)

	// Supply installs the container and its dependencies
	Supply() error

	// Finalize performs final container configuration
	Finalize() error

	// Release returns the startup command for the container
	Release() (string, error)
}

Container represents a Java application container (Tomcat, Spring Boot, etc.)

type DistZipContainer

type DistZipContainer struct {
	// contains filtered or unexported fields
}

DistZipContainer handles distribution ZIP applications (applications with bin/ and lib/ structure, typically from Gradle's distZip)

func NewDistZipContainer

func NewDistZipContainer(ctx *common.Context) *DistZipContainer

NewDistZipContainer creates a new Dist ZIP container

func (*DistZipContainer) Detect

func (d *DistZipContainer) Detect() (string, error)

Detect checks if this is a Dist ZIP application

func (*DistZipContainer) Finalize

func (d *DistZipContainer) Finalize() error

Finalize performs final Dist ZIP configuration

func (*DistZipContainer) Release

func (d *DistZipContainer) Release() (string, error)

Release returns the Dist ZIP startup command Uses absolute path to ensure script is found at runtime

func (*DistZipContainer) Supply

func (d *DistZipContainer) Supply() error

Supply installs Dist ZIP dependencies

type ExternalConfiguration

type ExternalConfiguration struct {
	Version        string `yaml:"version"`
	RepositoryRoot string `yaml:"repository_root"`
}

type GroovyContainer

type GroovyContainer struct {
	// contains filtered or unexported fields
}

GroovyContainer handles Groovy script applications

func NewGroovyContainer

func NewGroovyContainer(ctx *common.Context) *GroovyContainer

NewGroovyContainer creates a new Groovy container

func (*GroovyContainer) Detect

func (g *GroovyContainer) Detect() (string, error)

Detect checks if this is a Groovy application

func (*GroovyContainer) Finalize

func (g *GroovyContainer) Finalize() error

Finalize performs final Groovy configuration

func (*GroovyContainer) Release

func (g *GroovyContainer) Release() (string, error)

Release returns the Groovy startup command

func (*GroovyContainer) Supply

func (g *GroovyContainer) Supply() error

Supply installs Groovy and dependencies

type GroovyUtils

type GroovyUtils struct{}

GroovyUtils struct provides instance methods for SpringBootCLI compatibility

func (*GroovyUtils) FindGroovyFiles

func (g *GroovyUtils) FindGroovyFiles(dir string) ([]string, error)

FindGroovyFiles finds all .groovy files in the given directory

func (*GroovyUtils) HasMainMethod

func (g *GroovyUtils) HasMainMethod(filePath string) bool

HasMainMethod checks if a Groovy file contains a static void main() method

func (*GroovyUtils) HasShebang

func (g *GroovyUtils) HasShebang(filePath string) bool

HasShebang checks if a Groovy file has a shebang line (#!/...)

func (*GroovyUtils) IsLogbackConfigFile

func (g *GroovyUtils) IsLogbackConfigFile(filePath string) bool

IsLogbackConfigFile checks if a file is a logback configuration file

func (*GroovyUtils) IsPOGO

func (g *GroovyUtils) IsPOGO(filePath string) bool

IsPOGO checks if a Groovy file is a Plain Old Groovy Object (contains a class definition)

type JavaMainContainer

type JavaMainContainer struct {
	// contains filtered or unexported fields
}

JavaMainContainer handles standalone JAR applications with a main class

func NewJavaMainContainer

func NewJavaMainContainer(ctx *common.Context) *JavaMainContainer

NewJavaMainContainer creates a new Java Main container

func (*JavaMainContainer) Detect

func (j *JavaMainContainer) Detect() (string, error)

Detect checks if this is a Java Main application

func (*JavaMainContainer) Finalize

func (j *JavaMainContainer) Finalize() error

Finalize performs final Java Main configuration

func (*JavaMainContainer) Release

func (j *JavaMainContainer) Release() (string, error)

Release returns the Java Main startup command

func (*JavaMainContainer) Supply

func (j *JavaMainContainer) Supply() error

Supply installs Java Main dependencies

type PlayContainer

type PlayContainer struct {
	// contains filtered or unexported fields
}

PlayContainer represents a Play Framework application container

func NewPlayContainer

func NewPlayContainer(ctx *common.Context) *PlayContainer

NewPlayContainer creates a new Play Framework container

func (*PlayContainer) Detect

func (p *PlayContainer) Detect() (string, error)

Detect checks if this is a Play Framework application

func (*PlayContainer) Finalize

func (p *PlayContainer) Finalize() error

Finalize performs final configuration for the Play Framework application

func (*PlayContainer) Release

func (p *PlayContainer) Release() (string, error)

Release returns the command to start the Play Framework application

func (*PlayContainer) Supply

func (p *PlayContainer) Supply() error

Supply installs and configures the Play Framework application

func (*PlayContainer) Validate

func (p *PlayContainer) Validate() error

Validate checks for ambiguous Play configurations without mutating the receiver.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages available containers

func NewRegistry

func NewRegistry(ctx *common.Context) *Registry

NewRegistry creates a new container registry

func (*Registry) Detect

func (r *Registry) Detect() (Container, string, error)

Detect finds the first container that can handle the application. If JBP_CONFIG_JAVA_MAIN specifies an explicit java_main_class, the Java Main container is selected unconditionally — before the normal priority order — so it can override higher-priority containers such as Spring Boot. Java Main is always registered last (lowest priority), so it is the last element.

func (*Registry) DetectAll

func (r *Registry) DetectAll() ([]Container, []string, error)

DetectAll returns all containers that can handle the application

func (*Registry) Get

func (r *Registry) Get(name string) Container

Get returns the container whose Detect() returns the given name, or nil if not found. Used by the finalize phase to resolve a container by the name stored in config.yml.

func (*Registry) Register

func (r *Registry) Register(c Container)

Register adds a container to the registry

func (*Registry) RegisterStandardContainers

func (r *Registry) RegisterStandardContainers()

RegisterStandardContainers registers all standard containers in the correct priority order. This ensures Supply and Finalize phases use the same detection order. IMPORTANT: The order matters! Containers are checked in registration order. More specific containers (with stricter detection rules) must come before generic ones.

type SpringBootContainer

type SpringBootContainer struct {
	// contains filtered or unexported fields
}

SpringBootContainer handles Spring Boot JAR applications

func NewSpringBootContainer

func NewSpringBootContainer(ctx *common.Context) *SpringBootContainer

NewSpringBootContainer creates a new Spring Boot container

func (*SpringBootContainer) Detect

func (s *SpringBootContainer) Detect() (string, error)

Detect checks if this is a Spring Boot application

func (*SpringBootContainer) Finalize

func (s *SpringBootContainer) Finalize() error

Finalize performs final Spring Boot configuration

func (*SpringBootContainer) Release

func (s *SpringBootContainer) Release() (string, error)

Release returns the Spring Boot startup command

func (*SpringBootContainer) Supply

func (s *SpringBootContainer) Supply() error

Supply installs Spring Boot dependencies

type Tomcat

type Tomcat struct {
	Version                      string `yaml:"version"`
	ExternalConfigurationEnabled bool   `yaml:"external_configuration_enabled"`
	ContextPath                  string `yaml:"context_path"`
}

type TomcatContainer

type TomcatContainer struct {
	// contains filtered or unexported fields
}

TomcatContainer handles servlet/WAR applications

func NewTomcatContainer

func NewTomcatContainer(ctx *common.Context) *TomcatContainer

NewTomcatContainer creates a new Tomcat container

func (*TomcatContainer) Detect

func (t *TomcatContainer) Detect() (string, error)

Detect checks if this is a Tomcat/servlet application

func (*TomcatContainer) Finalize

func (t *TomcatContainer) Finalize() error

Finalize performs final Tomcat configuration

func (*TomcatContainer) Release

func (t *TomcatContainer) Release() (string, error)

Release returns the Tomcat startup command

func (*TomcatContainer) Supply

func (t *TomcatContainer) Supply() error

Supply installs Tomcat and dependencies

Jump to

Keyboard shortcuts

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