-
Notifications
You must be signed in to change notification settings - Fork 33
/
app.go
50 lines (40 loc) · 1.58 KB
/
app.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
// SPDX-FileCopyrightText: 2020 SAP SE or an SAP affiliate company and Gardener contributors.
//
// SPDX-License-Identifier: Apache-2.0
package app
import (
"context"
"fmt"
"github.com/spf13/cobra"
lc "github.com/gardener/landscaper/controller-utils/pkg/logging/constants"
manifestctlr "github.com/gardener/landscaper/pkg/deployer/manifest"
"github.com/gardener/landscaper/pkg/version"
)
func NewManifestDeployerControllerCommand(ctx context.Context) *cobra.Command {
options := NewOptions()
cmd := &cobra.Command{
Use: "manifest-deployer",
Short: fmt.Sprintf("Manifest Deployer is a controller that applies kubernetes manifests based on DeployItems of type %s", manifestctlr.Type),
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if err := options.Complete(); err != nil {
return err
}
return options.run(ctx)
},
}
options.AddFlags(cmd.Flags())
return cmd
}
func (o *options) run(ctx context.Context) error {
o.DeployerOptions.Log.Info("Starting Manifest Deployer", lc.KeyVersion, version.Get().GitVersion)
if err := manifestctlr.AddDeployerToManager(
o.DeployerOptions.LsUncachedClient, o.DeployerOptions.LsCachedClient, o.DeployerOptions.HostUncachedClient, o.DeployerOptions.HostCachedClient,
o.DeployerOptions.FinishedObjectCache,
o.DeployerOptions.Log, o.DeployerOptions.LsMgr,
o.DeployerOptions.HostMgr, o.Config, "manifest"); err != nil {
return fmt.Errorf("unable to setup manifest controller")
}
o.DeployerOptions.Log.Info("Starting manifest deployer manager")
return o.DeployerOptions.StartManagers(ctx)
}