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

validate shortnames during generation #320

Open
mitchdraft opened this issue Nov 6, 2019 · 0 comments
Open

validate shortnames during generation #320

mitchdraft opened this issue Nov 6, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@mitchdraft
Copy link
Contributor

"nice to have"

currently you can generate code with kube shortcodes like this: shortCode but if you try to register the crd, it will fail with this error:

0: errorVerbose: failed to register crd: CustomResourceDefinition.apiextensions.k8s.io "rbacconfigs.istio.rbac.v1alpha1" is invalid: spec.names.shortNames[0]: Invalid value: "rbacConfig": a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name',  or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?')
creating base RbacConfig resource client
github.com/solo-io/mesh-projects/vendor/github.com/solo-io/solo-kit/pkg/errors.Wrapf
        /Users/mitch/go/src/github.com/solo-io/mesh-projects/vendor/github.com/solo-io/solo-kit/pkg/errors/errors.go:12
github.com/solo-io/mesh-projects/pkg/api/external/istio/rbac/v1alpha1.NewRbacConfigClientWithToken
        /Users/mitch/go/src/github.com/solo-io/mesh-projects/pkg/api/external/istio/rbac/v1alpha1/rbac_config_client.sk.go:41
github.com/solo-io/mesh-projects/pkg/api/external/istio/rbac/v1alpha1.NewRbacConfigClient
        /Users/mitch/go/src/github.com/solo-io/mesh-projects/pkg/api/external/istio/rbac/v1alpha1/rbac_config_client.sk.go:32
github.com/solo-io/mesh-projects/pkg/capability/rbac.InitializeRbacConfigClient
        /Users/mitch/go/src/github.com/solo-io/mesh-projects/pkg/capability/rbac/rbac_syncer.go:256
github.com/solo-io/mesh-projects/pkg/capability/rbac.Run
        /Users/mitch/go/src/github.com/solo-io/mesh-projects/pkg/capability/rbac/rbac_syncer.go:52
github.com/solo-io/mesh-projects/services/rbac-operator/pkg/setup.Main
        /Users/mitch/go/src/github.com/solo-io/mesh-projects/services/rbac-operator/pkg/setup/setup.go:33
main.run.func1
        /Users/mitch/go/src/github.com/solo-io/mesh-projects/services/rbac-operator/cmd/main.go:26
runtime.goexit
        /usr/local/Cellar/go/1.12.5/libexec/src/runtime/asm_amd64.s:1337
process: rbac-operator
logger: rbac-operator
msg: err in main
caller: cmd/main.go:17
version: undefined
error: creating base RbacConfig resource client: failed to register crd: CustomResourceDefinition.apiextensions.k8s.io "rbacconfigs.istio.rbac.v1alpha1" is invalid: spec.names.shortNames[0]: Invalid value: "rbacConfig": a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name',  or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?')
stacktrace: main.main
        /Users/mitch/go/src/github.com/solo-io/mesh-projects/services/rbac-operator/cmd/main.go:17
runtime.main
        /usr/local/Cellar/go/1.12.5/libexec/src/runtime/proc.go:200
level: fatal
ts: 2019-11-06T10:41:28.299-0500

it's tricky because plural_name does not have this restriction

example of valid config:

message RbacConfig {

    option (core.solo.io.resource).short_name = "rbacconfig";
    option (core.solo.io.resource).plural_name = "rbacConfigs";

example of invalid config:

message RbacConfig {

    option (core.solo.io.resource).short_name = "rbacConfig";
    option (core.solo.io.resource).plural_name = "rbacConfigs";

if we validate during generation we can signal this error sooner than later

@mitchdraft mitchdraft added the enhancement New feature or request label Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant