override

package
v1.34.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package override defines functionality to interact with the "overrides/" directory for accessing and mutating the Copilot generated AWS CloudFormation templates.

Index

Constants

View Source
const (
	YAMLPatchFile = "cfn.patches.yml" // YAMLPatchFile is the name of the YAML patch override file.

)

Variables

This section is empty.

Functions

func ScaffoldWithCDK

func ScaffoldWithCDK(fs afero.Fs, dir string, seeds []template.CFNResource, requiresEnv bool) error

ScaffoldWithCDK bootstraps a CDK application under dir/ to override the seed CloudFormation resources. If the directory is not empty, then returns an error.

func ScaffoldWithPatch added in v1.27.0

func ScaffoldWithPatch(fs afero.Fs, dir string) error

ScaffoldWithPatch sets up YAML patches in dir/ to apply to the Copilot generated CloudFormation template.

Types

type CDK

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

CDK is an Overrider that can transform a CloudFormation template with the Cloud Development Kit.

func WithCDK

func WithCDK(root string, opts CDKOpts) *CDK

WithCDK instantiates a new CDK Overrider with root being the path to the overrides/ directory.

func (*CDK) Override

func (cdk *CDK) Override(body []byte) ([]byte, error)

Override returns the extended CloudFormation template body using the CDK. In order to ensure the CDK transformations can be applied, Copilot first installs any CDK dependencies as well as the toolkit itself.

type CDKOpts

type CDKOpts struct {
	ExecWriter io.Writer                                   // Writer to forward stdout and stderr writes from os/exec calls. If nil default to io.Discard.
	FS         afero.Fs                                    // File system interface. If nil, defaults to the OS file system.
	EnvVars    map[string]string                           // Environment variables key value pairs to pass to the "cdk synth" command.
	LookPathFn func(executable string) (string, error)     // Search for the executable under $PATH. Defaults to exec.LookPath.
	CommandFn  func(name string, args ...string) *exec.Cmd // Create a new executable command. Defaults to exec.Command rooted at the overrides/ dir.
}

CDKOpts is optional configuration for initializing a CDK Overrider.

type ErrNotExist

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

ErrNotExist occurs when the path of the file associated with an Overrider does not exist.

func (*ErrNotExist) Error

func (err *ErrNotExist) Error() string

type Info

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

Info holds metadata about an overrider.

func Lookup

func Lookup(path string, fs afero.Fs) (Info, error)

Lookup returns information indicating if the overrider is a CDK application or YAML Patches. If path does not exist, then return an ErrNotExist. If path is a directory that contains cfn.patches.yml, then IsYAMLPatch evaluates to true. If path is a directory that contains a cdk.json file, then IsCDK evaluates to true.

func (Info) IsCDK

func (i Info) IsCDK() bool

IsCDK returns true if the overrider is a CDK application.

func (Info) IsYAMLPatch

func (i Info) IsYAMLPatch() bool

IsYAMLPatch returns true if the overrider is a YAML patch document.

func (Info) Path

func (i Info) Path() string

Path returns the path to the overrider. For CDK applications, returns the root of the CDK directory. For YAML patch documents, returns the path to the file.

type Noop

type Noop struct{}

Noop represents an Overrider that does not do any transformations.

func (*Noop) Override

func (no *Noop) Override(body []byte) ([]byte, error)

Override does nothing.

type Patch added in v1.27.0

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

Patch applies overrides configured as JSON Patches, as defined in https://www.rfc-editor.org/rfc/rfc6902.

func WithPatch added in v1.27.0

func WithPatch(filePath string, opts PatchOpts) *Patch

WithPatch instantiates a new Patch Overrider with root being the path to the overrides/ directory. It supports a single file (cfn.patches.yml) with configured patches.

func (*Patch) Override added in v1.27.0

func (p *Patch) Override(body []byte) ([]byte, error)

Override returns the overriden CloudFormation template body after applying YAML patches to it.

type PatchOpts added in v1.27.0

type PatchOpts struct {
	FS afero.Fs // File system interface. If nil, defaults to the OS file system.
}

PatchOpts is optional configuration for initializing a Patch Overrider.

Jump to

Keyboard shortcuts

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