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

Add support for single token #404

Merged
merged 14 commits into from
Jan 4, 2022
Merged

Add support for single token #404

merged 14 commits into from
Jan 4, 2022

Conversation

gkrenn
Copy link
Contributor

@gkrenn gkrenn commented Dec 3, 2021

If the apiToken has the scope "InstallerDownload" and "DataExport", the paas token can be omitted

- token validation now works with only 1 apiToken
- if only the apiToken is provided, a copy of the token is saved in the paasToken field of the secret
@gkrenn gkrenn requested a review from 0sewa0 December 7, 2021 12:44
return dtc, updateCR, nil
}

func (r *DynatraceClientReconciler) getTokensFromSecret(ctx context.Context, instance *dynatracev1beta1.DynaKube) (*corev1.Secret, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this doesn't only get the tokens from the secret
maybe splitting this into loading the secret and then assigning the tokens in a separate stuff would improve readability here

@@ -36,8 +36,6 @@ func TestReconcileDynatraceClient_TokenValidation(t *testing.T) {
rec := &DynatraceClientReconciler{
Client: c,
DynatraceClientFunc: StaticDynatraceClient(dtcMock),
UpdatePaaSToken: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

this could use a test to make sure the apiToken is used when the paasToken is missing

func TestReconcile_RemoveRoutingIfDisabled(t *testing.T) {
mockClient := &dtclient.MockDynatraceClient{}
// replacing is possible
Copy link
Collaborator

Choose a reason for hiding this comment

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

replacing what?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was just a hint for me during development, will be removed

src/initgeneration/initgeneration.go Outdated Show resolved Hide resolved
src/controllers/dynakube/dtclient_reconciler.go Outdated Show resolved Hide resolved
@@ -9,6 +9,7 @@ CONNECTION_NAME=""
CLUSTER_NAME=""
CLUSTER_NAME_REGEX="^[-_a-zA-Z0-9][-_\.a-zA-Z0-9]*$"
CLUSTER_NAME_LENGTH=256
USES_API_AS_PAAS_TOKEN=false
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think the install.sh needs to be updated, but having it can't hurt...

- If there is only one token then only one condition field of dynakube should be used
- ApiToken in secret should not be copied
@gkrenn gkrenn merged commit 34f2060 into master Jan 4, 2022
@gkrenn gkrenn deleted the feature/api-as-paas-token branch January 4, 2022 11:06
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.

None yet

3 participants