@@ -30,6 +30,11 @@ import (
3030 "github.com/spf13/viper"
3131)
3232
33+ const (
34+ clusterNameMaxLength = 20
35+ namespaceMaxLength = 20
36+ )
37+
3338var installCmdOptions struct {
3439 dryRun bool
3540 clusterNameInCodefresh string
@@ -164,6 +169,11 @@ var installCmd = &cobra.Command{
164169 s .CodefreshAPI .BuildNodeSelector = bns
165170 builderInstallOpt .BuildNodeSelector = bns
166171
172+ err = validateInstallOptions (builderInstallOpt )
173+ if err != nil {
174+ dieOnError (err )
175+ }
176+
167177 values := s .BuildValues ()
168178 for _ , p := range builder .Get () {
169179 values , err = p .Install (builderInstallOpt , values )
@@ -213,6 +223,16 @@ func parseNodeSelector(s string) (nodeSelector, error) {
213223 return nodeSelector {v [0 ]: v [1 ]}, nil
214224}
215225
226+ func validateInstallOptions (opts * plugins.InstallOptions ) (error ) {
227+ if len (opts .ClusterName ) > clusterNameMaxLength {
228+ return errors .New (fmt .Sprintf ("cluster name lenght is limited to %d" , clusterNameMaxLength ))
229+ }
230+ if len (opts .ClusterNamespace ) > namespaceMaxLength {
231+ return errors .New (fmt .Sprintf ("cluster namespace is limited to %d" , namespaceMaxLength ))
232+ }
233+ return nil
234+ }
235+
216236// String returns a k8s compliant string representation of the nodeSelector. Only a single value is supported.
217237func (ns nodeSelector ) String () string {
218238 var s string
0 commit comments