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

Refactor AuthCredentials #3

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

HomayoonAlimohammadi
Copy link

@HomayoonAlimohammadi HomayoonAlimohammadi commented Nov 26, 2024

Overview

  • Replace old juju-solutions with charmed-kubernetes in the URL of the setup file.
  • Refactored some duplicated strings and added AuthCredentials

@HomayoonAlimohammadi HomayoonAlimohammadi changed the title Fix url Replace juju-solutions with charmed-kubernetes in the URL Nov 26, 2024
@HomayoonAlimohammadi HomayoonAlimohammadi changed the title Replace juju-solutions with charmed-kubernetes in the URL Refactor AuthCredentials Nov 26, 2024
Copy link

@louiseschmidtgen louiseschmidtgen left a comment

Choose a reason for hiding this comment

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

Nice work Hue, I've got a few questions on the way we store the tokens.

Comment on lines +167 to +169
kubelet_token: str
proxy_token: str
client_token: str

Choose a reason for hiding this comment

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

Are these tokens going to be encoded?

Choose a reason for hiding this comment

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

I don't think so, I just created this model because I have personal issues with a type-unsafe dict :D

Choose a reason for hiding this comment

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

That'll be the go developer in you :D

ops/ops/interface_kube_control/consts.py Show resolved Hide resolved
@@ -139,3 +149,21 @@ def get_ca_certificate(self, model: ops.Model) -> Optional[bytes]:
return secret.get_content(refresh=True)["ca-certificate"].encode()
except ops.SecretNotFoundError:
return None


class AuthCredentials(BaseModel):

Choose a reason for hiding this comment

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

Are there any tests around getting and setting these AuthCredentials?

Choose a reason for hiding this comment

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

I think there is. The only thing that we use from that AuthCredentials is the client_token field, and that field is used to populate the token in the created kubeconfig. We have a test covering it here: https://github.com/charmed-kubernetes/interface-kube-control/blob/main/ops/tests/unit/test_ops_requires.py#L157

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

Successfully merging this pull request may close these issues.

2 participants