...
1 package flux
2
3 import (
4 "context"
5 _ "embed"
6
7 "k8s.io/apimachinery/pkg/api/errors"
8 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
9 "sigs.k8s.io/controller-runtime/pkg/client"
10
11 "edge-infra.dev/third_party/k8s/fluxcd"
12 )
13
14
15
16 func LoadManifests() ([]*unstructured.Unstructured, error) {
17 return fluxcd.LoadManifests()
18 }
19
20
21
22
23 func Install(ctx context.Context, c client.Client, manifests []*unstructured.Unstructured) error {
24
25 for _, manifest := range manifests {
26 if manifest.GetKind() == "Namespace" {
27 if err := c.Create(ctx, manifest); err != nil && !errors.IsAlreadyExists(err) {
28 return err
29 }
30 }
31 }
32
33 for _, manifest := range manifests {
34 if manifest.GetKind() != "Namespace" {
35 if err := c.Create(ctx, manifest); err != nil && !errors.IsAlreadyExists(err) {
36 return err
37 }
38 }
39 }
40
41 return nil
42 }
43
View as plain text