-
Notifications
You must be signed in to change notification settings - Fork 245
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 the functionality of unmounting storage using the mounted path. #492
Conversation
@mik-dass , code looks good. Please check whether you can add tests or not |
cmd/storage.go
Outdated
fmt.Printf("Storage %v does not exist in component %v\n", storageName, componentName) | ||
os.Exit(1) | ||
storageName := "" | ||
if string(args[0][0]) == "/" { |
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.
It might be nice to have command explaining what we are doing here.
What would happen if we pass in: |
@cdrage You mean at the start of the path? |
@mik-dass Yes |
@cdrage I think it might be complicated as there are many combinations which are possible |
This should be treated as a storage name, and it should fail because no such storage exits. |
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.
Use
for unmount command needs to be updated.
Use: "unmount [storage name]",
Also, Long
description should explain that this command can be called with a path and that path needs to be absolute.
cmd/storage.go
Outdated
Use: "unmount [storage name]", | ||
Short: "Unmount storage from the current component", | ||
Long: `Unmount storage from the current component. | ||
Use: "unmount [storage/path name]", |
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.
we can update this based on #516
"PATH | STORAGE_NAME"
cmd/storage.go
Outdated
Long: `Unmount storage from the current component. | ||
Use: "unmount [storage/path name]", | ||
Short: "Unmount storage or storage with the given path, from the current component", | ||
Long: `Unmount storage or storage with the given path, from the current component. |
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.
How about this:
Unmount storage from the given path or unmount storage identified by its name.
@kadel Done |
cmd/storage.go
Outdated
Use: "unmount [storage name]", | ||
Short: "Unmount storage from the current component", | ||
Long: `Unmount storage from the current component. | ||
Use: "unmount [PATH | STORAGE_NAME]", |
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 should be lowercase, other sources (such as create.go
) use lowercase.
unmount <path | storage_name>
maybe better?
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.
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.
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.
@kadel So between <>?
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.
As described in docopts docs (link in #516)
either just capital letters
unmount PATH | STORAGE_NAME
or in <>
unmount <path> | <storage_name>
I would use the capital letters, it seems to be more widly used (heroku and could foundry).
We should pick one and stick with it across all commands in OpenShift-Do.
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.
@kadel OK I will changed to the Upper case approach
cmd/storage.go
Outdated
if !exists { | ||
fmt.Printf("Storage %v does not exist in component %v\n", storageName, componentName) | ||
os.Exit(1) | ||
storageName := "" |
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.
if this starts as blank, I think var storageName string
is more go-esque
cmd/storage.go
Outdated
if string(args[0][0]) == "/" { | ||
path := args[0] | ||
storageName, err = storage.GetStorageNameFromMountPath(client, path, componentName, applicationName) | ||
checkError(err, "") |
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.
instead of ""
maybe add explanation (Unable to get storage name from mount path
) or something similar?
cmd/storage.go
Outdated
} else { | ||
storageName = args[0] | ||
exists, err := storage.IsMounted(client, storageName, componentName, applicationName) | ||
checkError(err, "") |
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.
same here, maybe add own explanation?
pkg/storage/storage.go
Outdated
func GetStorageNameFromMountPath(client *occlient.Client, path string, componentName string, applicationName string) (string, error) { | ||
storages, err := List(client, componentName, applicationName) | ||
if err != nil { | ||
return "", errors.Wrap(err, "unable to list storages") |
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.
storage not storages
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.
@cdrage But we refer to one PVC as storage
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.
@mik-dass Storage is an uncountable plural, we just use "storage" not "storages". https://en.wiktionary.org/wiki/storage
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.
@cdrage I know about the plural form but here a single PVC is called storage and all of them together is also called storage. It seemed confusing. So I added the 's' to distinguish. Anyways updating it.
baa2fb7
to
722b9e1
Compare
LGTM |
…A function GetStorageNameFromMountPath is added which returns the storageName mounted to the given path in the given component and application or returns the error. Signed-off-by: mdas <mrinald7@gmail.com>
Issue : #493
Signed-off-by: mdas mrinald7@gmail.com