Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow docker resources #243

Merged
merged 1 commit into from
Jun 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ snapshot:
params:
$schema: "http://json-schema.org/draft-03/schema#"
`,
expectedError: "schema key \"$schema\" not compatible with this version of juju",
expectedError: `schema key "\$schema" not compatible with this version of juju`,
}, {
description: "Reject JSON-Schema containing references.",
yaml: `
Expand All @@ -606,7 +606,7 @@ snapshot:
params:
outfile: { $ref: "http://json-schema.org/draft-03/schema#" }
`,
expectedError: "schema key \"$ref\" not compatible with this version of juju",
expectedError: `schema key "\$ref" not compatible with this version of juju`,
}, {
description: "Malformed YAML: missing key in \"outfile\".",
yaml: `
Expand All @@ -619,7 +619,7 @@ snapshot:
default: foo.bz2
`,

expectedError: "yaml: line 6: mapping values are not allowed in this context",
expectedError: `yaml: line [0-9]: mapping values are not allowed in this context`,
}, {
description: "Malformed JSON-Schema: $schema element misplaced.",
yaml: `
Expand All @@ -633,31 +633,31 @@ description: Take a snapshot of the database.
default: foo.bz2
`,

expectedError: "yaml: line 3: mapping values are not allowed in this context",
expectedError: `yaml: line [0-9]: mapping values are not allowed in this context`,
}, {
description: "Malformed Actions: hyphen at beginning of action name.",
yaml: `
-snapshot:
description: Take a snapshot of the database.
`,

expectedError: "bad action name -snapshot",
expectedError: `bad action name -snapshot`,
}, {
description: "Malformed Actions: hyphen after action name.",
yaml: `
snapshot-:
description: Take a snapshot of the database.
`,

expectedError: "bad action name snapshot-",
expectedError: `bad action name snapshot-`,
}, {
description: "Malformed Actions: caps in action name.",
yaml: `
Snapshot:
description: Take a snapshot of the database.
`,

expectedError: "bad action name Snapshot",
expectedError: `bad action name Snapshot`,
}, {
description: `Reserved Action Name: "juju".`,
yaml: `
Expand All @@ -678,7 +678,7 @@ juju-run:
snapshot:
description: ["Take a snapshot of the database."]
`,
expectedError: "value for schema key \"description\" must be a string",
expectedError: `value for schema key "description" must be a string`,
}, {
description: "A non-list \"required\" key",
yaml: `
Expand All @@ -690,23 +690,23 @@ snapshot:
type: string
required: "outfile"
`,
expectedError: "value for schema key \"required\" must be a YAML list",
expectedError: `value for schema key "required" must be a YAML list`,
}, {
description: "A schema with an empty \"params\" key fails to parse",
yaml: `
snapshot:
description: Take a snapshot of the database.
params:
`,
expectedError: "params failed to parse as a map",
expectedError: `params failed to parse as a map`,
}, {
description: "A schema with a non-map \"params\" value fails to parse",
yaml: `
snapshot:
description: Take a snapshot of the database.
params: ["a", "b"]
`,
expectedError: "params failed to parse as a map",
expectedError: `params failed to parse as a map`,
}, {
description: "\"definitions\" goes against JSON-Schema definition",
yaml: `
Expand All @@ -720,7 +720,7 @@ snapshot:
diskdevice: ["a"]
something-else: {"a": "b"}
`,
expectedError: "invalid params schema for action schema snapshot: definitions must be of type array of schemas",
expectedError: `invalid params schema for action schema snapshot: definitions must be of type array of schemas`,
}, {
description: "excess keys not in the JSON-Schema spec will be rejected",
yaml: `
Expand All @@ -741,15 +741,14 @@ snapshot:
something-else: {}
other-key: ["some", "values"],
`,
expectedError: "yaml: line 16: did not find expected key",
expectedError: `yaml: line [0-9]+: did not find expected key`,
}}

for i, test := range badActionsYamlTests {
c.Logf("test %d: %s", i, test.description)
reader := bytes.NewReader([]byte(test.yaml))
_, err := ReadActionsYaml(reader)
c.Assert(err, gc.NotNil)
c.Check(err.Error(), gc.Equals, test.expectedError)
c.Check(err, gc.ErrorMatches, test.expectedError)
}
}

Expand Down
2 changes: 1 addition & 1 deletion config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func (s *ConfigSuite) TestDefaultType(c *gc.C) {
assertDefault("boolean", "true", true)
assertDefault("string", "golden grahams", "golden grahams")
assertDefault("string", `""`, "")
assertDefault("float", "2.2e11", 2.2e11)
assertDefault("float", "2.211", 2.211)
assertDefault("int", "99", int64(99))

assertTypeError := func(type_, str, value string) {
Expand Down
12 changes: 10 additions & 2 deletions meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1227,21 +1227,29 @@ resources:
other-resource:
type: file
filename: other.zip
image-resource:
type: docker
description: "An image"
`))
c.Assert(err, gc.IsNil)

c.Check(meta.Resources, jc.DeepEquals, map[string]resource.Meta{
"resource-name": resource.Meta{
"resource-name": {
Name: "resource-name",
Type: resource.TypeFile,
Path: "filename.tgz",
Description: "One line that is useful when operators need to push it.",
},
"other-resource": resource.Meta{
"other-resource": {
Name: "other-resource",
Type: resource.TypeFile,
Path: "other.zip",
},
"image-resource": {
Name: "image-resource",
Type: resource.TypeDocker,
Description: "An image",
},
})
}

Expand Down
1 change: 1 addition & 0 deletions resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var resourceSchema = schema.FieldMap(
},
schema.Defaults{
"type": resource.TypeFile.String(),
"filename": "",
"description": "",
},
)
Expand Down
10 changes: 0 additions & 10 deletions resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,6 @@ func (s *resourceSuite) TestSchemaUnknownType(c *gc.C) {
})
}

func (s *resourceSuite) TestSchemaMissingPath(c *gc.C) {
raw := map[interface{}]interface{}{
"type": "file",
"description": "One line that is useful when operators need to push it.",
}
_, err := charm.ResourceSchema.Coerce(raw, nil)

c.Check(err, gc.NotNil)
}

func (s *resourceSuite) TestSchemaMissingComment(c *gc.C) {
raw := map[interface{}]interface{}{
"type": "file",
Expand Down