|
| 1 | +/* |
| 2 | + * Copyright 2019 Project OpenUBL, Inc. and/or its affiliates |
| 3 | + * and other contributors as indicated by the @author tags. |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | +@Grab('org.yaml:snakeyaml:1.33') |
| 18 | +import org.yaml.snakeyaml.* |
| 19 | +import groovy.yaml.* |
| 20 | + |
| 21 | +def file = new File(this.args[0]) |
| 22 | +def version = this.args[1] |
| 23 | + |
| 24 | +def fileReader = new FileReader(file) |
| 25 | +def yaml = new Yaml().load(fileReader) |
| 26 | + |
| 27 | +yaml.metadata.name = 'ublhub-operator.v' + version |
| 28 | +yaml.spec.annotations.containerImage = 'quay.io/projectopenubl/ublhub-operator:v' + version |
| 29 | +yaml.spec.install.spec.deployments[0].spec.template.spec.containers[0].image = 'quay.io/projectopenubl/ublhub-operator:v' + version |
| 30 | +yaml.spec.version = version |
| 31 | +yaml.spec.customresourcedefinitions.owned[0].displayName = 'Ublhub' |
| 32 | +yaml.spec.customresourcedefinitions.owned[0].description = 'Ublhub' |
| 33 | + |
| 34 | +// Workaround for moving annotations since OperatorHub.io complains about it |
| 35 | +yaml.metadata.annotations = yaml.spec.annotations |
| 36 | +yaml.spec.annotations = "" |
| 37 | + |
| 38 | +DumperOptions options = new DumperOptions(); |
| 39 | +options.indent = 2 |
| 40 | +options.defaultFlowStyle = DumperOptions.FlowStyle.BLOCK |
| 41 | +options.defaultScalarStyle = DumperOptions.ScalarStyle.PLAIN |
| 42 | +options.prettyFlow = true |
| 43 | + |
| 44 | +new Yaml(options).dump(yaml, new FileWriter(file)) |
0 commit comments