-
Notifications
You must be signed in to change notification settings - Fork 926
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
Add API types for configuration metadata #14132
base: main
Are you sure you want to change the base?
Conversation
Heads up @mionaalex - the "Documentation" label was applied to this issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thanks!
@@ -285,7 +253,7 @@ func parse(path string, outputJSONPath string, excludedPaths []string, substitut | |||
continue | |||
} | |||
|
|||
configKeyEntry[metadataMap["key"]].(map[string]any)[dataKVMatch[1]] = detectType(dataKVMatch[2]) | |||
configKeyEntry[metadataMap["key"]].(map[string]any)[dataKVMatch[1]] = dataKVMatch[2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this change.
Where is the value in dataKVMatch[2]
coming from?
As for how these are classified, whilst I agree that all config values are strings, my understanding of the metadata definition here is in order to indicate in the docs what sort of string values are allowed for a particular config key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like dataKVMatch
is coming from this regular expression (?m)([\S]+):[\s]+([\S \"\']+)
on the key value section of the lxdmeta:generate
section of the doc block e.g.:
type: string
defaultdesc: `auto`
liveupdate: no
shortdesc: What to do when evacuating the instance
In this example, the first dataKVMatch
outputted from lxdDocDataRegex.FindAllStringSubmatch(data, -1)
would have
dataKVMatch[1] -> "type"
dataKVMatch[2] -> "string"
My feeling is that lxd-generate shouldn't be too clever about figuring out which config keys are which type. We should just include that in the description of the key. There is only one config key for which this appears to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is only one config key for which this appears to work.
which one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit directly after this change shows the result of make update-metadata
. Only one field is changed: 2614bb5#diff-d3459341f992192c3b18b6130aa7e165d305183794a84f219c7ab7512b1b31bcL4316
It is changing the value of defaultdesc
from a boolean true
to a string "true"
.
@@ -309,6 +309,13 @@ func parse(path string, outputJSONPath string, excludedPaths []string, substitut | |||
return nil, fmt.Errorf("Error while marshaling project documentation: %v", err) | |||
} | |||
|
|||
// Validate that what we've generated is valid against our API definition. | |||
var metadataConfiguration api.MetadataConfiguration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice touch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the data type change at the start, this seems all good.
needs a rebase. @edlerd are you happy with this change btw? |
Signed-off-by: Mark Laing <mark.laing@canonical.com>
They may be something like "true", but this is still a string. Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
This includes adding the `requires_project` field, which will be required for validating `lxc auth permission add/remove` command arguments. Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
…finition. Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
1b74932
to
d594de4
Compare
Done 👍 |
Happy is a big word for a change breaking our integration ;-) It looks all right to me. One concern is the |
I'm a bit confused about this, does this relate to the |
Yes, exactly. You can share a network between all projects, so it is not really project specific. Or you can enable the |
I guess this is a difference in phrasing. When a network is "shared" it is just a network in the default project. It's still project specific because it is in the default project. Let's say you create project "foo" with |
Project features have been a real headache for fine-grained authorization for this reason. I've added a warning to the documentation on this: https://documentation.ubuntu.com/lxd/en/latest/explanation/projects/#isolation-of-projects. |
This is so that we can manage configuration metadata with API extensions as we do with any other API response over
/1.0
GET /1.0/configuration/metadata
.shared/api
for configuration metadata.requires_project
andentitlements
fields.GET /1.0/configuration/metadata
to include the newly defined type.