Files
Yuan TangandGitHub a0e8622ea6 feat: Provide minimal distribution of CRDs (#3492)
* Provide full

Signed-off-by: Yuan Tang <[email protected]>

* Move to cmd directory

Signed-off-by: Yuan Tang <[email protected]>

* Add helm charts

Signed-off-by: Yuan Tang <[email protected]>

* regen

Signed-off-by: Yuan Tang <[email protected]>

* fix conflict

Signed-off-by: Yuan Tang <[email protected]>

* rebase

Signed-off-by: Yuan Tang <[email protected]>

* remove unused

Signed-off-by: Yuan Tang <[email protected]>

* remove redundant files

Signed-off-by: Yuan Tang <[email protected]>

* Empty-Commit

Signed-off-by: Yuan Tang <[email protected]>

* Rename file

Signed-off-by: Yuan Tang <[email protected]>

---------

Signed-off-by: Yuan Tang <[email protected]>
2024-04-21 08:08:14 -04:00

65 lines
1.5 KiB
Go

/*
Copyright 2023 The KServe Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"os"
"path/filepath"
"sigs.k8s.io/yaml"
)
type obj = map[string]interface{}
func removeCRDValidation(filename string) {
data, err := os.ReadFile(filepath.Clean(filename))
if err != nil {
panic(err)
}
crd := make(obj)
err = yaml.Unmarshal(data, &crd)
if err != nil {
panic(err)
}
spec := crd["spec"].(obj)
versions := spec["versions"].([]interface{})
version := versions[0].(obj)
properties := version["schema"].(obj)["openAPIV3Schema"].(obj)["properties"].(obj)
for k := range properties {
if k == "spec" || k == "status" {
properties[k] = obj{"type": "object", "x-kubernetes-preserve-unknown-fields": true, "x-kubernetes-map-type": "atomic"}
}
}
data, err = yaml.Marshal(crd)
if err != nil {
panic(err)
}
err = os.WriteFile(filename, data, 0o600)
if err != nil {
panic(err)
}
}
func main() {
switch os.Args[1] {
case "removecrdvalidation":
removeCRDValidation(os.Args[2])
default:
panic(os.Args[1])
}
}