-
Notifications
You must be signed in to change notification settings - Fork 0
Namespace config #161
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
Namespace config #161
Conversation
benbrandt
left a comment
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.
Since we're bringing in breaking changes, I think we should fix a few more things before merging.
From the user side we are just making it possible to configure more things, but I don't want to change it again after.
I think we have an issue where registry is used in two levels, which hints at a naming problem in our domain.
And more importantly, we need to define what a NamespaceIdentifier is and make sure it is serialized as such from env variables and strings.
I would suggest:
- letters
- numbers
-
You should be able to check the characters (maybe only allow alphanumeric and - or _ ?) and also use the heck crate if you need to convert. (Though with the previous rules maybe it is as simple as replacing _ with -)
| # Each of the value can alternatively be provided as environment variables, which have higher precedence: | ||
| # NAMESPACES__PLAYGROUND__CONFIG_URL | ||
| # NAMESPACES__PLAYGROUND__CONFIG_ACCESS_TOKEN | ||
| # NAMESPACES__PLAYGROUND__REGISTRY__REGISTRY |
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 still feel this is telling us we have a bad name here... Shouldn't have registry twice
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.
Changing the field to name
| config_url: String, | ||
| config_access_token_env_var: Option<String>, | ||
| config_access_token: Option<String>, | ||
| registry: Registry, |
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.
Ok this is the issue for me. This causes the double registry in the variable which is a signal to me we got the naming wrong.
This isn't always a registry.... I wonder if this is something like source or ... I don't know. But we need another name because then this type has a name that is the same
|
On second thought... The normalization would also apply at the url level, so it's possible we can sort this out afterwards... But might still be good to sort out before releasing as a separate breaking release. |
benbrandt
left a comment
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.
We're getting there! Nice work. Still some small things
operator-config.toml
Outdated
| [namespaces.pharia-kernel-team.registry] | ||
| type = "oci" | ||
| registry = "registry.gitlab.aleph-alpha.de" | ||
| name = "registry.gitlab.aleph-alpha.de" |
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 think we're getting closer here. But I still feel like registry is the right name at this level. According to the spec https://github.com/opencontainers/distribution-spec/blob/main/spec.md this is indeed the name of this URL.
I feel like our domain model is slightly off for this enum. The enum is called Registry, but then the variants are a file based or an OCI based one. Which is why i wonder if we need a different name at the top level.
You could argue however, that while this is our concept internally, from a user perspective they only ever deal with OCI registries and therefore registry is the right term at the outer level, which is fair.
In that case I feel this should be domain or host or something.
Sorry to be pedantic about this, but obviously I care we get the right names here :)
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.
Basically I'm sure you guys discussed so:
If you feel the correct name of this domain object is indeed Registry, I am ok with this, but then I wonder if there is a more specific, intuitive name for name
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.
Absolutely, in fact we spent most of the time pondering about this, and we are still not satisfied with the results.
I think it is a symptom of internal (enum) representation leaking into user interface.
pub enum NamespaceConfig {
TeamOwned {
config_url: String,
config_access_token: Option<String>,
registry: Registry,
},
Watch { directory: PathBuf },
InPlace {
skills: Vec<SkillDescription>,
registry: Registry,
},
}If we look at the current definition, NamespaceConfig consists of two things:
- Skill config
- Skill registry (or source)
For TeamOwned, the skill config is already prefixed with config and registry would be prefixed with registry, at least this is consistent.
For Watch, the directory acts as both the skill config and the skill registry.
For InPlace, the skills is the skill config, while the registry is equivalent to TeamOwned.
Thinking top-down, maybe we can streamline the interface:
# TeamOwned + OciRegistry
[namespaces.oci-team]
config_url = ""
config_access_token = ""
registry = ""
repository = ""
registry_user = ""
registry_password = ""
# TeamOwned + FileRegistry
[namespaces.file-team]
config_url = ""
config_access_token = ""
path = ""
# Watch
[namespaces.dev]
directory = ""
# InPlace + OciRegistry
[namespaces.oci-default]
skills = []
registry = ""
repository = ""
registry_user = ""
registry_password = ""
# InPlace + FileRegistry
[namespaces.file-default]
skills = []
path = ""What do you think?
This would mean flattening the registry, untagging the Registry enum, and adding prefix to user/password.
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 also considering refactoring config_url and config_access_token as skill_config (which can be via file or http) and skill_config_access_token.
src/namespace_watcher/config.rs
Outdated
| pub fn from_toml(config: &str) -> anyhow::Result<Self> { | ||
| Ok(toml::from_str(config)?) | ||
| fn environment() -> Environment { | ||
| // A namespace can contain the characters `[a-z0-9-]` e.g. `pharia-kernel-team`. |
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.
This is a great doc comment
src/namespace_watcher/config.rs
Outdated
| /// implies that the skills in team owned namespaces are configured by a team rather than the | ||
| /// operators of Pharia Kernel, which in turn means we only refer the teams documentation here. | ||
| TeamOwned { | ||
| #[serde(alias = "config-url")] |
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 think we can remove these aliases once we sort out if we need kebab for all environment variables
src/shell.rs
Outdated
| /// The qualified name of the skill to invoke. The qualified name consists of a namespace and | ||
| /// a skill name (e.g. "acme/summarize"). | ||
| /// If the namespace is omitted, the default 'pharia-kernel-team' namespace is used. | ||
| /// If the namespace is omitted, the default `pharia-kernel-team` namespace is used. |
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.
Oh we should remove this line. No longer true. It is required
Previously, the namespace config access token, as well as the user and the password for the skill registry are provided as the associated environment variable keys only. As we have now adopted config-rs, the actual values can be provided directly, or more commonly via the associated environment variables.
this enforces consistency of configuration names and optimizes the config interface for defining a remote registry
No description provided.