-
Notifications
You must be signed in to change notification settings - Fork 56
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
capitalizeMsg function to correctly capitalize the first character an… #1276
Conversation
Hi @Horiodino. Thanks for your PR. I'm waiting for a devfile member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
i was thinking in the dw structure we can add a context of type error if its for user we can set it as true and then at the end we can dw is for error handling and representing we can directly add function for that. |
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.
Thank you for your PR @Horiodino :)
It seems you're missing testing instructions. Could you please add some?
Have you tried building DevWorkspace Operator with your changes and deploying it to a testing cluster (like minikube for instance?)
I took a look through the codebase to try and find a user-facing error message that is not already being capitalized, and is simple enough to trigger. What I found was that finalize function (which gets called when a workspace is being terminated/deleted off the cluster) will try and check the workspace's storageProvisioner (i.e. storage type). The potential error that could happen at this step is not being capitalized.
You should be able to trigger this (normally not-capitalized error) by:
- Creating a workspace with a valid storage strategy attribute set, e.g.:
kind: DevWorkspace
apiVersion: workspace.devfile.io/v1alpha2
metadata:
name: plain-devworkspace
spec:
started: true
routingClass: 'basic'
template:
attributes:
controller.devfile.io/storage-type: per-user
components:
- name: web-terminal
container:
image: quay.io/wto/web-terminal-tooling:next
memoryRequest: 256Mi
memoryLimit: 512Mi
mountSources: true
command:
- "tail"
- "-f"
- "/dev/null"
- Let the workspace startup successfully
- Modify the workspace's storage-type attribute to an invalid value
- Delete the workspace object off the cluster, i.e.
kubectl delete dw plain-devworkspace -n <your-workspace's-namespace>
- Check that the workspace status error message is capitalized by checking the devworkspace object or doing a
kubectl get dw -n <your-workspace's-namespace>
Anytime we're setting the workspace status, such as here, it is already implied that it is a user-facing message. As the workspace status will be provided in the workspace object on the cluster. So there should be no need for this additional context IMO. |
41742c9
to
f56a79c
Compare
sorry for making so long , the
|
/test v8-devworkspace-operator-e2e, v8-che-happy-path |
@Horiodino: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
@Horiodino thank you for the follow-up. Could you please run a You might also need to do a |
@Horiodino sorry for the delay, I'm planning to continue reviewing your PR early this week. |
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.
Sorry for the delay in following up on this @Horiodino.
I made a silly mistake in my original review: cases.Title(language.English, cases.NoLower)
actually sets every word in a string to start with an upper case character, which is not what we want here.
You can remove commits f56a79c & c431b0e from your PR and just keep e758926. I'll add some extra comments on that commit.
Also for testing, you should be running
kubectl patch dw plain-devworkspace -n $NAMESPACE --type=merge -p '{"spec":{"template":{"attributes":{"controller.devfile.io/storage-type": "invalid-type"}}}}' && kubectl delete dw plain-devworkspace -n $NAMESPACE
as the workspace needs to be deleted immediately after setting an invalid storage type.
The output of kubectl get dw -n $NAMESPACE -w
should include something like:
plain-devworkspace workspace3a2024c23f13435f Error Configured Storage Type Not Supported
controllers/workspace/condition.go
Outdated
@@ -130,3 +132,12 @@ func getConditionIndexInOrder(condType dw.DevWorkspaceConditionType) int { | |||
} | |||
return -1 | |||
} | |||
|
|||
func capitalizeMsg(msg string) string { | |||
if len(msg) == 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.
We usually check for empty strings directly, rather than checking the length of the string. So this can be rewritten as:
if msg == "" {
return msg
}
controllers/workspace/condition.go
Outdated
@@ -130,3 +132,12 @@ func getConditionIndexInOrder(condType dw.DevWorkspaceConditionType) int { | |||
} | |||
return -1 | |||
} | |||
|
|||
func capitalizeMsg(msg string) string { |
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 think this function name could be unabbreviated as capitalizeMessage(msg string)
.
Also, it's worth adding a simple function doc, something like:
// Capitalizes the first character in the given string.
b49342d
to
e70748d
Compare
working as expected |
/ok-to-test |
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.
LGTM. @dkwon17 any thoughts? I'll wait for you to give this a look before we merge.
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.
Sorry, just getting to this now,
LGTM, let's have it for DWO 0.31.x
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: AObuchow, dkwon17, Horiodino The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@Horiodino This looks just about good to merge finally. @Horiodino could you please squashing both of your commits and perhaps rewording the commit message to "feat: ensure all DevWorkspace condition messages are capitalized" (or something similar)? Thank you :) |
e70748d
to
8e304e2
Compare
New changes are detected. LGTM label has been removed. |
@Horiodino Sorry for being so picky, but your commit now has the author sign-off twice in the description, and it's also lacking a reference to the bug it's resolving. Could you please modify your commit message to:
|
Fix devfile#1092 Signed-off-by: Horiodino <[email protected]>
8e304e2
to
76b66f3
Compare
np , done 👍 |
@Horiodino Thank you! Merging, great work :) |
handle error msf scenarios based
What does this PR do?
What issues does this PR fix or reference?
#1092
Is it tested? How?
PR Checklist
/test v8-devworkspace-operator-e2e, v8-che-happy-path
to trigger)v8-devworkspace-operator-e2e
: DevWorkspace e2e testv8-che-happy-path
: Happy path for verification integration with Che