This repository has been archived by the owner on Jun 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 89
Support creation of managed secret without associating it to a workload #350
Merged
openshift-merge-robot
merged 10 commits into
redhat-developer:master
from
DhritiShikhar:generic-binding-1
Mar 12, 2020
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
619810c
Adds test for Generic Binding
DhritiShikhar 6495e55
Merge remote-tracking branch 'origin/master' into generic
DhritiShikhar 45abadc
update Binding Status
DhritiShikhar 0d20483
remove application selector from required
DhritiShikhar 415b1a8
makes application selector optional
DhritiShikhar 572adc7
Checks status on reconcilation
DhritiShikhar 88203f1
Merge remote-tracking branch 'origin/master' into generic
DhritiShikhar f2c599a
uses corev1.ConditionTrue and corev1.ConditionFalsee
DhritiShikhar 1eceb8e
remove CSV with volume mount
DhritiShikhar 78118e8
change backingServiceResourceRef name
DhritiShikhar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,3 +205,78 @@ func TestReconcilerReconcileUsingVolumes(t *testing.T) { | |
require.Equal(t, reconcilerName, volumes[0].VolumeSource.Secret.SecretName) | ||
}) | ||
} | ||
|
||
func TestReconcilerGenericBinding(t *testing.T) { | ||
ctx := context.TODO() | ||
backingServiceResourceRef := "backingService1" | ||
matchLabels := map[string]string{ | ||
"connects-to": "database", | ||
"environment": "reconciler", | ||
} | ||
f := mocks.NewFake(t, reconcilerNs) | ||
f.AddMockedUnstructuredServiceBindingRequest(reconcilerName, backingServiceResourceRef, "", deploymentsGVR, matchLabels) | ||
f.AddMockedUnstructuredCSV("cluster-service-version-list") | ||
f.AddMockedUnstructuredDatabaseCRD() | ||
f.AddMockedUnstructuredDatabaseCR(backingServiceResourceRef) | ||
f.AddMockedSecret("db-credentials") | ||
|
||
fakeClient := f.FakeClient() | ||
reconciler := &Reconciler{client: fakeClient, dynClient: f.FakeDynClient(), scheme: f.S} | ||
|
||
// Reconcile without deployment | ||
res, err := reconciler.Reconcile(reconcileRequest()) | ||
require.NoError(t, err) | ||
require.True(t, res.Requeue) | ||
|
||
namespacedName := types.NamespacedName{Namespace: reconcilerNs, Name: reconcilerName} | ||
sbrOutput, err := reconciler.getServiceBindingRequest(namespacedName) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, "BindingFail", sbrOutput.Status.BindingStatus) | ||
require.Equal(t, corev1.ConditionFalse, sbrOutput.Status.Conditions[0].Status) | ||
require.Equal(t, 0, len(sbrOutput.Status.ApplicationObjects)) | ||
|
||
// Reconcile with deployment | ||
f.AddMockedUnstructuredDeployment(reconcilerName, matchLabels) | ||
|
||
fakeClient = f.FakeClient() | ||
reconciler = &Reconciler{client: fakeClient, dynClient: f.FakeDynClient(), scheme: f.S} | ||
res, err = reconciler.Reconcile(reconcileRequest()) | ||
require.NoError(t, err) | ||
require.False(t, res.Requeue) | ||
|
||
d := appsv1.Deployment{} | ||
require.NoError(t, fakeClient.Get(ctx, namespacedName, &d)) | ||
|
||
sbrOutput2, err := reconciler.getServiceBindingRequest(namespacedName) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, "BindingSuccess", sbrOutput2.Status.BindingStatus) | ||
require.Equal(t, reconcilerName, sbrOutput2.Status.Secret) | ||
require.Equal(t, corev1.ConditionTrue, sbrOutput2.Status.Conditions[0].Status) | ||
require.Equal(t, 1, len(sbrOutput2.Status.ApplicationObjects)) | ||
|
||
// Update Credentials | ||
s := corev1.Secret{} | ||
secretNamespaced := types.NamespacedName{Namespace: reconcilerNs, Name: "db-credentials"} | ||
require.NoError(t, fakeClient.Get(ctx, secretNamespaced, &s)) | ||
s.Data["password"] = []byte("abc123") | ||
require.NoError(t, fakeClient.Update(ctx, &s)) | ||
|
||
reconciler = &Reconciler{client: fakeClient, dynClient: f.FakeDynClient(), scheme: f.S} | ||
res, err = reconciler.Reconcile(reconcileRequest()) | ||
require.NoError(t, err) | ||
require.False(t, res.Requeue) | ||
|
||
sbrOutput3, err := reconciler.getServiceBindingRequest(namespacedName) | ||
require.NoError(t, err) | ||
|
||
d = appsv1.Deployment{} | ||
require.NoError(t, fakeClient.Get(ctx, namespacedName, &d)) | ||
|
||
require.Equal(t, "BindingSuccess", sbrOutput3.Status.BindingStatus) | ||
require.Equal(t, corev1.ConditionTrue, sbrOutput3.Status.Conditions[0].Status) | ||
require.Equal(t, reconcilerName, sbrOutput3.Status.Secret) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but #366 is not merged yet There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can track this and send a new PR :) |
||
require.Equal(t, s.Data["password"], []byte("abc123")) | ||
require.Equal(t, 1, len(sbrOutput3.Status.ApplicationObjects)) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the first time I've seen this; why generated files are being generated differently between developers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe because of operator-sdk versions? I'm using 0.5.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mine is different:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You definitely got to update your operator-sdk CLI
:-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am on 0.15.2 and even for me these changes are happening