4
4
import io .apicurio .registry .operator .Configuration ;
5
5
import io .apicurio .registry .operator .OperatorException ;
6
6
import io .apicurio .registry .operator .api .v1 .ApicurioRegistry3 ;
7
+ import io .apicurio .registry .operator .api .v1 .ApicurioRegistry3Spec ;
8
+ import io .apicurio .registry .operator .api .v1 .spec .AppSpec ;
9
+ import io .apicurio .registry .operator .api .v1 .spec .StudioUiSpec ;
10
+ import io .apicurio .registry .operator .api .v1 .spec .UiSpec ;
7
11
import io .fabric8 .kubernetes .api .model .*;
8
12
import io .fabric8 .kubernetes .api .model .apps .Deployment ;
9
13
import io .fabric8 .kubernetes .api .model .apps .DeploymentSpec ;
16
20
import java .util .List ;
17
21
import java .util .Map ;
18
22
23
+ import static io .apicurio .registry .operator .api .v1 .ContainerNames .*;
19
24
import static io .apicurio .registry .operator .resource .app .AppDeploymentResource .getContainerFromPodTemplateSpec ;
20
25
import static io .apicurio .registry .operator .utils .Mapper .YAML_MAPPER ;
21
26
import static io .apicurio .registry .operator .utils .Utils .isBlank ;
27
+ import static java .util .Optional .ofNullable ;
22
28
23
29
public class ResourceFactory {
24
30
@@ -34,17 +40,14 @@ public class ResourceFactory {
34
40
public static final String RESOURCE_TYPE_SERVICE = "service" ;
35
41
public static final String RESOURCE_TYPE_INGRESS = "ingress" ;
36
42
37
- public static final String APP_CONTAINER_NAME = "apicurio-registry-app" ;
38
- public static final String UI_CONTAINER_NAME = "apicurio-registry-ui" ;
39
- public static final String STUDIO_UI_CONTAINER_NAME = "apicurio-studio-ui" ;
40
-
41
43
public Deployment getDefaultAppDeployment (ApicurioRegistry3 primary ) {
42
- var r = initDefaultDeployment (primary , COMPONENT_APP , 1 ,
43
- primary .getSpec ().getApp ().getPodTemplateSpec ()); // TODO: Replicas
44
+ var r = initDefaultDeployment (primary , COMPONENT_APP , 1 , ofNullable (primary .getSpec ())
45
+ .map (ApicurioRegistry3Spec ::getApp ).map (AppSpec ::getPodTemplateSpec ).orElse (null )); // TODO:
46
+ // Replicas
44
47
mergeDeploymentPodTemplateSpec (
45
48
// spotless:off
46
49
r .getSpec ().getTemplate (),
47
- APP_CONTAINER_NAME ,
50
+ REGISTRY_APP_CONTAINER_NAME ,
48
51
Configuration .getAppImage (),
49
52
List .of (new ContainerPortBuilder ().withName ("http" ).withProtocol ("TCP" ).withContainerPort (8080 ).build ()),
50
53
new ProbeBuilder ().withHttpGet (new HTTPGetActionBuilder ().withPath ("/health/ready" ).withPort (new IntOrString (8080 )).withScheme ("HTTP" ).build ()).build (),
@@ -60,12 +63,13 @@ public Deployment getDefaultAppDeployment(ApicurioRegistry3 primary) {
60
63
}
61
64
62
65
public Deployment getDefaultUIDeployment (ApicurioRegistry3 primary ) {
63
- var r = initDefaultDeployment (primary , COMPONENT_UI , 1 ,
64
- primary .getSpec ().getUi ().getPodTemplateSpec ()); // TODO: Replicas
66
+ var r = initDefaultDeployment (primary , COMPONENT_UI , 1 , ofNullable (primary .getSpec ())
67
+ .map (ApicurioRegistry3Spec ::getUi ).map (UiSpec ::getPodTemplateSpec ).orElse (null )); // TODO:
68
+ // Replicas
65
69
mergeDeploymentPodTemplateSpec (
66
70
// spotless:off
67
71
r .getSpec ().getTemplate (),
68
- UI_CONTAINER_NAME ,
72
+ REGISTRY_UI_CONTAINER_NAME ,
69
73
Configuration .getUIImage (),
70
74
List .of (new ContainerPortBuilder ().withName ("http" ).withProtocol ("TCP" ).withContainerPort (8080 ).build ()),
71
75
new ProbeBuilder ().withHttpGet (new HTTPGetActionBuilder ().withPath ("/config.js" ).withPort (new IntOrString (8080 )).withScheme ("HTTP" ).build ()).build (),
@@ -81,8 +85,9 @@ public Deployment getDefaultUIDeployment(ApicurioRegistry3 primary) {
81
85
}
82
86
83
87
public Deployment getDefaultStudioUIDeployment (ApicurioRegistry3 primary ) {
84
- var r = initDefaultDeployment (primary , COMPONENT_STUDIO_UI , 1 ,
85
- primary .getSpec ().getStudioUi ().getPodTemplateSpec ()); // TODO: Replicas
88
+ var r = initDefaultDeployment (primary , COMPONENT_STUDIO_UI , 1 , ofNullable (primary .getSpec ())
89
+ .map (ApicurioRegistry3Spec ::getStudioUi ).map (StudioUiSpec ::getPodTemplateSpec ).orElse (null )); // TODO:
90
+ // Replicas
86
91
mergeDeploymentPodTemplateSpec (
87
92
// spotless:off
88
93
r .getSpec ().getTemplate (),
0 commit comments