-
Notifications
You must be signed in to change notification settings - Fork 243
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
Adds storage Push() for devfile components. #4407
Merged
openshift-merge-robot
merged 6 commits into
redhat-developer:master
from
mik-dass:storage_push
Mar 15, 2021
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c645d3f
Adds storage Push() for devfile components.
mik-dass 94c0bc9
Adds test for Push(). It also adds tests for Create() and Delete() of…
mik-dass 95c98bd
Removes GetOwnerReference() from the kclient
mik-dass 5b4f010
Renames UpdateStorageOwnerReference() to GetAndUpdateStorageOwnerRefe…
mik-dass 24b8a6b
Fixes ListFromCluster(), removes the StorageAdapter from the common i…
mik-dass e75b72c
Fixes ListFromCluster() by avoiding the volume mounts from the init c…
mik-dass 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
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 |
---|---|---|
@@ -1,101 +1 @@ | ||
package storage | ||
|
||
import ( | ||
"testing" | ||
|
||
devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" | ||
devfileParser "github.com/devfile/library/pkg/devfile/parser" | ||
"github.com/devfile/library/pkg/testingutil" | ||
"github.com/openshift/odo/pkg/devfile/adapters/common" | ||
"github.com/openshift/odo/pkg/lclient" | ||
) | ||
|
||
func TestCreate(t *testing.T) { | ||
|
||
testComponentName := "test" | ||
fakeClient := lclient.FakeNew() | ||
fakeErrorClient := lclient.FakeErrorNew() | ||
|
||
volNames := [...]string{"vol1", "vol2"} | ||
volSize := "5Gi" | ||
|
||
tests := []struct { | ||
name string | ||
storage []common.Storage | ||
client *lclient.Client | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "Case 1: No volumes", | ||
storage: nil, | ||
client: fakeClient, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "Case 2: Multiple volumes", | ||
storage: []common.Storage{ | ||
{ | ||
Name: "vol1", | ||
Volume: common.DevfileVolume{ | ||
Name: volNames[0], | ||
Size: volSize, | ||
}, | ||
}, | ||
{ | ||
Name: "vol2", | ||
Volume: common.DevfileVolume{ | ||
Name: volNames[1], | ||
Size: volSize, | ||
}, | ||
}, | ||
}, | ||
client: fakeClient, | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "Case 3: Docker client error", | ||
storage: []common.Storage{ | ||
{ | ||
Name: "vol1", | ||
Volume: common.DevfileVolume{ | ||
Name: volNames[0], | ||
Size: volSize, | ||
}, | ||
}, | ||
{ | ||
Name: "vol2", | ||
Volume: common.DevfileVolume{ | ||
Name: volNames[1], | ||
Size: volSize, | ||
}, | ||
}, | ||
}, | ||
client: fakeErrorClient, | ||
wantErr: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
devObj := devfileParser.DevfileObj{ | ||
Data: &testingutil.TestDevfileData{ | ||
Components: []devfilev1.Component{}, | ||
}, | ||
} | ||
|
||
adapterCtx := common.AdapterContext{ | ||
ComponentName: testComponentName, | ||
Devfile: devObj, | ||
} | ||
|
||
storageAdapter := New(adapterCtx, *tt.client) | ||
// ToDo: Add more meaningful unit tests once Push actually does something with its parameters | ||
err := storageAdapter.Create(tt.storage) | ||
|
||
// Checks for unexpected error cases | ||
if !tt.wantErr == (err != nil) { | ||
t.Errorf("component adapter create unexpected error %v, wantErr %v", err, tt.wantErr) | ||
} | ||
}) | ||
} | ||
|
||
} |
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
Oops, something went wrong.
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.
so i was looking to extract this logic out, so that the library can return the updated containers with volume mounts and the pvc volumes after reading the devfile.
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 have only modified the network calls in this function.
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.
Yep, after this merged, I can look to consolidate this in devfile/library call; so anyone calling devfile/library generator func like
generator.GetVolume()
will return thepvcVolumes
and updated container volumeMounts 👍