@@ -27,6 +27,29 @@ import (
27
27
"github.com/arangodb/kube-arangodb/pkg/util/errors"
28
28
)
29
29
30
+ const (
31
+ ArangoMLExtensionSpecDeploymentComponentPrediction = "prediction"
32
+ ArangoMLExtensionSpecDeploymentComponentTraining = "training"
33
+ ArangoMLExtensionSpecDeploymentComponentProject = "project"
34
+
35
+ ArangoMLExtensionSpecDeploymentComponentPredictionDefaultPort = 16000
36
+ ArangoMLExtensionSpecDeploymentComponentTrainingDefaultPort = 16001
37
+ ArangoMLExtensionSpecDeploymentComponentProjectDefaultPort = 16002
38
+ )
39
+
40
+ func GetArangoMLExtensionSpecDeploymentComponentDefaultPort (component string ) int32 {
41
+ switch component {
42
+ case ArangoMLExtensionSpecDeploymentComponentPrediction :
43
+ return ArangoMLExtensionSpecDeploymentComponentPredictionDefaultPort
44
+ case ArangoMLExtensionSpecDeploymentComponentTraining :
45
+ return ArangoMLExtensionSpecDeploymentComponentTrainingDefaultPort
46
+ case ArangoMLExtensionSpecDeploymentComponentProject :
47
+ return ArangoMLExtensionSpecDeploymentComponentProjectDefaultPort
48
+ }
49
+
50
+ return 0
51
+ }
52
+
30
53
type ArangoMLExtensionSpecDeployment struct {
31
54
// Replicas defines the number of replicas running specified components. No replicas created if no components are defined.
32
55
// +doc/default: 1
@@ -87,9 +110,9 @@ func (s *ArangoMLExtensionSpecDeployment) GetComponents() map[string]*ArangoMLEx
87
110
return nil
88
111
}
89
112
return map [string ]* ArangoMLExtensionSpecDeploymentComponent {
90
- "prediction" : s .GetPrediction (),
91
- "training" : s .GetTraining (),
92
- "project" : s .GetProject (),
113
+ ArangoMLExtensionSpecDeploymentComponentPrediction : s .GetPrediction (),
114
+ ArangoMLExtensionSpecDeploymentComponentTraining : s .GetTraining (),
115
+ ArangoMLExtensionSpecDeploymentComponentProject : s .GetProject (),
93
116
}
94
117
}
95
118
@@ -130,12 +153,22 @@ func (s *ArangoMLExtensionSpecDeployment) Validate() error {
130
153
var usedPorts util.List [int32 ]
131
154
for prefix , component := range s .GetComponents () {
132
155
err := component .Validate ()
133
- errs = append (errs , shared .PrefixResourceErrors (prefix , err ))
156
+ if err != nil {
157
+ errs = append (errs , shared .PrefixResourceErrors (prefix , err ))
158
+ continue
159
+ }
134
160
if err == nil {
135
- if usedPorts .IndexOf (component .GetPort ()) >= 0 {
136
- errs = append (errs , shared .PrefixResourceErrors (prefix , errors .Newf ("port %d already specified for other component" , component .GetPort ())))
161
+ port := component .GetPort (GetArangoMLExtensionSpecDeploymentComponentDefaultPort (prefix ))
162
+
163
+ if port == 0 {
164
+ errs = append (errs , shared .PrefixResourceErrors (prefix , errors .Newf ("port not defined" )))
165
+ continue
166
+ }
167
+
168
+ if usedPorts .IndexOf (port ) >= 0 {
169
+ errs = append (errs , shared .PrefixResourceErrors (prefix , errors .Newf ("port %d already specified for other component" , port )))
137
170
} else {
138
- usedPorts .Append (component . GetPort () )
171
+ usedPorts .Append (port )
139
172
}
140
173
}
141
174
}
0 commit comments