bundler

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(
	logger scribe.Logger,
	vr RubyVersionResolver,
	calc fs.ChecksumCalculator,
	bc RunBashCmd,
	pm PumaInstaller) packit.BuildFunc

Build the RVM layer provided by this buildpack

func Detect

func Detect(logger rvm.LogEmitter, bundlerVersionParser VersionParser, buildpackYMLParser VersionParser) packit.DetectFunc

Detect whether this buildpack should install RVM

func InstallBundler

func InstallBundler(context packit.BuildContext, configuration Configuration, logger scribe.Logger, versionResolver VersionResolver, calculator Calculator, bashcmd BashCmd, pumainstaller PumaInstaller) (packit.BuildResult, error)

InstallBundler install bundler in a given RVM environment

To configure the Bundler environment, InstallBundler will copy the local Bundler configuration, if any, into the target layer path. The configuration file created in the layer will become the defacto configuration file by setting `BUNDLE_USER_CONFIG` in the local environment while executing the subsequent Bundle CLI commands. The configuration will then be modifed with any settings specific to the invocation of Execute. These configurations will override any settings previously applied in the local Bundle configuration.

func ShouldRun added in v0.0.15

func ShouldRun(metadata map[string]interface{}, workingDir string, versionResolver VersionResolver, calculator Calculator, bashcmd BashCmd) (bool, string, string, error)

ShouldRun will return true if it is determined that the BundleInstallProcess be executed during the build phase.

The criteria for determining that the install process should be executed is if the major or minor version of Ruby has changed, or if the contents of the Gemfile or Gemfile.lock have changed.

In addition to reporting if the install process should execute, this method will return the current version of Ruby and the checksum of the Gemfile and Gemfile.lock contents.

Types

type BashCmd added in v0.0.16

type BashCmd interface {
	RunBashCmd(command string, WorkingDir string) (string, error)
}

BashCmd defines the interface for running a bash command.

type BuildPackYML

type BuildPackYML struct {
	BundlerVersion string `yaml:"bundler_version"`
}

BuildPackYML represents the buildpack.yml file provided by a user / an app

func BuildpackYMLParse

func BuildpackYMLParse(path string) (BuildPackYML, error)

BuildpackYMLParse parses the buildpack.yml file

type BuildPlanMetadata

type BuildPlanMetadata struct {
	RvmBundlerVersion string `toml:"rvm_bundler_version"`
	VersionSource     string `toml:"version_source"`
}

BuildPlanMetadata represents this buildpack's metadata

type BuildpackYMLParser

type BuildpackYMLParser struct{}

BuildpackYMLParser represents the buildpack.yml parser

func NewBuildpackYMLParser

func NewBuildpackYMLParser() BuildpackYMLParser

NewBuildpackYMLParser creates and returns a new buildpack.yml parser

func (BuildpackYMLParser) ParseVersion

func (p BuildpackYMLParser) ParseVersion(path string) (string, error)

ParseVersion parses the buildpack.yml file and returns a a ruby version, if one was specified

type BundlerVersionParser

type BundlerVersionParser struct{}

BundlerVersionParser represents a Gemfile.lock parser

func NewBundlerVersionParser

func NewBundlerVersionParser() BundlerVersionParser

NewBundlerVersionParser creates a new Gemfile.lock parser

func (BundlerVersionParser) ParseVersion

func (r BundlerVersionParser) ParseVersion(path string) (string, error)

ParseVersion looks for a Gemfile.lock file in a given path and, if it exists, parses it to find a string "BUNDLED WITH" and returns the string in the next line minus the whitespace

type Calculator added in v0.0.15

type Calculator interface {
	Sum(paths ...string) (string, error)
}

Calculator defines the interface for calculating a checksum of the given set of file paths.

type Configuration

type Configuration struct {
	DefaultBundlerVersion string `toml:"default_bundler_version"`
	InstallPuma           bool   `toml:"install_puma"`
	Puma                  Puma   `toml:"puma"`
}

Configuration represents this buildpack's configuration read from a table named "configuration"

func ReadConfiguration

func ReadConfiguration(cnbPath string) (Configuration, error)

ReadConfiguration returns the configuration for this buildpack

type MetaData

type MetaData struct {
	Metadata struct {
		Configuration Configuration `toml:"configuration"`
	} `toml:"metadata"`
}

MetaData represents this buildpack's metadata

type Puma added in v0.0.3

type Puma struct {
	Version string `toml:"version"`
	Bind    string `toml:"bind"`
	Workers string `toml:"workers"`
	Threads string `toml:"threads"`
	Preload bool   `toml:"preload"`
}

Puma represents the configuration structure for Puma

type PumaGemInstaller added in v0.0.16

type PumaGemInstaller struct{}

PumaGemInstaller represents a new puma gem installer

func NewPumaInstaller added in v0.0.16

func NewPumaInstaller() PumaGemInstaller

NewPumaInstaller creates a new puma gem installer

func (PumaGemInstaller) CreatePumaProcess added in v0.0.16

func (p PumaGemInstaller) CreatePumaProcess(context packit.BuildContext, configuration Configuration, logger scribe.Logger) (packit.Process, error)

CreatePumaProcess creates a packit.Process if this buildpack is configured to do so. If there is a Procfile in the application's directory and it it contains a process of type "web:", then no packit.Process will be returned

func (PumaGemInstaller) InstallPuma added in v0.0.16

func (p PumaGemInstaller) InstallPuma(context packit.BuildContext, configuration Configuration, logger scribe.Logger) error

InstallPuma install the Puma gem and creates a workingDir/config/puma.rb if the file doesn't exist already

type PumaInstaller added in v0.0.16

type PumaInstaller interface {
	InstallPuma(context packit.BuildContext, configuration Configuration, logger scribe.Logger) error
	CreatePumaProcess(context packit.BuildContext, configuration Configuration, logger scribe.Logger) (packit.Process, error)
}

PumaInst defines the interface for running a bash command.

type RubyVersionResolver added in v0.0.15

type RubyVersionResolver struct {
}

RubyVersionResolver identifies and compares versions of Ruby used in the build environment.

func NewRubyVersionResolver added in v0.0.15

func NewRubyVersionResolver() RubyVersionResolver

NewRubyVersionResolver initializes an instance of RubyVersionResolver.

func (RubyVersionResolver) Lookup added in v0.0.15

func (r RubyVersionResolver) Lookup(workingDir string, bashcmd BashCmd) (string, error)

Lookup returns the version of Ruby installed in the build environment.

type RunBashCmd

type RunBashCmd struct{}

BashCmd represents a bash cmd runner

func NewRunBashCmd added in v0.0.16

func NewRunBashCmd() RunBashCmd

NewBashCmd creates a new bash cmd runner

func (RunBashCmd) RunBashCmd added in v0.0.16

func (r RunBashCmd) RunBashCmd(command string, WorkingDir string) (string, error)

RunBashCmd executes a command in an interactive BASH shell

type VersionParser

type VersionParser interface {
	ParseVersion(path string) (version string, err error)
}

VersionParser represents a parser for files like .ruby-version and Gemfiles

type VersionResolver added in v0.0.15

type VersionResolver interface {
	Lookup(workingDir string, bashcmd BashCmd) (version string, err error)
}

VersionResolver defines the interface for looking up and comparing the versions of Ruby installed in the environment.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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