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

Initial check-access work #11

Merged
merged 25 commits into from
Aug 22, 2024
Merged

Initial check-access work #11

merged 25 commits into from
Aug 22, 2024

Conversation

detjensrobert
Copy link
Contributor

@detjensrobert detjensrobert commented Jun 19, 2024

Only basic K8S for now, the others are stubbed out while I work on them.

Also refactors how config parsing works to only parse once, and reuse that on other calls.

Signed-off-by: Robert Detjens <[email protected]>
This will make referencing RcdsConfig and the ChallengeConfig's much easier
in other places in the code. Right now, this requires a call to validate_X()
to initialize the OnceLock with the parsed value; I might change this to a
LazyLock later when it is not experimental.

Signed-off-by: Robert Detjens <[email protected]>
this ensures the config is good to use before other parts try to use it,
and loads the parsed value into the static OnceLocks.

Signed-off-by: Robert Detjens <[email protected]>
These do nothing and return hardcoded values for now.

Signed-off-by: Robert Detjens <[email protected]>
Signed-off-by: Robert Detjens <[email protected]>
If this is not given, use the default KUBECONFIG / ~/.kube/config as usual

Signed-off-by: Robert Detjens <[email protected]>
We don't need to worry about all these unused variable warnings while things
are still being implemented. I know it's unused, I'm gonna use it soon!

Signed-off-by: Robert Detjens <[email protected]>
This checks K8S api access by asking whoami (a la `kubectl auth whoami`).

Also adds Tokio as a dependency. The kube crate is all async, and so we need
Tokio to deal with that.

Signed-off-by: Robert Detjens <[email protected]>
@detjensrobert detjensrobert self-assigned this Jun 19, 2024
Signed-off-by: Robert Detjens <[email protected]>
Comment on lines +15 to +27
/// get config from global, or load from file if not parsed yet
pub fn get_config() -> Result<RcdsConfig> {
// return already parsed value
if let Some(existing) = CONFIG.get() {
return Ok(existing);
}

let config = config::parse();

// if config parsed OK, set global and return that
// otherwise pass through the errors from parsing
config.map(|c| CONFIG.get_or_init(|| c))
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also refactors how config parsing works to only parse once, and reuse that on other calls.

Currently, this is with an getter function that updates a static variable. This is redundant to have both exposed, and I'd prefer to only have the static variable lazily init'd, but std::Lazy isnt standardized yet and would need another crate for that (std::OnceCell is).

Thoughts on how this should be exposed? What's the idiomatic way to do this?

Parsing these and normalizing the structs into one struct for consumers
is very non-ergonomic and users should be doing this anyway for security.

We can add this back in later if the need arises and we know how/what
components are using this.

Signed-off-by: Robert Detjens <[email protected]>
This is using the docker_api crate, for now. This isnt the greatest to use and
there are other libraries that might be better.

Signed-off-by: Robert Detjens <[email protected]>
This is easier to use than docker_api

Signed-off-by: Robert Detjens <[email protected]>
@detjensrobert
Copy link
Contributor Author

merging without review to unblock other work items pending on this pr

@detjensrobert detjensrobert merged commit 98bf272 into main Aug 22, 2024
3 checks passed
@detjensrobert detjensrobert deleted the dr/check-access branch August 22, 2024 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant