Skip to content

Catch invalid job names #11

@jacobtomlinson

Description

@jacobtomlinson

When trying to create a job with the name runningTest I get the following error.

$ krontab -e
panic: CronJob.batch "runningTest" is invalid: [metadata.name: Invalid value: "runningTest": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*'), spec.jobTemplate.spec.template.spec.containers[0].name: Invalid value: "runningTest": a DNS-1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name',  or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')]

goroutine 1 [running]:
github.com/jacobtomlinson/krontab/crontab.KronJob.Create(0xc0000b5c58, 0x7, 0xc0000b5ca0, 0xb, 0xc0000b5e60, 0xc, 0xc0000b5f10, 0xc, 0x0, 0x18)
        /Users/jacob/Projects/pangeo/krontab/crontab/crontab.go:78 +0xf1
github.com/jacobtomlinson/krontab/crontab.EditCrontab()
        /Users/jacob/Projects/pangeo/krontab/crontab/crontab.go:207 +0x5a1
github.com/jacobtomlinson/krontab/cmd.glob..func10(0x2849f20, 0xc00030ee80, 0x0, 0x1)
        /Users/jacob/Projects/pangeo/krontab/cmd/root.go:32 +0x59
github.com/spf13/cobra.(*Command).execute(0x2849f20, 0xc0000c2030, 0x1, 0x1, 0x2849f20, 0xc0000c2030)
        /Users/jacob/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:766 +0x2cc
github.com/spf13/cobra.(*Command).ExecuteC(0x2849f20, 0x0, 0x284a640, 0xc000147f58)
        /Users/jacob/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:852 +0x2fd
github.com/spf13/cobra.(*Command).Execute(0x2849f20, 0x1007500, 0xc0000a0058)
        /Users/jacob/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:800 +0x2b
github.com/jacobtomlinson/krontab/cmd.Execute()
        /Users/jacob/Projects/pangeo/krontab/cmd/root.go:44 +0x2d
main.main()
        /Users/jacob/Projects/pangeo/krontab/main.go:8 +0x20

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions