Documentation
¶
Index ¶
- Constants
- func CreateBucket(ctx context.Context, client *Client, ...) (string, error)
- func CreateBuild(ctx context.Context, client *Client, ...) (string, error)
- func CreateIteration(ctx context.Context, client *Client, ...) (*models.HashicorpCloudPackerIteration, error)
- func GetGitFingerprint(opts IterationOptions) (string, error)
- func GetIteration(ctx context.Context, client *Client, bucketslug string, fingerprint string) (*models.HashicorpCloudPackerIteration, error)
- func GetIterationFromChannel(ctx context.Context, client *Client, bucketSlug string, channelName string) (*models.HashicorpCloudPackerIteration, error)
- func GetIterationFromId(ctx context.Context, client *Client, bucketslug string, iterationId string) (*models.HashicorpCloudPackerIteration, error)
- func ListBuilds(ctx context.Context, client *Client, bucketSlug string, iterationID string) ([]*models.HashicorpCloudPackerBuild, error)
- func UpdateBuild(ctx context.Context, client *Client, ...) (string, error)
- func UpsertBucket(ctx context.Context, client *Client, ...) error
- type Bucket
- func (b *Bucket) CreateInitialBuildForIteration(ctx context.Context, componentType string) error
- func (b *Bucket) Initialize(ctx context.Context) error
- func (b *Bucket) IsExpectingBuildForComponent(buildName string) bool
- func (b *Bucket) LoadDefaultSettingsFromEnv()
- func (b *Bucket) PopulateIteration(ctx context.Context) error
- func (b *Bucket) RegisterBuildForComponent(sourceName string)
- func (b *Bucket) UpdateBuildStatus(ctx context.Context, name string, ...) error
- func (b *Bucket) UpdateImageForBuild(componentType string, images ...registryimage.Image) error
- func (b *Bucket) UpdateLabelsForBuild(componentType string, data map[string]string) error
- func (b *Bucket) Validate() error
- type Build
- type Client
- type ClientError
- type Iteration
- type IterationOptions
- type MockPackerClientService
- func (svc *MockPackerClientService) PackerServiceCreateBucket(params *packerSvc.PackerServiceCreateBucketParams, ...) (*packerSvc.PackerServiceCreateBucketOK, error)
- func (svc *MockPackerClientService) PackerServiceCreateBuild(params *packerSvc.PackerServiceCreateBuildParams, ...) (*packerSvc.PackerServiceCreateBuildOK, error)
- func (svc *MockPackerClientService) PackerServiceCreateIteration(params *packerSvc.PackerServiceCreateIterationParams, ...) (*packerSvc.PackerServiceCreateIterationOK, error)
- func (svc *MockPackerClientService) PackerServiceGetIteration(params *packerSvc.PackerServiceGetIterationParams, ...) (*packerSvc.PackerServiceGetIterationOK, error)
- func (svc *MockPackerClientService) PackerServiceListBuilds(params *packerSvc.PackerServiceListBuildsParams, ...) (*packerSvc.PackerServiceListBuildsOK, error)
- func (svc *MockPackerClientService) PackerServiceUpdateBucket(params *packerSvc.PackerServiceUpdateBucketParams, ...) (*packerSvc.PackerServiceUpdateBucketOK, error)
- func (svc *MockPackerClientService) PackerServiceUpdateBuild(params *packerSvc.PackerServiceUpdateBuildParams, ...) (*packerSvc.PackerServiceUpdateBuildOK, error)
Constants ¶
const (
InvalidClientConfig
)
Variables ¶
This section is empty.
Functions ¶
func CreateBucket ¶
func CreateBucket(ctx context.Context, client *Client, input *models.HashicorpCloudPackerCreateBucketRequest) (string, error)
CreateBucket creates a bucket on a HCP Packer Registry.
func CreateBuild ¶
func CreateBuild(ctx context.Context, client *Client, input *models.HashicorpCloudPackerCreateBuildRequest) (string, error)
CreateBuild create a build entry to track for the IterationID and BucketSlug defined within input.
func CreateIteration ¶
func CreateIteration(ctx context.Context, client *Client, input *models.HashicorpCloudPackerCreateIterationRequest) (*models.HashicorpCloudPackerIteration, error)
CreateIteration creates an Iteration for some Bucket on a HCP Packer Registry.
func GetGitFingerprint ¶
func GetGitFingerprint(opts IterationOptions) (string, error)
GetGitFingerprint returns the HEAD commit for some template dir defined in opt.TemplateBaseDir. If the base directory is not under version control an error is returned.
func GetIteration ¶
func GetIteration(ctx context.Context, client *Client, bucketslug string, fingerprint string) (*models.HashicorpCloudPackerIteration, error)
GetIteration queries the HCP Packer registry for an existing bucket iteration.
func GetIterationFromChannel ¶
func GetIterationFromChannel(ctx context.Context, client *Client, bucketSlug string, channelName string) (*models.HashicorpCloudPackerIteration, error)
GetChannel loads the iterationId associated with a current channel. If the channel does not exist in HCP Packer, GetChannel returns an error.
func GetIterationFromId ¶
func GetIterationFromId(ctx context.Context, client *Client, bucketslug string, iterationId string) (*models.HashicorpCloudPackerIteration, error)
GetIteration queries the HCP Packer registry for an existing bucket iteration.
func ListBuilds ¶
func ListBuilds(ctx context.Context, client *Client, bucketSlug string, iterationID string) ([]*models.HashicorpCloudPackerBuild, error)
ListBuilds queries an Iteration on HCP Packer registry for all of it's associated builds. Currently all builds are returned regardless of status.
func UpdateBuild ¶
func UpdateBuild(ctx context.Context, client *Client, input *models.HashicorpCloudPackerUpdateBuildRequest) (string, error)
UpdateBuild updates a single iteration build entry with the incoming input data.
func UpsertBucket ¶
func UpsertBucket(ctx context.Context, client *Client, input *models.HashicorpCloudPackerCreateBucketRequest) error
UpsertBucket tries to create a bucket on a HCP Packer Registry. If the bucket exists it will handle the error and update the bucket with the provided details.
Types ¶
type Bucket ¶
type Bucket struct { Slug string Description string Destination string Labels map[string]string Iteration *Iteration // contains filtered or unexported fields }
Bucket represents a single Image bucket on the HCP Packer registry.
func NewBucketWithIteration ¶
func NewBucketWithIteration(opts IterationOptions) (*Bucket, error)
NewBucketWithIteration initializes a simple Bucket that can be used publishing Packer build images to the HCP Packer registry.
func (*Bucket) CreateInitialBuildForIteration ¶
CreateInitialBuildForIteration will create a build entry on the HCP Packer Registry for the named componentType. This initial creation is needed so that Packer can properly track when an iteration is complete.
func (*Bucket) Initialize ¶
Initialize registers the Bucket b with the configured HCP Packer Registry. Upon initialization a Bucket will be upserted to, and new iteration will be created for the build if the configured fingerprint has no associated iterations. Lastly, the initialization process with register the builds that need to be completed before an iteration can be marked as DONE.
b.Initialize() must be called before any data can be published to the configured HCP Packer Registry. TODO ensure initialize can only be called once
func (*Bucket) IsExpectingBuildForComponent ¶
IsExpectingBuildForComponent returns true if the component referenced by buildName is part of the iteration and is not marked as DONE on the HCP Packer registry.
func (*Bucket) LoadDefaultSettingsFromEnv ¶
func (b *Bucket) LoadDefaultSettingsFromEnv()
Load defaults from environment variables
func (*Bucket) PopulateIteration ¶ added in v1.7.7
populateIteration populates the bucket iteration with the details needed for tracking builds for a Packer run. If an existing Packer registry iteration exists for the said iteration fingerprint, calling initialize on iteration that doesn't yet exist will call createIteration to create the entry on the HCP packer registry for the given bucket. All build details will be created (if they don't exists) and added to b.Iteration.builds for tracking during runtime.
func (*Bucket) RegisterBuildForComponent ¶
func (*Bucket) UpdateBuildStatus ¶
func (b *Bucket) UpdateBuildStatus(ctx context.Context, name string, status models.HashicorpCloudPackerBuildStatus) error
UpdateBuildStatus updates the status of a build entry on the HCP Packer registry with its current local status.
func (*Bucket) UpdateImageForBuild ¶
func (b *Bucket) UpdateImageForBuild(componentType string, images ...registryimage.Image) error
UpdateImageForBuild appends one or more images artifacts to the build referred to by componentType.
func (*Bucket) UpdateLabelsForBuild ¶
UpdateLabelsForBuild merges the contents of data to the labels associated with the build referred to by componentType.
type Build ¶
type Build struct { ID string CloudProvider string ComponentType string RunUUID string Labels map[string]string Images map[string]registryimage.Image Status models.HashicorpCloudPackerBuildStatus }
Build represents a build of a given component type for some bucket on the HCP Packer Registry.
type Client ¶
type Client struct { Packer packerSvc.ClientService Organization organizationSvc.ClientService Project projectSvc.ClientService // OrganizationID is the organization unique identifier on HCP. OrganizationID string // ProjectID is the project unique identifier on HCP. ProjectID string }
Client is an HCP client capable of making requests on behalf of a service principal
type ClientError ¶
ClientError represents a generic error for the Cloud Packer Service client.
func (*ClientError) Error ¶
func (c *ClientError) Error() string
Error returns the string message for some ClientError.
type Iteration ¶
type Iteration struct { ID string AncestorSlug string Fingerprint string RunUUID string Labels map[string]string // contains filtered or unexported fields }
func NewIteration ¶
func NewIteration(opts IterationOptions) (*Iteration, error)
NewIteration returns a pointer to an Iteration that can be used for storing Packer build details needed by PAR.
func (*Iteration) AddImageToBuild ¶
func (i *Iteration) AddImageToBuild(buildName string, images ...registryimage.Image) error
AddImageToBuild appends one or more images artifacts to the build referred to by buildName.
type IterationOptions ¶
type IterationOptions struct {
TemplateBaseDir string
}
type MockPackerClientService ¶
type MockPackerClientService struct {
CreateBucketCalled, UpdateBucketCalled, BucketAlreadyExist bool
CreateIterationCalled, GetIterationCalled, IterationAlreadyExist, IterationCompleted bool
CreateBuildCalled, UpdateBuildCalled, ListBuildsCalled, BuildAlreadyDone bool
// Mock Creates
CreateBucketResp *models.HashicorpCloudPackerCreateBucketResponse
CreateIterationResp *models.HashicorpCloudPackerCreateIterationResponse
CreateBuildResp *models.HashicorpCloudPackerCreateBuildResponse
// Mock Gets
GetIterationResp *models.HashicorpCloudPackerGetIterationResponse
ExistingBuilds []string
packerSvc.ClientService
}
func NewMockPackerClientService ¶
func NewMockPackerClientService() *MockPackerClientService
func (*MockPackerClientService) PackerServiceCreateBucket ¶ added in v1.7.7
func (svc *MockPackerClientService) PackerServiceCreateBucket(params *packerSvc.PackerServiceCreateBucketParams, _ runtime.ClientAuthInfoWriter) (*packerSvc.PackerServiceCreateBucketOK, error)
func (*MockPackerClientService) PackerServiceCreateBuild ¶ added in v1.7.7
func (svc *MockPackerClientService) PackerServiceCreateBuild(params *packerSvc.PackerServiceCreateBuildParams, _ runtime.ClientAuthInfoWriter) (*packerSvc.PackerServiceCreateBuildOK, error)
func (*MockPackerClientService) PackerServiceCreateIteration ¶ added in v1.7.7
func (svc *MockPackerClientService) PackerServiceCreateIteration(params *packerSvc.PackerServiceCreateIterationParams, _ runtime.ClientAuthInfoWriter) (*packerSvc.PackerServiceCreateIterationOK, error)
func (*MockPackerClientService) PackerServiceGetIteration ¶ added in v1.7.7
func (svc *MockPackerClientService) PackerServiceGetIteration(params *packerSvc.PackerServiceGetIterationParams, _ runtime.ClientAuthInfoWriter) (*packerSvc.PackerServiceGetIterationOK, error)
func (*MockPackerClientService) PackerServiceListBuilds ¶ added in v1.7.7
func (svc *MockPackerClientService) PackerServiceListBuilds(params *packerSvc.PackerServiceListBuildsParams, _ runtime.ClientAuthInfoWriter) (*packerSvc.PackerServiceListBuildsOK, error)
func (*MockPackerClientService) PackerServiceUpdateBucket ¶ added in v1.7.7
func (svc *MockPackerClientService) PackerServiceUpdateBucket(params *packerSvc.PackerServiceUpdateBucketParams, _ runtime.ClientAuthInfoWriter) (*packerSvc.PackerServiceUpdateBucketOK, error)
func (*MockPackerClientService) PackerServiceUpdateBuild ¶ added in v1.7.7
func (svc *MockPackerClientService) PackerServiceUpdateBuild(params *packerSvc.PackerServiceUpdateBuildParams, _ runtime.ClientAuthInfoWriter) (*packerSvc.PackerServiceUpdateBuildOK, error)