Replace caps.FileType with caps.BoolFile with required "path" #206

Merged
merged 10 commits into from Dec 3, 2015

Conversation

Projects
None yet
4 participants
Contributor

zyga commented Dec 2, 2015

This branch depends on #205

This patch kills the early development "file" type and replaces it with
the "bool-file" type that can be used to describe simple GPIO pins.

zyga added some commits Dec 1, 2015

Add caps.Type.SupportedAttrs
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Add support for simple capability attribute validation
This patch ensures, via caps.Type.Validate(), that capabilities have
only attributes that are expected. The actual value of attributes is
not checked, just their presence.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Use caps.testType instead of FileType
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Contributor

zyga commented Dec 2, 2015

CI failed because the corresponding part of #205 is not merged, I'll change that in a sec.

zyga added some commits Dec 2, 2015

Trivial golint suggestion
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Rename caps.Type.SupportedAttrs to RequiredAttrs
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Tweak initializer for known capability types
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
caps/types.go
+ //
+ // This capability type can be used to describe many boolan flags exposed
+ // in sysfs, including certain hardware like exported GPIO pins.
+ BoolFileType = &Type{
@mvo5

mvo5 Dec 2, 2015

Collaborator

Maybe this is more a question for Gustavo, not sure. But is there anything that enforces that BoolFile is a bool file (or will there be anything)? Right now it seems like I could also use it for other files in sysfs or dev. Will there be a DecimalFileType for files like /proc/sys/vm/swappiness that accept a numeric range of parameters? Just curious to understand the longer term vision better .)

zyga added some commits Dec 2, 2015

Tweak wording on caps.Type.RequiredAttrs
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Tweak comment in caps.Type.Validate()
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Replace caps.FileType with caps.BoolFileType with required "path"
This patch kills the early development "file" type and replaces it with
the "bool-file" type that can be used to describe simple GPIO pins.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Use realistic capability in daemon tests
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Member

chipaca commented Dec 2, 2015

👍

Contributor

niemeyer commented Dec 3, 2015

This looks good, but pending work on the underlying branch.

Collaborator

mvo5 commented Dec 3, 2015

One question, how will this look in the future? Will the fact that its a BoolFile with only 0/1 be enforced in some way by snappy? Or is it just a label for the user/developer?

Contributor

zyga commented Dec 3, 2015

@mvo5 In the future each type will be a standalone entity that is loaded at start-up. Types will be documented (along with the semantics for application developers). Snappy will not enforce what an application does but I hope to have a library for popular languages for working with capabilities with cleaner APIs than the roll-your-own one might look like.

chipaca added a commit that referenced this pull request Dec 3, 2015

Merge pull request #206 from zyga/caps-bool-type
Replace caps.FileType with caps.BoolFile with required "path"

@chipaca chipaca merged commit e9a9c95 into snapcore:master Dec 3, 2015

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.006%) to 66.547%
Details

@zyga zyga deleted the zyga:caps-bool-type branch Dec 3, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment