@@ -114,14 +114,27 @@ var (
114
114
"jenkins pipeline persistent" : "examples/jenkins/jenkins-persistent-template.json" ,
115
115
"sample pipeline" : "examples/jenkins/pipeline/samplepipeline.yaml" ,
116
116
}
117
- // serviceCatalogTemplateLocations are templates that will be registered in an internal namespace
118
- // when the service catalog is requested
119
- serviceCatalogTemplateLocations = map [string ]string {
117
+ // internalTemplateLocations are templates that will be registered in an internal namespace
118
+ // when the service catalog is requested. These templates are compatible with both vN and vN-1
119
+ // clusters. If they are not, they should be moved into the internalCurrent and internalPrevious maps.
120
+ internalTemplateLocations = map [string ]string {
120
121
"service catalog" : "examples/service-catalog/service-catalog.yaml" ,
121
- "template service broker apiserver" : "install/templateservicebroker/apiserver-template.yaml" ,
122
122
"template service broker rbac" : "install/templateservicebroker/rbac-template.yaml" ,
123
123
"template service broker registration" : "install/service-catalog-broker-resources/template-service-broker-registration.yaml" ,
124
124
}
125
+ // internalCurrentTemplateLocations are templates that will be registered in an internal namespace
126
+ // when the service catalog is requested. These templates are for the current version of openshift
127
+ // (vN), for when the client version matches the cluster version.
128
+ internalCurrentTemplateLocations = map [string ]string {
129
+ "template service broker apiserver" : "install/templateservicebroker/apiserver-template.yaml" ,
130
+ }
131
+ // internalPreviousTemplateLocations are templates that will be registered in an internal namespace
132
+ // when the service catalog is requested, these templates are for the previous version of openshift
133
+ // (vN-1) to provide N-1 support for older clusters from a newer client.
134
+ internalPreviousTemplateLocations = map [string ]string {
135
+ "template service broker apiserver" : "install/templateservicebroker/previous/apiserver-template.yaml" ,
136
+ }
137
+
125
138
// loggingTemplateLocations are templates that will be registered in an internal namespace
126
139
// when logging is requested
127
140
loggingTemplateLocations = map [string ]string {
@@ -411,9 +424,7 @@ func (c *ClientStartConfig) Complete(f *osclientcmd.Factory, cmd *cobra.Command)
411
424
c .addTask (conditionalTask ("Importing templates" , c .ImportTemplates , c .ShouldInitializeData ))
412
425
413
426
// Import catalog templates
414
- c .addTask (conditionalTask ("Importing service catalog templates" , c .ImportServiceCatalogTemplates , func () bool {
415
- return c .ShouldInstallServiceCatalog && c .ShouldInitializeData ()
416
- }))
427
+ c .addTask (conditionalTask ("Importing internal catalog templates" , c .ImportInternalTemplates , c .ShouldInitializeData ))
417
428
418
429
// Import logging templates
419
430
c .addTask (conditionalTask ("Importing logging templates" , c .ImportLoggingTemplates , func () bool {
@@ -989,11 +1000,24 @@ func (c *ClientStartConfig) ImportTemplates(out io.Writer) error {
989
1000
return nil
990
1001
}
991
1002
992
- // ImportServiceCatalogTemplates imports service catalog templates into the server
993
- func (c * ClientStartConfig ) ImportServiceCatalogTemplates (out io.Writer ) error {
994
- if err := c .importObjects (out , openshift .OpenshiftInfraNamespace , serviceCatalogTemplateLocations ); err != nil {
1003
+ // ImportInternalTemplates imports internal system templates into the server
1004
+ func (c * ClientStartConfig ) ImportInternalTemplates (out io.Writer ) error {
1005
+ if err := c .importObjects (out , openshift .OpenshiftInfraNamespace , internalTemplateLocations ); err != nil {
1006
+ return err
1007
+ }
1008
+ version , err := c .OpenShiftHelper ().ServerVersion ()
1009
+ if err != nil {
995
1010
return err
996
1011
}
1012
+ if shouldImportCurrentTemplates (version ) {
1013
+ if err := c .importObjects (out , openshift .OpenshiftInfraNamespace , internalCurrentTemplateLocations ); err != nil {
1014
+ return err
1015
+ }
1016
+ } else {
1017
+ if err := c .importObjects (out , openshift .OpenshiftInfraNamespace , internalPreviousTemplateLocations ); err != nil {
1018
+ return err
1019
+ }
1020
+ }
997
1021
return nil
998
1022
}
999
1023
@@ -1009,6 +1033,10 @@ func shouldImportAdminTemplates(v semver.Version) bool {
1009
1033
return v .GTE (openshiftVersion36 )
1010
1034
}
1011
1035
1036
+ func shouldImportCurrentTemplates (v semver.Version ) bool {
1037
+ return v .GT (openshiftVersion37 )
1038
+ }
1039
+
1012
1040
func useAnsible (v semver.Version ) bool {
1013
1041
return v .GTE (openshiftVersion36 )
1014
1042
}
0 commit comments