File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -116,12 +116,17 @@ func (r *Resource) checkAndSetKinds() error {
116
116
}
117
117
118
118
func (r * Resource ) checkAndSetGroups () error {
119
- r .FullGroup = strings .Split (r .APIVersion , "/" )[0 ]
120
- r .Group = strings .Split (r .FullGroup , "." )[0 ]
121
-
122
- if len (r .Group ) == 0 {
119
+ fg := strings .Split (r .APIVersion , "/" )
120
+ if len (fg ) < 2 || len (fg [0 ]) == 0 {
121
+ return errors .New ("full group cannot be empty" )
122
+ }
123
+ g := strings .Split (fg [0 ], "." )
124
+ if len (g ) < 2 || len (g [0 ]) == 0 {
123
125
return errors .New ("group cannot be empty" )
124
126
}
127
+ r .FullGroup = fg [0 ]
128
+ r .Group = g [0 ]
129
+
125
130
if ! ResourceGroupRegexp .MatchString (r .Group ) {
126
131
return errors .New ("group should consist of lowercase alphabetical characters" )
127
132
}
@@ -130,7 +135,7 @@ func (r *Resource) checkAndSetGroups() error {
130
135
131
136
func (r * Resource ) checkAndSetVersion () error {
132
137
api := strings .Split (r .APIVersion , "/" )
133
- if len (api ) < 2 {
138
+ if len (api ) < 2 || len ( api [ 1 ]) == 0 {
134
139
return errors .New ("version cannot be empty" )
135
140
}
136
141
r .Version = api [1 ]
You can’t perform that action at this time.
0 commit comments