mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-14 18:10:21 +00:00
Feat: remove unused crd in chart (#5899)
* Feat: remove unused crd in chart Signed-off-by: Somefive <yd219913@alibaba-inc.com> * fix test Signed-off-by: Somefive <yd219913@alibaba-inc.com> --------- Signed-off-by: Somefive <yd219913@alibaba-inc.com>
This commit is contained in:
@@ -25,24 +25,22 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
oldCRD = map[string]bool{"components": true, "applicationconfigurations": true}
|
||||
// when controller need to run in runtime cluster, just add them in this map, key=crdName, value=subPath
|
||||
runtimeCRD = map[string]string{"rollouts": "rollout"}
|
||||
minimalCRD = map[string]bool{"applicationrevisions": true, "applications": true, "definitionrevisions": true, "healthscopes": true,
|
||||
"policydefinitions": true, "resourcetrackers": true, "scopedefinitions": true, "traitdefinitions": true, "workflowstepdefinitions": true,
|
||||
"workloaddefinitions": true, "rollouts": true}
|
||||
oldCRD = map[string]bool{
|
||||
"components": true,
|
||||
"applicationconfigurations": true,
|
||||
"scopedefinitions": true,
|
||||
"rollouts": true,
|
||||
"healthscopes": true,
|
||||
"workloaddefinitions": true,
|
||||
}
|
||||
)
|
||||
|
||||
func main() {
|
||||
var dir string
|
||||
var newDir string
|
||||
var minimalDir string
|
||||
var runtimeDir string
|
||||
if len(os.Args) > 2 {
|
||||
dir = os.Args[1]
|
||||
newDir = os.Args[2]
|
||||
runtimeDir = os.Args[3]
|
||||
minimalDir = os.Args[4]
|
||||
} else {
|
||||
log.Fatal(fmt.Errorf("not enough args"))
|
||||
}
|
||||
@@ -55,22 +53,6 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
writeMinimal := func(fileName string, data []byte) {
|
||||
pathMinimal := fmt.Sprintf("%s/%s", minimalDir, fileName)
|
||||
/* #nosec */
|
||||
if err := os.WriteFile(pathMinimal, data, 0644); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
writeRuntime := func(subPath, fileName string, data []byte) {
|
||||
pathRuntime := fmt.Sprintf("%s/%s/charts/crds/%s", runtimeDir, subPath, fileName)
|
||||
/* #nosec */
|
||||
if err := os.WriteFile(pathRuntime, data, 0644); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
err := filepath.Walk(dir, func(path string, info os.FileInfo, _ error) error {
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
@@ -85,12 +67,6 @@ func main() {
|
||||
if oldCRD[resourceName] {
|
||||
return nil
|
||||
}
|
||||
if minimalCRD[resourceName] {
|
||||
writeMinimal(info.Name(), data)
|
||||
}
|
||||
if subPath, exist := runtimeCRD[resourceName]; exist {
|
||||
writeRuntime(subPath, info.Name(), data)
|
||||
}
|
||||
writeNew(info.Name(), data)
|
||||
return nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user