package release import ( "context" "errors" ) // The signed-pointer and ship entry points below run as one app mutation: // on an enabled console store the whole read, authorize and conditional // write sequence shares one admitted operation, and a nested call (a ladder // promote that cuts a tag, a pending execution that promotes) reuses the // permitted context it was handed. The ordinary bucket implementations do // not implement AppMutationRunner, so with host claims off each call runs // its original body unchanged. // Ship is claimRawShip under the app mutation of the manifest's app. func Ship(ctx context.Context, s Store, acct string, m Manifest, files map[string][]byte) error { return WithAppMutation(ctx, s, acct, m.App, "release.Ship", func(ctx context.Context) error { return claimRawShip(ctx, s, acct, m, files) }) } // ShipSpooled is claimRawShipSpooled under the app mutation of the // manifest's app: Ship for artifacts on disk (paths maps each artifact key to // a local file), each streamed into the bucket rather than held in memory. func ShipSpooled(ctx context.Context, s Store, acct string, m Manifest, paths map[string]string) error { return WithAppMutation(ctx, s, acct, m.App, "release.ShipSpooled", func(ctx context.Context) error { return claimRawShipSpooled(ctx, s, acct, m, paths) }) } func (sg Signer) promote(ctx context.Context, s Store, acct, app, channel, version string, authorize func(*Pipeline) error, expectVersion string, rec ...Promotion) error { return WithAppMutation(ctx, s, acct, app, "release.Promote", func(ctx context.Context) error { return sg.claimRawPromote(ctx, s, acct, app, channel, version, authorize, expectVersion, rec...) }) } // PromoteOnLadder is claimRawPromoteOnLadder under one app mutation, so the // pointer write and the stable tag it may cut are a single admitted effect. func (sg Signer) PromoteOnLadder(ctx context.Context, s Store, acct, app, channel, version string, opt PromoteOptions) (PromoteResult, error) { var res PromoteResult err := WithAppMutation(ctx, s, acct, app, "release.PromoteOnLadder", func(ctx context.Context) error { var err error res, err = sg.claimRawPromoteOnLadder(ctx, s, acct, app, channel, version, opt) return err }) return res, err } // RollbackAuthorized is claimRawRollbackAuthorized under one app mutation. func (sg Signer) RollbackAuthorized(ctx context.Context, s Store, acct, app, channel string, authorize func(*Pipeline) error) error { return WithAppMutation(ctx, s, acct, app, "release.Rollback", func(ctx context.Context) error { return sg.claimRawRollbackAuthorized(ctx, s, acct, app, channel, authorize) }) } // Resign is ResignAuthorized with no authority hook. func (sg Signer) Resign(ctx context.Context, s Store, plan *ResignPlan, actor string) error { return sg.ResignAuthorized(ctx, s, plan, actor, nil) } // ResignAuthorized is claimRawResign under one app mutation, with authorize // (nil = no hook) asked of the pipeline inside it, as RollbackAuthorized does. func (sg Signer) ResignAuthorized(ctx context.Context, s Store, plan *ResignPlan, actor string, authorize func(*Pipeline) error) error { if plan == nil { return errors.New("resign: no plan to sign") } return WithAppMutation(ctx, s, plan.Account, plan.App, "release.Resign", func(ctx context.Context) error { return sg.claimRawResign(ctx, s, plan, actor, authorize) }) } // Authorize is claimRawAuthorize under one app mutation. func (sg Signer) Authorize(ctx context.Context, s Store, plan *AuthorizePlan, actor string) (already bool, err error) { if plan == nil { return false, errors.New("authorize: no plan to sign") } err = WithAppMutation(ctx, s, plan.Account, plan.App, "release.Authorize", func(ctx context.Context) error { var err error already, err = sg.claimRawAuthorize(ctx, s, plan, actor) return err }) return already, err }