Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
asserts: introduce model assertion #460
Conversation
pedronis
added some commits
Feb 6, 2016
atomatt
reviewed
Feb 8, 2016
| + listStr, ok := headers[name] | ||
| + if !ok { | ||
| + return nil, fmt.Errorf("%q header is mandatory", name) | ||
| + } |
atomatt
Feb 8, 2016
Contributor
It may not be worth it, but would it make sense to split checkMandatory into two, e.g. checkMandatory & checkEmpty, so that checkMandatory only has one responsibility and can be reused here?
pedronis
Feb 8, 2016
Contributor
@emgee well this is a checker itself, so reuse is not so interesting, also I don't think we want many fields that must be there but can be empty, lists are a bit of a special case, maybe we even want to leave them out when empty but not sure about that
|
+1 with optional comment |
|
|
atomatt
reviewed
Feb 8, 2016
| +var modelMandatory = []string{"os", "architecture", "gadget", "kernel", "store", "class"} | ||
| + | ||
| +func assembleModel(assert assertionBase) (Assertion, error) { | ||
| + if assert.headers["brand-id"] != assert.headers["authority-id"] { |
atomatt
Feb 8, 2016
Contributor
It seems there is no authority-id for model assertions - the brand-id takes its place.
pedronis
Feb 8, 2016
Contributor
@emgee yea I discussed that with Gustavo, the library assumes there is always an authority-id and that's the signer until we get strong input to add the complexity of aliases for it etc
stevenwilkin
reviewed
Feb 8, 2016
| + return nil, fmt.Errorf("%q header is mandatory", name) | ||
| + } | ||
| + | ||
| + // empty list are allowed |
stevenwilkin
reviewed
Feb 8, 2016
| +} | ||
| + | ||
| +// BrandID returns the brand identifier. Same as the authority id. | ||
| +func (mod *Model) BrandID() string { |
stevenwilkin
reviewed
Feb 8, 2016
| + return mod.allowedModes | ||
| +} | ||
| + | ||
| +// RequiredSnaps returns the snaps that must be installed at all times and cannot be removed for this model. |
stevenwilkin
reviewed
Feb 8, 2016
| + tsLine string | ||
| +} | ||
| + | ||
| +var ( |
pedronis commentedFeb 6, 2016
No description provided.