@@ -23,7 +23,6 @@ import (
23
23
"path/filepath"
24
24
"strings"
25
25
"sync"
26
- "unicode"
27
26
28
27
"github.com/operator-framework/operator-sdk/internal/pkg/scaffold"
29
28
"github.com/operator-framework/operator-sdk/internal/pkg/scaffold/input"
@@ -138,7 +137,7 @@ func (s *CSV) CustomRender() ([]byte, error) {
138
137
}
139
138
}
140
139
141
- return k8sutil .GetObjectBytes (csv )
140
+ return k8sutil .GetObjectBytes (csv , yaml . Marshal )
142
141
}
143
142
144
143
func (s * CSV ) getBaseCSVIfExists () (* olmapiv1alpha1.ClusterServiceVersion , bool , error ) {
@@ -190,41 +189,6 @@ func (s *CSV) getCSVPath(ver string) string {
190
189
return filepath .Join (s .pathPrefix , OLMCatalogDir , lowerProjName , ver , name )
191
190
}
192
191
193
- // getDisplayName turns a project dir name in any of {snake, chain, camel}
194
- // cases, hierarchical dot structure, or space-delimited into a
195
- // space-delimited, title'd display name.
196
- // Ex. "another-_AppOperator_againTwiceThrice More"
197
- // -> "Another App Operator Again Twice Thrice More"
198
- func getDisplayName (name string ) string {
199
- for _ , sep := range ".-_ " {
200
- splitName := strings .Split (name , string (sep ))
201
- for i := 0 ; i < len (splitName ); i ++ {
202
- if splitName [i ] == "" {
203
- splitName = append (splitName [:i ], splitName [i + 1 :]... )
204
- i --
205
- } else {
206
- splitName [i ] = strings .TrimSpace (splitName [i ])
207
- }
208
- }
209
- name = strings .Join (splitName , " " )
210
- }
211
- splitName := strings .Split (name , " " )
212
- for i , word := range splitName {
213
- temp := word
214
- o := 0
215
- for j , r := range word {
216
- if unicode .IsUpper (r ) {
217
- if j > 0 && ! unicode .IsUpper (rune (word [j - 1 ])) {
218
- temp = temp [0 :j + o ] + " " + temp [j + o :len (temp )]
219
- o ++
220
- }
221
- }
222
- }
223
- splitName [i ] = temp
224
- }
225
- return strings .TrimSpace (strings .Title (strings .Join (splitName , " " )))
226
- }
227
-
228
192
// initCSVFields initializes all csv fields that should be populated by a user
229
193
// with sane defaults. initCSVFields should only be called for new csv's.
230
194
func (s * CSV ) initCSVFields (csv * olmapiv1alpha1.ClusterServiceVersion ) {
@@ -237,7 +201,7 @@ func (s *CSV) initCSVFields(csv *olmapiv1alpha1.ClusterServiceVersion) {
237
201
238
202
// Spec fields
239
203
csv .Spec .Version = * semver .New (s .CSVVersion )
240
- csv .Spec .DisplayName = getDisplayName (s .OperatorName )
204
+ csv .Spec .DisplayName = k8sutil . GetDisplayName (s .OperatorName )
241
205
csv .Spec .Description = "Placeholder description"
242
206
csv .Spec .Maturity = "alpha"
243
207
csv .Spec .Provider = olmapiv1alpha1.AppLink {}
@@ -371,7 +335,7 @@ func (s *CSV) updateCSVFromManifestFiles(cfg *CSVConfig, csv *olmapiv1alpha1.Clu
371
335
scanner := yamlutil .NewYAMLScanner (yamlData )
372
336
for scanner .Scan () {
373
337
yamlSpec := scanner .Bytes ()
374
- kind , err := getKindfromYAML (yamlSpec )
338
+ kind , err := k8sutil . GetKindfromYAML (yamlSpec )
375
339
if err != nil {
376
340
return fmt .Errorf ("%s: %v" , f , err )
377
341
}
0 commit comments