Skip to content

Commit c992a16

Browse files
vdicejeremyrickard
authored andcommitted
ref(bundle/*): replace mapstructure tags with yaml tags (#95)
1 parent 2a69a0f commit c992a16

File tree

5 files changed

+90
-90
lines changed

5 files changed

+90
-90
lines changed

bundle/bundle.go

+36-36
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@ import (
1616

1717
// Bundle is a CNAB metadata document
1818
type Bundle struct {
19-
SchemaVersion string `json:"schemaVersion" mapstructure:"schemaVersion"`
20-
Name string `json:"name" mapstructure:"name"`
21-
Version string `json:"version" mapstructure:"version"`
22-
Description string `json:"description" mapstructure:"description"`
23-
Keywords []string `json:"keywords,omitempty" mapstructure:"keywords"`
24-
Maintainers []Maintainer `json:"maintainers,omitempty" mapstructure:"maintainers"`
25-
InvocationImages []InvocationImage `json:"invocationImages" mapstructure:"invocationImages"`
26-
Images map[string]Image `json:"images,omitempty" mapstructure:"images"`
27-
Actions map[string]Action `json:"actions,omitempty" mapstructure:"actions"`
28-
Parameters map[string]Parameter `json:"parameters,omitempty" mapstructure:"parameters"`
29-
Credentials map[string]Credential `json:"credentials,omitempty" mapstructure:"credentials"`
30-
Outputs map[string]Output `json:"outputs,omitempty" mapstructure:"outputs"`
31-
Definitions definition.Definitions `json:"definitions,omitempty" mapstructure:"definitions"`
32-
License string `json:"license,omitempty" mapstructure:"license"`
33-
RequiredExtensions []string `json:"requiredExtensions,omitempty" mapstructure:"requiredExtensions"`
19+
SchemaVersion string `json:"schemaVersion" yaml:"schemaVersion"`
20+
Name string `json:"name" yaml:"name"`
21+
Version string `json:"version" yaml:"version"`
22+
Description string `json:"description" yaml:"description"`
23+
Keywords []string `json:"keywords,omitempty" yaml:"keywords,omitempty"`
24+
Maintainers []Maintainer `json:"maintainers,omitempty" yaml:"maintainers,omitempty"`
25+
InvocationImages []InvocationImage `json:"invocationImages" yaml:"invocationImages"`
26+
Images map[string]Image `json:"images,omitempty" yaml:"images,omitempty"`
27+
Actions map[string]Action `json:"actions,omitempty" yaml:"actions,omitempty"`
28+
Parameters map[string]Parameter `json:"parameters,omitempty" yaml:"parameters,omitempty"`
29+
Credentials map[string]Credential `json:"credentials,omitempty" yaml:"credentials,omitempty"`
30+
Outputs map[string]Output `json:"outputs,omitempty" yaml:"outputs,omitempty"`
31+
Definitions definition.Definitions `json:"definitions,omitempty" yaml:"definitions,omitempty"`
32+
License string `json:"license,omitempty" yaml:"license,omitempty"`
33+
RequiredExtensions []string `json:"requiredExtensions,omitempty" yaml:"requiredExtensions,omitempty"`
3434

3535
// Custom extension metadata is a named collection of auxiliary data whose
3636
// meaning is defined outside of the CNAB specification.
37-
Custom map[string]interface{} `json:"custom,omitempty" mapstructure:"custom"`
37+
Custom map[string]interface{} `json:"custom,omitempty" yaml:"custom,omitempty"`
3838
}
3939

4040
//Unmarshal unmarshals a Bundle that was not signed.
@@ -72,30 +72,30 @@ func (b Bundle) WriteTo(w io.Writer) (int64, error) {
7272

7373
// LocationRef specifies a location within the invocation package
7474
type LocationRef struct {
75-
Path string `json:"path" mapstructure:"path"`
76-
Field string `json:"field" mapstructure:"field"`
77-
MediaType string `json:"mediaType" mapstructure:"mediaType"`
75+
Path string `json:"path" yaml:"path"`
76+
Field string `json:"field" yaml:"field"`
77+
MediaType string `json:"mediaType" yaml:"mediaType"`
7878
}
7979

8080
// BaseImage contains fields shared across image types
8181
type BaseImage struct {
82-
ImageType string `json:"imageType" mapstructure:"imageType"`
83-
Image string `json:"image" mapstructure:"image"`
84-
Digest string `json:"contentDigest,omitempty" mapstructure:"contentDigest"`
85-
Size uint64 `json:"size,omitempty" mapstructure:"size"`
86-
Labels map[string]string `json:"labels,omitempty" mapstructure:"labels"`
87-
MediaType string `json:"mediaType,omitempty" mapstructure:"mediaType"`
82+
ImageType string `json:"imageType" yaml:"imageType"`
83+
Image string `json:"image" yaml:"image"`
84+
Digest string `json:"contentDigest,omitempty" yaml:"contentDigest"`
85+
Size uint64 `json:"size,omitempty" yaml:"size,omitempty"`
86+
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
87+
MediaType string `json:"mediaType,omitempty" yaml:"mediaType,omitempty"`
8888
}
8989

9090
// Image describes a container image in the bundle
9191
type Image struct {
92-
BaseImage `mapstructure:",squash"`
93-
Description string `json:"description" mapstructure:"description"` //TODO: change? see where it's being used? change to description?
92+
BaseImage `yaml:",inline"`
93+
Description string `json:"description" yaml:"description"` //TODO: change? see where it's being used? change to description?
9494
}
9595

9696
// InvocationImage contains the image type and location for the installation of a bundle
9797
type InvocationImage struct {
98-
BaseImage `mapstructure:",squash"`
98+
BaseImage `yaml:",inline"`
9999
}
100100

101101
// ImageRelocationMap stores the relocated images
@@ -108,30 +108,30 @@ type ImageRelocationMap map[string]string
108108
//
109109
// A location may be either a file (by path) or an environment variable.
110110
type Location struct {
111-
Path string `json:"path,omitempty" mapstructure:"path"`
112-
EnvironmentVariable string `json:"env,omitempty" mapstructure:"env"`
111+
Path string `json:"path,omitempty" yaml:"path,omitempty"`
112+
EnvironmentVariable string `json:"env,omitempty" yaml:"env,omitempty"`
113113
}
114114

115115
// Maintainer describes a code maintainer of a bundle
116116
type Maintainer struct {
117117
// Name is a user name or organization name
118-
Name string `json:"name" mapstructure:"name"`
118+
Name string `json:"name" yaml:"name"`
119119
// Email is an optional email address to contact the named maintainer
120-
Email string `json:"email,omitempty" mapstructure:"email"`
120+
Email string `json:"email,omitempty" yaml:"email,omitempty"`
121121
// Url is an optional URL to an address for the named maintainer
122-
URL string `json:"url,omitempty" mapstructure:"url"`
122+
URL string `json:"url,omitempty" yaml:"url,omitempty"`
123123
}
124124

125125
// Action describes a custom (non-core) action.
126126
type Action struct {
127127
// Modifies indicates whether this action modifies the release.
128128
//
129129
// If it is possible that an action modify a release, this must be set to true.
130-
Modifies bool `json:"modifies,omitempty" mapstructure:"modifies"`
130+
Modifies bool `json:"modifies,omitempty" yaml:"modifies,omitempty"`
131131
// Stateless indicates that the action is purely informational, that credentials are not required, and that the runtime should not keep track of its invocation
132-
Stateless bool `json:"stateless,omitempty" mapstructure:"stateless"`
132+
Stateless bool `json:"stateless,omitempty" yaml:"stateless,omitempty"`
133133
// Description describes the action as a user-readable string
134-
Description string `json:"description,omitempty" mapstructure:"description"`
134+
Description string `json:"description,omitempty" yaml:"description,omitempty"`
135135
}
136136

137137
// ValuesOrDefaults returns parameter values or the default parameter values. An error is returned when the parameter value does not pass

bundle/credentials.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package bundle
22

33
// Credential represents the definition of a CNAB credential
44
type Credential struct {
5-
Location `mapstructure:",squash"`
6-
Description string `json:"description,omitempty" mapstructure:"description"`
7-
Required bool `json:"required,omitempty" mapstructure:"required"`
5+
Location `yaml:",inline"`
6+
Description string `json:"description,omitempty" yaml:"description,omitempty"`
7+
Required bool `json:"required,omitempty" yaml:"required,omitempty"`
88
}

bundle/definition/schema.go

+42-42
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,51 @@ type Definitions map[string]*Schema
1313

1414
// Schema represents a JSON Schema compatible CNAB Definition
1515
type Schema struct {
16-
Schema string `json:"$schema,omitempty" yaml:"$schema,omitempty" mapstructure:"$schema,omitempty"`
17-
Comment string `json:"$comment,omitempty" yaml:"$comment,omitempty" mapstructure:"$comment,omitempty"`
18-
ID string `json:"$id,omitempty" yaml:"$id,omitempty" mapstructure:"$id,omitempty"`
19-
Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty" mapstructure:"$ref,omitempty"`
20-
AdditionalItems interface{} `json:"additionalItems,omitempty" yaml:"additionalItems,omitempty" mapstructure:"additionalItems,omitempty"`
21-
AdditionalProperties interface{} `json:"additionalProperties,omitempty" yaml:"additionalProperties,omitempty" mapstructure:"additionalProperties,omitempty"`
22-
AllOf []*Schema `json:"allOf,omitempty" yaml:"allOf,omitempty" mapstructure:"allOf,omitempty"`
23-
Const interface{} `json:"const,omitempty" yaml:"const,omitempty" mapstructure:"const,omitempty"`
24-
Contains *Schema `json:"contains,omitempty" yaml:"contains,omitempty" mapstructure:"contains,omitempty"`
25-
ContentEncoding string `json:"contentEncoding,omitempty" yaml:"contentEncoding,omitempty" mapstructure:"contentEncoding,omitempty"`
26-
ContentMediaType string `json:"contentMediaType,omitempty" yaml:"contentMediaType,omitempty" mapstructure:"contentMediaType,omitempty"`
27-
Default interface{} `json:"default,omitempty" yaml:"default,omitempty" mapstructure:"default,omitempty"`
28-
Definitions Definitions `json:"definitions,omitempty" yaml:"definitions,omitempty" mapstructure:"definitions,omitempty"`
29-
Dependencies map[string]interface{} `json:"dependencies,omitempty" yaml:"dependencies,omitempty" mapstructure:"dependencies,omitempty"`
30-
Description string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`
31-
Else *Schema `json:"else,omitempty" yaml:"else,omitempty" mapstructure:"else,omitempty"`
32-
Enum []interface{} `json:"enum,omitempty" yaml:"enum,omitempty" mapstructure:"enum,omitempty"`
33-
Examples []interface{} `json:"examples,omitempty" yaml:"examples,omitempty" mapstructure:"examples,omitempty"`
34-
ExclusiveMaximum *float64 `json:"exclusiveMaximum,omitempty" yaml:"exclusiveMaximum,omitempty" mapstructure:"exclusiveMaximum,omitempty"`
35-
ExclusiveMinimum *float64 `json:"exclusiveMinimum,omitempty" yaml:"exclusiveMinimum,omitempty" mapstructure:"exclusiveMinimum,omitempty"`
36-
Format string `json:"format,omitempty" yaml:"format,omitempty" mapstructure:"format,omitempty"`
37-
If *Schema `json:"if,omitempty" yaml:"if,omitempty" mapstructure:"if,omitempty"`
16+
Schema string `json:"$schema,omitempty" yaml:"$schema,omitempty"`
17+
Comment string `json:"$comment,omitempty" yaml:"$comment,omitempty"`
18+
ID string `json:"$id,omitempty" yaml:"$id,omitempty"`
19+
Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
20+
AdditionalItems interface{} `json:"additionalItems,omitempty" yaml:"additionalItems,omitempty"`
21+
AdditionalProperties interface{} `json:"additionalProperties,omitempty" yaml:"additionalProperties,omitempty"`
22+
AllOf []*Schema `json:"allOf,omitempty" yaml:"allOf,omitempty"`
23+
Const interface{} `json:"const,omitempty" yaml:"const,omitempty"`
24+
Contains *Schema `json:"contains,omitempty" yaml:"contains,omitempty"`
25+
ContentEncoding string `json:"contentEncoding,omitempty" yaml:"contentEncoding,omitempty"`
26+
ContentMediaType string `json:"contentMediaType,omitempty" yaml:"contentMediaType,omitempty"`
27+
Default interface{} `json:"default,omitempty" yaml:"default,omitempty"`
28+
Definitions Definitions `json:"definitions,omitempty" yaml:"definitions,omitempty"`
29+
Dependencies map[string]interface{} `json:"dependencies,omitempty" yaml:"dependencies,omitempty"`
30+
Description string `json:"description,omitempty" yaml:"description,omitempty"`
31+
Else *Schema `json:"else,omitempty" yaml:"else,omitempty"`
32+
Enum []interface{} `json:"enum,omitempty" yaml:"enum,omitempty"`
33+
Examples []interface{} `json:"examples,omitempty" yaml:"examples,omitempty"`
34+
ExclusiveMaximum *float64 `json:"exclusiveMaximum,omitempty" yaml:"exclusiveMaximum,omitempty"`
35+
ExclusiveMinimum *float64 `json:"exclusiveMinimum,omitempty" yaml:"exclusiveMinimum,omitempty"`
36+
Format string `json:"format,omitempty" yaml:"format,omitempty"`
37+
If *Schema `json:"if,omitempty" yaml:"if,omitempty"`
3838
//Items can be a Schema or an Array of Schema :(
39-
Items interface{} `json:"items,omitempty" yaml:"items,omitempty" mapstructure:"items,omitempty"`
40-
Maximum *float64 `json:"maximum,omitempty" yaml:"maximum,omitempty" mapstructure:"maximum,omitempty"`
41-
MaxLength *float64 `json:"maxLength,omitempty" yaml:"maxLength,omitempty" mapstructure:"maxLength,omitempty"`
42-
MinItems *float64 `json:"minItems,omitempty" yaml:"minItems,omitempty" mapstructure:"minItems,omitempty"`
43-
MinLength *float64 `json:"minLength,omitempty" yaml:"minLength,omitempty" mapstructure:"minLength,omitempty"`
44-
MinProperties *float64 `json:"minProperties,omitempty" yaml:"minProperties,omitempty" mapstructure:"minProperties,omitempty"`
45-
Minimum *float64 `json:"minimum,omitempty" yaml:"minimum,omitempty" mapstructure:"minimum,omitempty"`
46-
MultipleOf *float64 `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty" mapstructure:"multipleOf,omitempty"`
47-
Not *Schema `json:"not,omitempty" yaml:"not,omitempty" mapstructure:"not,omitempty"`
48-
OneOf *Schema `json:"oneOf,omitempty" yaml:"oneOf,omitempty" mapstructure:"oneOf,omitempty"`
39+
Items interface{} `json:"items,omitempty" yaml:"items,omitempty"`
40+
Maximum *float64 `json:"maximum,omitempty" yaml:"maximum,omitempty"`
41+
MaxLength *float64 `json:"maxLength,omitempty" yaml:"maxLength,omitempty"`
42+
MinItems *float64 `json:"minItems,omitempty" yaml:"minItems,omitempty"`
43+
MinLength *float64 `json:"minLength,omitempty" yaml:"minLength,omitempty"`
44+
MinProperties *float64 `json:"minProperties,omitempty" yaml:"minProperties,omitempty"`
45+
Minimum *float64 `json:"minimum,omitempty" yaml:"minimum,omitempty"`
46+
MultipleOf *float64 `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty"`
47+
Not *Schema `json:"not,omitempty" yaml:"not,omitempty"`
48+
OneOf *Schema `json:"oneOf,omitempty" yaml:"oneOf,omitempty"`
4949

50-
PatternProperties map[string]*Schema `json:"patternProperties,omitempty" yaml:"patternProperties,omitempty" mapstructure:"patternProperties,omitempty"`
50+
PatternProperties map[string]*Schema `json:"patternProperties,omitempty" yaml:"patternProperties,omitempty"`
5151

52-
Properties map[string]*Schema `json:"properties,omitempty" yaml:"properties,omitempty" mapstructure:"properties,omitempty"`
53-
PropertyNames *Schema `json:"propertyNames,omitempty" yaml:"propertyNames,omitempty" mapstructure:"propertyNames,omitempty"`
54-
ReadOnly *bool `json:"readOnly,omitempty" yaml:"readOnly,omitempty" mapstructure:"readOnly,omitempty"`
55-
Required []string `json:"required,omitempty" yaml:"required,omitempty" mapstructure:"required,omitempty"`
56-
Then *Schema `json:"then,omitempty" yaml:"then,omitempty" mapstructure:"then,omitempty"`
57-
Title string `json:"title,omitempty" yaml:"title,omitempty" mapstructure:"title,omitempty"`
58-
Type interface{} `json:"type,omitempty" yaml:"type,omitempty" mapstructure:"type,omitempty"`
59-
UniqueItems *bool `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty" mapstructure:"uniqueItems,omitempty"`
60-
WriteOnly *bool `json:"writeOnly,omitempty" yaml:"writeOnly,omitempty" mapstructure:"writeOnly,omitempty"`
52+
Properties map[string]*Schema `json:"properties,omitempty" yaml:"properties,omitempty"`
53+
PropertyNames *Schema `json:"propertyNames,omitempty" yaml:"propertyNames,omitempty"`
54+
ReadOnly *bool `json:"readOnly,omitempty" yaml:"readOnly,omitempty"`
55+
Required []string `json:"required,omitempty" yaml:"required,omitempty"`
56+
Then *Schema `json:"then,omitempty" yaml:"then,omitempty"`
57+
Title string `json:"title,omitempty" yaml:"title,omitempty"`
58+
Type interface{} `json:"type,omitempty" yaml:"type,omitempty"`
59+
UniqueItems *bool `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"`
60+
WriteOnly *bool `json:"writeOnly,omitempty" yaml:"writeOnly,omitempty"`
6161
}
6262

6363
// GetType will return the singular type for a given schema and a success boolean. If the

bundle/outputs.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package bundle
22

33
type Output struct {
4-
Definition string `json:"definition" mapstructure:"definition"`
5-
ApplyTo []string `json:"applyTo,omitempty" mapstructure:"applyTo,omitempty"`
6-
Description string `json:"description,omitempty" mapstructure:"description"`
7-
Path string `json:"path" mapstructure:"path"`
4+
Definition string `json:"definition" yaml:"definition"`
5+
ApplyTo []string `json:"applyTo,omitempty" yaml:"applyTo,omitempty"`
6+
Description string `json:"description,omitempty" yaml:"description,omitempty"`
7+
Path string `json:"path" yaml:"path"`
88
}

bundle/parameters.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package bundle
22

33
// Parameter defines a single parameter for a CNAB bundle
44
type Parameter struct {
5-
Definition string `json:"definition" mapstructure:"definition"`
6-
ApplyTo []string `json:"applyTo,omitempty" mapstructure:"applyTo,omitempty"`
7-
Description string `json:"description,omitempty" mapstructure:"description"`
8-
Destination *Location `json:"destination,omitemtpty" mapstructure:"destination"`
9-
Required bool `json:"required,omitempty" mapstructure:"required,omitempty"`
5+
Definition string `json:"definition" yaml:"definition"`
6+
ApplyTo []string `json:"applyTo,omitempty" yaml:"applyTo,omitempty"`
7+
Description string `json:"description,omitempty" yaml:"description,omitempty"`
8+
Destination *Location `json:"destination,omitemtpty" yaml:"destination,omitempty"`
9+
Required bool `json:"required,omitempty" yaml:"required,omitempty"`
1010
}

0 commit comments

Comments
 (0)