Skip to content

Conversation

@enj
Copy link
Contributor

@enj enj commented Jan 30, 2019

Builds on #28 and fixes various bugs.

/assign @stlaz

@stlaz review the new commits (your commits are unchanged). I have manually tested this.

stlaz and others added 6 commits January 30, 2019 17:15
Both these functions traverse the top level config's identity
providers, make it one so only one traversal is performed.
The Add functions need to return the path on disk and not the name
of the resource.  AddConfigMap was updating the wrong map.

Use SecretNameReference and ConfigMapNameReference to increase type
safety and reduce boilerplate.
Signed-off-by: Monis Khan <mkhan@redhat.com>
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 30, 2019
@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 30, 2019
@enj
Copy link
Contributor Author

enj commented Jan 31, 2019

/retest

Failure is unrelated.

Copy link
Contributor

@stlaz stlaz left a comment

Choose a reason for hiding this comment

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

Thanks for fixing my weird mistakes. I have a few comments on how to make this a bit cleaner.

func newSourceDataIDPSecret(index int, secretName, idpType string) (string, sourceData) {
dest := getIDPName(index, secretName, idpType)
// sourceData which describes the volumes and mount volumes to mount the secret to
func newSourceDataIDPSecret(index int, secretName configv1.SecretNameReference, key string) (string, sourceData) {
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: s/secretName/secretRef

return data.path
}

func (sd *idpSyncData) AddSecretStringSource(index int, secretName configv1.SecretNameReference, key string) configv1.StringSource {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather if we got rid of the helpers.go file by including the original function in idp.go instead of making this to be a method of this object. Having AddSecretStringSource() method does not make much sense because you don't have special storage for SecretStringSource in idpSyncData, there are only Secrets and ConfigMaps.

// Returns the path for the Secret
func (sd *idpSyncData) AddSecret(index int, secretName configv1.SecretNameReference, key string) string {
func (sd *idpSyncData) AddSecret(index int, secretName configv1.SecretNameReference, key string, optional bool) string {
if optional && len(secretName.Name) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Validation should precede these additions, here I'd personally rather only do

if len(secretName.Name) == 0 {
    return ""
}

It's for a simple reason - you'll need to return errors, too, which is something you're not doing here. Otherwise the problem we have now when optional field is unset would now still be present for required fields with unset values.

Proposal:
Use just the condition mentioned above. That will effectively make all such fields optional. I prepared some preliminary validation code for our CRDs for origin, I need to re-check it and then post it, then I'll get to validation on the operator side.

@stlaz
Copy link
Contributor

stlaz commented Jan 31, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 31, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: enj, stlaz

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

The pull request process is described here

Details 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

@stlaz
Copy link
Contributor

stlaz commented Jan 31, 2019

I'll create a new PR with the suggested changes, those are non-breaking issues anyway.

@openshift-merge-robot openshift-merge-robot merged commit be1b2ec into openshift:master Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants