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

Adding functionality to set same token value across cluster #10801

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

shivamdurgbuns
Copy link
Member

@shivamdurgbuns shivamdurgbuns commented Nov 5, 2024

This is for Vault Configuration.
fixes: https://issues.redhat.com/browse/OCSQE-1636

@shivamdurgbuns shivamdurgbuns requested a review from a team as a code owner November 5, 2024 07:42
@pull-request-size pull-request-size bot added the size/S PR that changes 10-29 lines label Nov 5, 2024
dahorak
dahorak previously approved these changes Nov 5, 2024
petr-balogh
petr-balogh previously approved these changes Nov 5, 2024
vavuthu
vavuthu previously approved these changes Nov 5, 2024
shylesh
shylesh previously approved these changes Nov 5, 2024
Copy link
Contributor

@shylesh shylesh left a comment

Choose a reason for hiding this comment

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

lgtm

ocs_ci/utility/kms.py Outdated Show resolved Hide resolved
@openshift-ci openshift-ci bot removed the lgtm label Nov 6, 2024
petr-balogh
petr-balogh previously approved these changes Nov 6, 2024
clacroix12
clacroix12 previously approved these changes Nov 7, 2024
@shivamdurgbuns
Copy link
Member Author

@shivamdurgbuns
Copy link
Member Author

@shivamdurgbuns
Copy link
Member Author

petr-balogh
petr-balogh previously approved these changes Dec 2, 2024
Copy link

openshift-ci bot commented Dec 3, 2024

New changes are detected. LGTM label has been removed.

Copy link

openshift-ci bot commented Dec 3, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: shivamdurgbuns

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

1 similar comment
Copy link

openshift-ci bot commented Dec 3, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: shivamdurgbuns

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@shivamdurgbuns
Copy link
Member Author

ocs_ci/utility/kms.py Outdated Show resolved Hide resolved
ocs_ci/utility/kms.py Outdated Show resolved Hide resolved
Copy link
Contributor

@clacroix12 clacroix12 left a comment

Choose a reason for hiding this comment

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

Couple things here:

  • changed set_vault_token from a staticmethod to a standard method since we need an instance reference.
  • changed the name to get_vault_token and updated the docstring since we are returning the value

Comment on lines 139 to 147
@staticmethod
def set_vault_token(self):
"""
This is a static method that will set the token value.
"""
if self.vault_path_token is None:
self.vault_path_token = self.generate_vault_token()
return self.vault_path_token
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@staticmethod
def set_vault_token(self):
"""
This is a static method that will set the token value.
"""
if self.vault_path_token is None:
self.vault_path_token = self.generate_vault_token()
return self.vault_path_token
def get_vault_token(self):
"""
Get the Vault token value. Generate it first if it does not already exist.
Returns:
str: Vault token
"""
if self.vault_path_token is None:
self.vault_path_token = self.generate_vault_token()
return self.vault_path_token

@@ -578,7 +593,7 @@ def vault_create_policy(self, policy_name=None):
raise VaultOperationError(
f"Failed to create policy f{self.vault_policy_name}"
)
self.vault_path_token = self.generate_vault_token()
self.vault_path_token = self.set_vault_token(self)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
self.vault_path_token = self.set_vault_token(self)
self.vault_path_token = self.get_vault_token()

Signed-off-by: Shivam Durgbuns <sdurgbun@redhat.com>
Signed-off-by: Shivam Durgbuns <sdurgbun@redhat.com>
Signed-off-by: Shivam Durgbuns <sdurgbun@redhat.com>
Signed-off-by: Shivam Durgbuns <sdurgbun@redhat.com>
… token value

Signed-off-by: Shivam Durgbuns <sdurgbun@redhat.com>
@@ -578,7 +594,7 @@ def vault_create_policy(self, policy_name=None):
raise VaultOperationError(
f"Failed to create policy f{self.vault_policy_name}"
)
self.vault_path_token = self.generate_vault_token()
self.vault_path_token = self.get_vault_token(self)
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to explicitly pass this to the function anymore.

Suggested change
self.vault_path_token = self.get_vault_token(self)
self.vault_path_token = self.get_vault_token()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/S PR that changes 10-29 lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants