-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.go
52 lines (43 loc) · 1.45 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
// Copyright 2022 Namespace Labs Inc; All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package main
import (
"context"
"fmt"
"namespacelabs.dev/foundation/framework/provisioning"
"namespacelabs.dev/foundation/internal/fnerrors"
helmc "namespacelabs.dev/foundation/internal/runtime/kubernetes/helm"
"namespacelabs.dev/foundation/library/kubernetes/helm"
"namespacelabs.dev/foundation/schema"
"namespacelabs.dev/foundation/std/execution/defs"
)
func main() {
h := provisioning.NewHandlers()
henv := h.MatchEnv(&schema.Environment{Runtime: "kubernetes"})
henv.HandleApply(func(ctx context.Context, req provisioning.StackRequest, out *provisioning.ApplyOutput) error {
intent := &helm.HelmReleaseIntent{}
if err := req.UnpackInput(intent); err != nil {
return err
}
if intent.Chart == nil {
return fnerrors.New("chart is required")
}
install := &helmc.OpHelmInstall{
ChartArchiveBlob: &helmc.Blob{
Inline: intent.Chart.Contents,
},
Namespace: intent.Namespace,
ReleaseName: intent.ReleaseName,
}
if intent.Values != nil {
install.Values = &helmc.JsonBlob{
Inline: intent.Values.InlineJson,
}
}
out.Invocations = append(out.Invocations, defs.Static(fmt.Sprintf("Helm Release %q", intent.ReleaseName), install))
out.OutputResourceInstance = &helm.HelmReleaseInstance{}
return nil
})
provisioning.Handle(h)
}