diff --git a/vendor/github.com/deislabs/cnab-go/action/action.go b/vendor/github.com/deislabs/cnab-go/action/action.go index 25da3f34..04b823e4 100644 --- a/vendor/github.com/deislabs/cnab-go/action/action.go +++ b/vendor/github.com/deislabs/cnab-go/action/action.go @@ -161,11 +161,6 @@ func selectInvocationImage(d driver.Driver, c *claim.Claim) (bundle.InvocationIm for _, ii := range c.Bundle.InvocationImages { if d.Handles(ii.ImageType) { - if c.RelocationMap != nil { - if img, ok := c.RelocationMap[ii.Image]; ok { - ii.Image = img - } - } return ii, nil } } diff --git a/vendor/github.com/deislabs/cnab-go/bundle/bundle.go b/vendor/github.com/deislabs/cnab-go/bundle/bundle.go index efcf7bbc..3c344992 100644 --- a/vendor/github.com/deislabs/cnab-go/bundle/bundle.go +++ b/vendor/github.com/deislabs/cnab-go/bundle/bundle.go @@ -98,11 +98,6 @@ type InvocationImage struct { BaseImage `yaml:",inline"` } -// ImageRelocationMap stores the relocated images -// The key is the Image in bundle.json and the value is the new Image -// from the relocated registry -type ImageRelocationMap map[string]string - // Location provides the location where a value should be written in // the invocation image. // diff --git a/vendor/github.com/deislabs/cnab-go/claim/claim.go b/vendor/github.com/deislabs/cnab-go/claim/claim.go index 57fc709d..1355c512 100644 --- a/vendor/github.com/deislabs/cnab-go/claim/claim.go +++ b/vendor/github.com/deislabs/cnab-go/claim/claim.go @@ -40,11 +40,11 @@ type Claim struct { Created time.Time `json:"created"` Modified time.Time `json:"modified"` Bundle *bundle.Bundle `json:"bundle"` - Result Result `json:"result"` - Parameters map[string]interface{} `json:"parameters"` + Result Result `json:"result,omitempty"` + Parameters map[string]interface{} `json:"parameters,omitempty"` // Outputs is a map from the names of outputs (defined in the bundle) to the contents of the files. - Outputs map[string]interface{} `json:"outputs"` - RelocationMap bundle.ImageRelocationMap `json:"relocationMap"` + Outputs map[string]interface{} `json:"outputs,omitempty"` + Custom interface{} `json:"custom,omitempty"` } // ValidName is a regular expression that indicates whether a name is a valid claim name. @@ -67,9 +67,8 @@ func New(name string) (*Claim, error) { Action: ActionUnknown, Status: StatusUnknown, }, - Parameters: map[string]interface{}{}, - Outputs: map[string]interface{}{}, - RelocationMap: bundle.ImageRelocationMap{}, + Parameters: map[string]interface{}{}, + Outputs: map[string]interface{}{}, }, nil } diff --git a/vendor/github.com/deislabs/cnab-go/credentials/credentialset.go b/vendor/github.com/deislabs/cnab-go/credentials/credentialset.go index e6ae6e0c..ed4db8bd 100644 --- a/vendor/github.com/deislabs/cnab-go/credentials/credentialset.go +++ b/vendor/github.com/deislabs/cnab-go/credentials/credentialset.go @@ -25,7 +25,7 @@ func (s Set) Expand(b *bundle.Bundle, stateless bool) (env, files map[string]str for name, val := range b.Credentials { src, ok := s[name] if !ok { - if stateless { + if stateless || !val.Required { continue } err = fmt.Errorf("credential %q is missing from the user-supplied credentials", name) @@ -77,15 +77,15 @@ func Load(path string) (*CredentialSet, error) { // Validate compares the given credentials with the spec. // -// This will result in an error only if: -// - a parameter in the spec is not present in the given set -// - a parameter in the given set does not match the format required by the spec +// This will result in an error only when the following conditions are true: +// - a credential in the spec is not present in the given set +// - the credential is required // // It is allowed for spec to specify both an env var and a file. In such case, if -// the givn set provides either, it will be considered valid. +// the given set provides either, it will be considered valid. func Validate(given Set, spec map[string]bundle.Credential) error { - for name := range spec { - if !isValidCred(given, name) { + for name, cred := range spec { + if !isValidCred(given, name) && cred.Required { return fmt.Errorf("bundle requires credential for %s", name) } } diff --git a/vendor/github.com/deislabs/cnab-go/driver/docker/docker.go b/vendor/github.com/deislabs/cnab-go/driver/docker/docker.go index 134d75ea..181c9851 100644 --- a/vendor/github.com/deislabs/cnab-go/driver/docker/docker.go +++ b/vendor/github.com/deislabs/cnab-go/driver/docker/docker.go @@ -227,21 +227,21 @@ func (d *Driver) exec(op *driver.Operation) (driver.OperationResult, error) { select { case err := <-errc: if err != nil { - opResult, fetchErr := d.fetchOutputs(ctx, resp.ID) + opResult, fetchErr := d.fetchOutputs(ctx, resp.ID, op) return opResult, containerError("error in container", err, fetchErr) } case s := <-statusc: if s.StatusCode == 0 { - return d.fetchOutputs(ctx, resp.ID) + return d.fetchOutputs(ctx, resp.ID, op) } if s.Error != nil { - opResult, fetchErr := d.fetchOutputs(ctx, resp.ID) + opResult, fetchErr := d.fetchOutputs(ctx, resp.ID, op) return opResult, containerError(fmt.Sprintf("container exit code: %d, message", s.StatusCode), err, fetchErr) } - opResult, fetchErr := d.fetchOutputs(ctx, resp.ID) + opResult, fetchErr := d.fetchOutputs(ctx, resp.ID, op) return opResult, containerError(fmt.Sprintf("container exit code: %d, message", s.StatusCode), err, fetchErr) } - opResult, fetchErr := d.fetchOutputs(ctx, resp.ID) + opResult, fetchErr := d.fetchOutputs(ctx, resp.ID, op) if fetchErr != nil { return opResult, fmt.Errorf("fetching outputs failed: %s", fetchErr) } @@ -259,10 +259,16 @@ func containerError(containerMessage string, containerErr, fetchErr error) error // fetchOutputs takes a context and a container ID; it copies the /cnab/app/outputs directory from that container. // The goal is to collect all the files in the directory (recursively) and put them in a flat map of path to contents. // This map will be inside the OperationResult. When fetchOutputs returns an error, it may also return partial results. -func (d *Driver) fetchOutputs(ctx context.Context, container string) (driver.OperationResult, error) { +func (d *Driver) fetchOutputs(ctx context.Context, container string, op *driver.Operation) (driver.OperationResult, error) { opResult := driver.OperationResult{ Outputs: map[string]string{}, } + // The /cnab/app/outputs directory probably only exists if outputs are created. In the + // case there are no outputs defined on the operation, there probably are none to copy + // and we should return early. + if len(op.Outputs) == 0 { + return opResult, nil + } ioReader, _, err := d.dockerCli.Client().CopyFromContainer(ctx, container, "/cnab/app/outputs") if err != nil { return opResult, fmt.Errorf("error copying outputs from container: %s", err)