-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
62 lines (48 loc) · 1.24 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
xfnv1alpha1 "github.com/crossplane/crossplane/apis/apiextensions/fn/io/v1alpha1"
"sigs.k8s.io/yaml"
// redisV1 "github.com/vshn/component-appcat/apis/vshn/v1"
redisV1 "xfnTest/redis"
)
func main() {
funcIO := xfnv1alpha1.FunctionIO{}
x, err := ioutil.ReadAll(os.Stdin)
if err != nil {
log.Fatal(err)
}
err = yaml.Unmarshal(x, &funcIO)
if err != nil {
log.Fatal(err)
}
redisXR := &redisV1.VSHNRedis{}
err = json.Unmarshal(funcIO.Observed.Composite.Resource.Raw, redisXR)
if err != nil {
log.Fatal(err)
}
if _, ok := redisXR.GetAnnotations()["appcat.io/effectiveVersion"]; !ok {
if redisXR.ObjectMeta.Annotations == nil {
redisXR.ObjectMeta.Annotations = map[string]string{}
}
redisXR.ObjectMeta.Annotations["appcat.io/effectiveVersion"] = redisXR.Spec.Parameters.Service.Version
}
rawData, err := json.Marshal(redisXR)
if err != nil {
log.Fatal(err)
}
funcIO.Desired.Composite.Resource.Raw = rawData
funcIO.Results = append(funcIO.Results, xfnv1alpha1.Result{
Severity: xfnv1alpha1.SeverityNormal,
Message: "I was reconciled",
})
finalYaml, err := yaml.Marshal(funcIO)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(finalYaml))
}