Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

fix(#38): add sa_token_encrypted to cluster model #40

Merged
merged 4 commits into from
Dec 5, 2018

Conversation

dipak-pawar
Copy link
Contributor

Fixes: #38

@dipak-pawar dipak-pawar requested review from alexeykazakov and xcoulon and removed request for alexeykazakov December 3, 2018 12:32
@codecov
Copy link

codecov bot commented Dec 3, 2018

Codecov Report

Merging #40 into master will increase coverage by 0.32%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #40      +/-   ##
==========================================
+ Coverage   75.79%   76.12%   +0.32%     
==========================================
  Files          13       13              
  Lines         752      758       +6     
==========================================
+ Hits          570      577       +7     
+ Misses        150      148       -2     
- Partials       32       33       +1
Impacted Files Coverage Δ
cluster/repository/cluster.go 69.81% <ø> (ø) ⬆️
configuration/configuration.go 78.57% <100%> (+0.31%) ⬆️
cluster/service/cluster.go 69.04% <100%> (+1.57%) ⬆️
migration/migration.go 86.66% <100%> (+0.95%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b963852...f8d0608. Read the comment docs.

Copy link
Contributor

@alexeykazakov alexeykazakov left a comment

Choose a reason for hiding this comment

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

Overall looks good but let's modify the code a bit.

  • "service-account-token-encrypted" in configuration JSON should be optional. If not set then use "true" be default. So, we don't have to modify the existing configuration secret.
  • I don't see any tests which checks if this flag is set to false. It's set to true in all tests or I'm missing something? We need to add tests for:
  • Configuration is set to "true", "false", not-set. Check it's loaded properly.
  • When creating an entry in the DB the flag is honored (maybe you already have a test for that though).

@dipak-pawar
Copy link
Contributor Author

@alexeykazakov I have addressed your comments.

Copy link
Contributor

@xcoulon xcoulon left a comment

Choose a reason for hiding this comment

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

In the parent issue description, you mentioned that the default value for the new field/column should be false but here in this PR, it's true. Also, I'm not sure I understand how this new field/column is used at all.
Lastly, please don't use the NOT NULL constraint on the new column now, otherwise we can't rollback the deployment. We can add this constraint in a later PR/deployment, though

@@ -613,3 +619,8 @@ func (c *ConfigurationData) GetDevModePrivateKey() []byte {
}
return nil
}

// IsSaTokenEncrypted return pointer to bool
func IsSaTokenEncrypted(encrypted bool) *bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

the name of this function is confusing: you just return a pointer to the given bool, don't you?

Copy link
Contributor Author

@dipak-pawar dipak-pawar Dec 5, 2018

Choose a reason for hiding this comment

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

ok, let me change that to PointerToBool?


// check if ALL the existing rows & new rows have the default value
rows, err := sqlDB.Query("SELECT sa_token_encrypted FROM cluster")
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

require.NoError(t, err)

@@ -0,0 +1,2 @@
-- Store sa_token_encrypted for cluster
ALTER TABLE cluster ADD COLUMN sa_token_encrypted boolean NOT NULL DEFAULT FALSE;
Copy link
Contributor

Choose a reason for hiding this comment

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

please don't use NOT NULL in this sql statement: if we need to rollback the deployment, we'll be in troubles.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see reason to rollback the deployment. Do you see?

Copy link
Contributor

Choose a reason for hiding this comment

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

it's just a good practice IMO

@dipak-pawar
Copy link
Contributor Author

In the parent issue description, you mentioned that the default value for the new field/column should be false but here in this PR, it's true. Also, I'm not sure I understand how this new field/column is used at all.

@xcoulon I have updated issue description. Sorry for confusion. Let me know if it's clear to you

@dipak-pawar dipak-pawar merged commit 4c9959a into fabric8-services:master Dec 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants