|
|
|
|
@ -13,12 +13,12 @@ import (
|
|
|
|
|
// CreateBucket creates a bucket on a HCP Packer Registry.
|
|
|
|
|
func CreateBucket(ctx context.Context, client *Client, input *models.HashicorpCloudPackerCreateBucketRequest) (string, error) {
|
|
|
|
|
|
|
|
|
|
params := packerSvc.NewCreateBucketParamsWithContext(ctx)
|
|
|
|
|
params := packerSvc.NewPackerServiceCreateBucketParamsWithContext(ctx)
|
|
|
|
|
params.LocationOrganizationID = client.OrganizationID
|
|
|
|
|
params.LocationProjectID = client.ProjectID
|
|
|
|
|
params.Body = input
|
|
|
|
|
|
|
|
|
|
resp, err := client.Packer.CreateBucket(params, nil)
|
|
|
|
|
resp, err := client.Packer.PackerServiceCreateBucket(params, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
@ -40,7 +40,7 @@ func UpsertBucket(ctx context.Context, client *Client, input *models.HashicorpCl
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
params := packerSvc.NewUpdateBucketParamsWithContext(ctx)
|
|
|
|
|
params := packerSvc.NewPackerServiceUpdateBucketParamsWithContext(ctx)
|
|
|
|
|
params.LocationOrganizationID = client.OrganizationID
|
|
|
|
|
params.LocationProjectID = client.ProjectID
|
|
|
|
|
params.BucketSlug = input.BucketSlug
|
|
|
|
|
@ -48,20 +48,20 @@ func UpsertBucket(ctx context.Context, client *Client, input *models.HashicorpCl
|
|
|
|
|
Description: input.Description,
|
|
|
|
|
Labels: input.Labels,
|
|
|
|
|
}
|
|
|
|
|
_, err = client.Packer.UpdateBucket(params, nil)
|
|
|
|
|
_, err = client.Packer.PackerServiceUpdateBucket(params, nil)
|
|
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateIteration creates an Iteration for some Bucket on a HCP Packer Registry.
|
|
|
|
|
func CreateIteration(ctx context.Context, client *Client, input *models.HashicorpCloudPackerCreateIterationRequest) (*models.HashicorpCloudPackerIteration, error) {
|
|
|
|
|
params := packerSvc.NewCreateIterationParamsWithContext(ctx)
|
|
|
|
|
params := packerSvc.NewPackerServiceCreateIterationParamsWithContext(ctx)
|
|
|
|
|
params.LocationOrganizationID = client.OrganizationID
|
|
|
|
|
params.LocationProjectID = client.ProjectID
|
|
|
|
|
params.BucketSlug = input.BucketSlug
|
|
|
|
|
params.Body = input
|
|
|
|
|
|
|
|
|
|
it, err := client.Packer.CreateIteration(params, nil)
|
|
|
|
|
it, err := client.Packer.PackerServiceCreateIteration(params, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
@ -71,7 +71,7 @@ func CreateIteration(ctx context.Context, client *Client, input *models.Hashicor
|
|
|
|
|
|
|
|
|
|
// GetIteration queries the HCP Packer registry for an existing bucket iteration.
|
|
|
|
|
func GetIteration(ctx context.Context, client *Client, bucketslug string, fingerprint string) (*models.HashicorpCloudPackerIteration, error) {
|
|
|
|
|
params := packerSvc.NewGetIterationParamsWithContext(ctx)
|
|
|
|
|
params := packerSvc.NewPackerServiceGetIterationParamsWithContext(ctx)
|
|
|
|
|
params.LocationOrganizationID = client.OrganizationID
|
|
|
|
|
params.LocationProjectID = client.ProjectID
|
|
|
|
|
params.BucketSlug = bucketslug
|
|
|
|
|
@ -80,7 +80,7 @@ func GetIteration(ctx context.Context, client *Client, bucketslug string, finger
|
|
|
|
|
// for now, we only care about fingerprint so we're hardcoding it.
|
|
|
|
|
params.Fingerprint = &fingerprint
|
|
|
|
|
|
|
|
|
|
it, err := client.Packer.GetIteration(params, nil)
|
|
|
|
|
it, err := client.Packer.PackerServiceGetIteration(params, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
@ -90,14 +90,14 @@ func GetIteration(ctx context.Context, client *Client, bucketslug string, finger
|
|
|
|
|
|
|
|
|
|
// CreateBuild create a build entry to track for the IterationID and BucketSlug defined within input.
|
|
|
|
|
func CreateBuild(ctx context.Context, client *Client, input *models.HashicorpCloudPackerCreateBuildRequest) (string, error) {
|
|
|
|
|
params := packerSvc.NewCreateBuildParamsWithContext(ctx)
|
|
|
|
|
params := packerSvc.NewPackerServiceCreateBuildParamsWithContext(ctx)
|
|
|
|
|
params.LocationOrganizationID = client.OrganizationID
|
|
|
|
|
params.LocationProjectID = client.ProjectID
|
|
|
|
|
params.IterationID = input.IterationID
|
|
|
|
|
params.BucketSlug = input.BucketSlug
|
|
|
|
|
params.BuildIterationID = input.Build.IterationID
|
|
|
|
|
params.Body = input
|
|
|
|
|
|
|
|
|
|
resp, err := client.Packer.CreateBuild(params, nil)
|
|
|
|
|
resp, err := client.Packer.PackerServiceCreateBuild(params, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
@ -108,13 +108,13 @@ func CreateBuild(ctx context.Context, client *Client, input *models.HashicorpClo
|
|
|
|
|
// ListBuilds queries an Iteration on HCP Packer registry for all of it's associated builds.
|
|
|
|
|
// Currently all builds are returned regardless of status.
|
|
|
|
|
func ListBuilds(ctx context.Context, client *Client, bucketSlug string, iterationID string) ([]*models.HashicorpCloudPackerBuild, error) {
|
|
|
|
|
params := packerSvc.NewListBuildsParamsWithContext(ctx)
|
|
|
|
|
params := packerSvc.NewPackerServiceListBuildsParamsWithContext(ctx)
|
|
|
|
|
params.LocationOrganizationID = client.OrganizationID
|
|
|
|
|
params.LocationProjectID = client.ProjectID
|
|
|
|
|
params.BucketSlug = bucketSlug
|
|
|
|
|
params.IterationID = iterationID
|
|
|
|
|
|
|
|
|
|
resp, err := client.Packer.ListBuilds(params, nil)
|
|
|
|
|
resp, err := client.Packer.PackerServiceListBuilds(params, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return []*models.HashicorpCloudPackerBuild{}, err
|
|
|
|
|
}
|
|
|
|
|
@ -124,13 +124,13 @@ func ListBuilds(ctx context.Context, client *Client, bucketSlug string, iteratio
|
|
|
|
|
|
|
|
|
|
// UpdateBuild updates a single iteration build entry with the incoming input data.
|
|
|
|
|
func UpdateBuild(ctx context.Context, client *Client, input *models.HashicorpCloudPackerUpdateBuildRequest) (string, error) {
|
|
|
|
|
params := packerSvc.NewUpdateBuildParamsWithContext(ctx)
|
|
|
|
|
params := packerSvc.NewPackerServiceUpdateBuildParamsWithContext(ctx)
|
|
|
|
|
params.BuildID = input.BuildID
|
|
|
|
|
params.LocationOrganizationID = client.OrganizationID
|
|
|
|
|
params.LocationProjectID = client.ProjectID
|
|
|
|
|
params.Body = input
|
|
|
|
|
|
|
|
|
|
resp, err := client.Packer.UpdateBuild(params, nil)
|
|
|
|
|
resp, err := client.Packer.PackerServiceUpdateBuild(params, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
@ -145,13 +145,13 @@ func UpdateBuild(ctx context.Context, client *Client, input *models.HashicorpClo
|
|
|
|
|
// GetChannel loads the iterationId associated with a current channel. If
|
|
|
|
|
// the channel does not exist in HCP Packer, GetChannel returns an error.
|
|
|
|
|
func GetIterationFromChannel(ctx context.Context, client *Client, bucketSlug string, channelName string) (*models.HashicorpCloudPackerIteration, error) {
|
|
|
|
|
params := packerSvc.NewGetChannelParamsWithContext(ctx)
|
|
|
|
|
params := packerSvc.NewPackerServiceGetChannelParamsWithContext(ctx)
|
|
|
|
|
params.LocationOrganizationID = client.OrganizationID
|
|
|
|
|
params.LocationProjectID = client.ProjectID
|
|
|
|
|
params.BucketSlug = bucketSlug
|
|
|
|
|
params.Slug = channelName
|
|
|
|
|
|
|
|
|
|
resp, err := client.Packer.GetChannel(params, nil)
|
|
|
|
|
resp, err := client.Packer.PackerServiceGetChannel(params, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
@ -172,7 +172,7 @@ func GetIterationFromChannel(ctx context.Context, client *Client, bucketSlug str
|
|
|
|
|
|
|
|
|
|
// GetIteration queries the HCP Packer registry for an existing bucket iteration.
|
|
|
|
|
func GetIterationFromId(ctx context.Context, client *Client, bucketslug string, iterationId string) (*models.HashicorpCloudPackerIteration, error) {
|
|
|
|
|
params := packerSvc.NewGetIterationParamsWithContext(ctx)
|
|
|
|
|
params := packerSvc.NewPackerServiceGetIterationParamsWithContext(ctx)
|
|
|
|
|
params.LocationOrganizationID = client.OrganizationID
|
|
|
|
|
params.LocationProjectID = client.ProjectID
|
|
|
|
|
params.BucketSlug = bucketslug
|
|
|
|
|
@ -181,7 +181,7 @@ func GetIterationFromId(ctx context.Context, client *Client, bucketslug string,
|
|
|
|
|
// for now, we only care about fingerprint so we're hardcoding it.
|
|
|
|
|
params.IterationID = &iterationId
|
|
|
|
|
|
|
|
|
|
it, err := client.Packer.GetIteration(params, nil)
|
|
|
|
|
it, err := client.Packer.PackerServiceGetIteration(params, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|