github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/cmd/orbctl/cmds/deploy.go (about) 1 package cmds 2 3 import ( 4 "fmt" 5 6 boomapi "github.com/caos/orbos/internal/operator/boom/api" 7 "github.com/caos/orbos/internal/operator/boom/api/latest" 8 cmdboom "github.com/caos/orbos/internal/operator/boom/cmd" 9 orbnw "github.com/caos/orbos/internal/operator/networking/kinds/orb" 10 "github.com/caos/orbos/mntr" 11 "github.com/caos/orbos/pkg/git" 12 "github.com/caos/orbos/pkg/kubernetes" 13 "github.com/caos/orbos/pkg/labels" 14 ) 15 16 func deployBoom(monitor mntr.Monitor, gitClient *git.Client, k8sClient kubernetes.ClientInt, binaryVersion string, gitops bool) error { 17 18 if gitops { 19 if !gitClient.Exists(git.BoomFile) { 20 monitor.Info(fmt.Sprintf("Deployment of BOOM skipped as %s not found in git repo", git.BoomFile)) 21 return nil 22 } 23 desiredTree, err := gitClient.ReadTree(git.BoomFile) 24 if err != nil { 25 return err 26 } 27 28 // TODO: Parse toolset in cmdboom.Reconcile function (see deployDatabase, deployNetworking) 29 desiredKind, _, apiKind, apiVersion, err := boomapi.ParseToolset(desiredTree) 30 if err != nil { 31 return err 32 } 33 34 if desiredKind != nil && 35 desiredKind.Spec != nil && 36 desiredKind.Spec.Boom != nil && 37 desiredKind.Spec.Boom.Version != "" { 38 binaryVersion = desiredKind.Spec.Boom.Version 39 } 40 41 if err := cmdboom.Reconcile( 42 monitor, 43 labels.MustForAPI(labels.MustForOperator("ORBOS", "boom.caos.ch", binaryVersion), apiKind, apiVersion), 44 k8sClient, 45 desiredKind.Spec.Boom, 46 binaryVersion, 47 gitops, 48 ); err != nil { 49 return err 50 } 51 } else { 52 boom := &latest.Boom{ 53 Version: binaryVersion, 54 SelfReconciling: true, 55 } 56 57 if err := cmdboom.Reconcile( 58 monitor, 59 labels.MustForAPI(labels.MustForOperator("ORBOS", "boom.caos.ch", binaryVersion), "BOOM", "v1"), 60 k8sClient, 61 boom, 62 binaryVersion, 63 gitops, 64 ); err != nil { 65 return err 66 } 67 } 68 return nil 69 } 70 71 func deployNetworking(monitor mntr.Monitor, gitClient *git.Client, k8sClient kubernetes.ClientInt, version string, gitops bool) error { 72 if gitops { 73 if !gitClient.Exists(git.NetworkingFile) { 74 monitor.Info(fmt.Sprintf("Deployment of networking operator skipped as %s not found in git repo", git.NetworkingFile)) 75 return nil 76 } 77 78 desiredTree, err := gitClient.ReadTree(git.NetworkingFile) 79 if err != nil { 80 return err 81 } 82 desired, err := orbnw.ParseDesiredV0(desiredTree) 83 if err != nil { 84 return err 85 } 86 spec := desired.Spec 87 88 // at takeoff the artifacts have to be applied 89 spec.SelfReconciling = true 90 if err := orbnw.Reconcile( 91 monitor, 92 spec, 93 gitops, 94 )(k8sClient); err != nil { 95 return err 96 } 97 } else { 98 // at takeoff the artifacts have to be applied 99 spec := &orbnw.Spec{ 100 Version: version, 101 SelfReconciling: true, 102 } 103 104 if err := orbnw.Reconcile( 105 monitor, 106 spec, 107 gitops, 108 )(k8sClient); err != nil { 109 return err 110 } 111 } 112 return nil 113 }