Documentation
¶
Overview ¶
Package codepipeline reads and writes the artifacts of a CodePipeline job, the S3 half of Powertools Python's CodePipelineJobEvent (setup_s3_client, get_artifact, put_artifact).
A CodePipeline Lambda invoke action receives temporary credentials scoped to the pipeline's artifact store. FromConfig builds an S3 client with them; New takes any client:
func handle(ctx context.Context, event eventsource.CodePipelineJobEvent) error {
artifacts := codepipeline.FromConfig(cfg, event)
template, err := artifacts.GetFile(ctx, "SourceArtifact", "template.yaml")
...
return artifacts.Put(ctx, "BuildArtifact", bytes.NewReader(out), "application/zip")
}
It lives in its own package so that importing eventsource does not bring in the S3 client.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrArtifactNotFound reports a name the job has no artifact for. ErrArtifactNotFound = errors.New("artifact not found") // ErrFileNotFound reports a file the artifact archive does not hold. ErrFileNotFound = errors.New("file not found in the artifact") )
Errors of the artifact helpers.
Functions ¶
func NewS3Client ¶
func NewS3Client(cfg aws.Config, job eventsource.CodePipelineJobEvent, optFns ...func(*s3.Options)) *s3.Client
NewS3Client returns an S3 client authenticated with the job's temporary artifact credentials. cfg gives the region and everything else; optFns customize the client further.
Types ¶
type Artifacts ¶
type Artifacts struct {
// contains filtered or unexported fields
}
Artifacts reads the input artifacts and writes the output artifacts of a job. It is safe for concurrent use when the client is.
func FromConfig ¶
func FromConfig(cfg aws.Config, job eventsource.CodePipelineJobEvent, optFns ...func(*s3.Options)) *Artifacts
FromConfig returns the artifacts of job, accessed with a client built by NewS3Client.
func New ¶
func New(client S3API, job eventsource.CodePipelineJobEvent) *Artifacts
New returns the artifacts of job, accessed with client.
func (*Artifacts) GetFile ¶
GetFile returns one file of the input artifact called name, which is a zip archive, as CodePipeline stores source and build outputs. The archive is spooled to a temporary file, as Powertools Python does, so that a large artifact does not have to fit in memory.
type S3API ¶
type S3API interface {
GetObject(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)
PutObject(ctx context.Context, params *s3.PutObjectInput, optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error)
}
S3API is the part of the S3 client the helpers use; *s3.Client satisfies it.