MCPcopy Create free account
hub / github.com/coldbrewcloud/coldbrew-cli / validateFlags

Method validateFlags

commands/deploy/flags.go:57–81  ·  view source on GitHub ↗
(flags *Flags)

Source from the content-addressed store, hash-verified

55}
56
57func (c *Command) validateFlags(flags *Flags) error {
58 if !utils.IsBlank(conv.S(flags.DockerImage)) && !core.DockerImageURIRE.MatchString(conv.S(flags.DockerImage)) {
59 return fmt.Errorf("Invalid Docker image [%s]", conv.S(flags.DockerImage))
60 }
61
62 if !utils.IsBlank(conv.S(flags.DockerfilePath)) {
63 if err := c.validatePath(conv.S(flags.DockerfilePath)); err != nil {
64 return fmt.Errorf("Invalid Dockerfile path [%s]", conv.S(flags.DockerfilePath))
65 }
66 }
67
68 if conv.I64(flags.Units) >= 0 && uint16(conv.I64(flags.Units)) > core.MaxAppUnits {
69 return fmt.Errorf("Units [%d] cannot exceed %d", conv.I64(flags.Units), core.MaxAppUnits)
70 }
71
72 if conv.F64(flags.CPU) > core.MaxAppCPU {
73 return fmt.Errorf("CPU [%.2f] cannot exceed %d", conv.F64(flags.CPU), core.MaxAppCPU)
74 }
75
76 if !utils.IsBlank(conv.S(flags.Memory)) && !core.SizeExpressionRE.MatchString(conv.S(flags.Memory)) {
77 return fmt.Errorf("Invalid app memory [%s]", conv.S(flags.Memory))
78 }
79
80 return nil
81}
82
83func (c *Command) validatePath(path string) error {
84 if utils.IsBlank(path) {

Callers 1

RunMethod · 0.95

Implementers 8

Commandcommands/clusterstatus/command.go
Commandcommands/deploy/command.go
Commandcommands/clusterdelete/command.go
Commandcommands/delete/command.go
Commandcommands/clustercreate/command.go
Commandcommands/create/command.go
Commandcommands/clusterscale/command.go
Commandcommands/status/command.go

Calls 1

validatePathMethod · 0.95

Tested by

no test coverage detected