Skip to content
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

improve gvk and resid strings for error messages #4344

Merged
merged 1 commit into from Dec 22, 2021

Conversation

natasha41575
Copy link
Contributor

@natasha41575 natasha41575 commented Dec 16, 2021

Before:
Gvk.String(): "g_v_k"
ResId.String(): "g_v_k|ns|nm"

After:
Gvk.String(): "{group: g, version: v, kind: k}"
ResId.String(): "{group: g, version: v, kind: k, name: nm, namespace: ns}"

/cc @KnVerey

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Dec 16, 2021
api/resource/resource_test.go Outdated Show resolved Hide resolved
kyaml/resid/gvk.go Show resolved Hide resolved
},
{
ResId{},
"~G_~V_~K|",
"[noKind].[noVer].[noGrp]/",
Copy link
Contributor

Choose a reason for hiding this comment

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

Not new, but why doesn't this one use the name placeholder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The GvknString method has the following body:

// GvknString of ResId based on GVK and name
func (id ResId) GvknString() string {
	return id.Gvk.String() + separator + id.Name
}

Which looks kind of odd to me to begin with and I'm unsure why it exists... but also I took a look and we aren't actually using this anywhere, and I'm not sure where we would use this if ever instead of ResId.String() so I'm inclined to just remove it entirely.

@@ -218,7 +218,7 @@ spec:
t.Fatalf("No match should return an error")
}
if err.Error() !=
"resource with name service does not match a config with the following GVK [~G_~V_Deployment]" {
"resource with name service does not match a config with the following GVK [Deployment.[noVer].[noGrp]]" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we get rid of the surrounding brackets now that we're using them internally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The surrounding brackets are not something we've added, but get added because we are outputting a list of gvks:

return fmt.Errorf("resource with name %s does not match a config with the following GVK %v",
p.Replica.Name, gvks)

Copy link
Contributor

@KnVerey KnVerey left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 22, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: KnVerey, natasha41575

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:
  • OWNERS [KnVerey,natasha41575]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", 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.

None yet

3 participants