Skip to content

Commit

Permalink
support config work driver.
Browse files Browse the repository at this point in the history
Signed-off-by: morvencao <[email protected]>
  • Loading branch information
morvencao committed Mar 26, 2024
1 parent 52eef42 commit cd70817
Show file tree
Hide file tree
Showing 324 changed files with 24,055 additions and 3,501 deletions.
2 changes: 1 addition & 1 deletion cmd/example/busybox/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func main() {
if err != nil {
os.Exit(1)
}
addonMgr, err := addonmanager.New(kubeConfig)
addonMgr, err := addonmanager.New(kubeConfig, addonmanager.NewManagerOptions())
if err != nil {
klog.Errorf("unable to setup addon manager: %v", err)
os.Exit(1)
Expand Down
14 changes: 11 additions & 3 deletions cmd/example/helloworld/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,30 @@ func newCommand() *cobra.Command {
}

func newControllerCommand() *cobra.Command {
o := addonmanager.NewManagerOptions()
c := &addManagerConfig{managerOptions: o}
cmd := cmdfactory.
NewControllerCommandConfig("helloworld-addon-controller", version.Get(), runController).
NewControllerCommandConfig("helloworld-addon-controller", version.Get(), c.runController).
NewCommand()
cmd.Use = "controller"
cmd.Short = "Start the addon controller"
o.AddFlags(cmd)

return cmd
}

func runController(ctx context.Context, kubeConfig *rest.Config) error {
// addManagerConfig holds configuration for addon manager
type addManagerConfig struct {
managerOptions *addonmanager.ManagerOptions
}

func (c *addManagerConfig) runController(ctx context.Context, kubeConfig *rest.Config) error {
addonClient, err := addonv1alpha1client.NewForConfig(kubeConfig)
if err != nil {
return err
}

mgr, err := addonmanager.New(kubeConfig)
mgr, err := addonmanager.New(kubeConfig, c.managerOptions)
if err != nil {
return err
}
Expand Down
14 changes: 11 additions & 3 deletions cmd/example/helloworld_helm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,24 @@ func newCommand() *cobra.Command {
}

func newControllerCommand() *cobra.Command {
o := addonmanager.NewManagerOptions()
c := &addManagerConfig{managerOptions: o}
cmd := cmdfactory.
NewControllerCommandConfig("helloworldhelm-addon-controller", version.Get(), runController).
NewControllerCommandConfig("helloworldhelm-addon-controller", version.Get(), c.runController).
NewCommand()
cmd.Use = "controller"
cmd.Short = "Start the addon controller"
o.AddFlags(cmd)

return cmd
}

func runController(ctx context.Context, kubeConfig *rest.Config) error {
// addManagerConfig holds configuration for addon manager
type addManagerConfig struct {
managerOptions *addonmanager.ManagerOptions
}

func (c *addManagerConfig) runController(ctx context.Context, kubeConfig *rest.Config) error {
kubeClient, err := kubernetes.NewForConfig(kubeConfig)
if err != nil {
return err
Expand All @@ -89,7 +97,7 @@ func runController(ctx context.Context, kubeConfig *rest.Config) error {
return err
}

mgr, err := addonmanager.New(kubeConfig)
mgr, err := addonmanager.New(kubeConfig, c.managerOptions)
if err != nil {
klog.Errorf("failed to new addon manager %v", err)
return err
Expand Down
14 changes: 11 additions & 3 deletions cmd/example/helloworld_hosted/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,25 @@ func newCommand() *cobra.Command {
}

func newControllerCommand() *cobra.Command {
o := addonmanager.NewManagerOptions()
c := &addManagerConfig{managerOptions: o}
cmd := cmdfactory.
NewControllerCommandConfig("helloworld-addon-controller", version.Get(), runController).
NewControllerCommandConfig("helloworld-addon-controller", version.Get(), c.runController).
NewCommand()
cmd.Use = "controller"
cmd.Short = "Start the addon controller"
o.AddFlags(cmd)

return cmd
}

func runController(ctx context.Context, kubeConfig *rest.Config) error {
mgr, err := addonmanager.New(kubeConfig)
// addManagerConfig holds configuration for addon manager
type addManagerConfig struct {
managerOptions *addonmanager.ManagerOptions
}

func (c *addManagerConfig) runController(ctx context.Context, kubeConfig *rest.Config) error {
mgr, err := addonmanager.New(kubeConfig, c.managerOptions)
if err != nil {
return err
}
Expand Down
43 changes: 23 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ require (
github.com/evanphx/json-patch v5.7.0+incompatible
github.com/fatih/structs v1.1.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.30.0
github.com/openshift/build-machinery-go v0.0.0-20230306181456-d321ffa04533
github.com/onsi/gomega v1.31.1
github.com/openshift/build-machinery-go v0.0.0-20231128094528-1e9b1b0595c8
github.com/openshift/library-go v0.0.0-20240116081341-964bcb3f545c
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
helm.sh/helm/v3 v3.14.2
k8s.io/api v0.29.1
k8s.io/api v0.29.2
k8s.io/apiextensions-apiserver v0.29.0
k8s.io/apimachinery v0.29.1
k8s.io/apimachinery v0.29.2
k8s.io/apiserver v0.29.0
k8s.io/client-go v0.29.1
k8s.io/client-go v0.29.2
k8s.io/component-base v0.29.1
k8s.io/klog/v2 v2.110.1
k8s.io/utils v0.0.0-20240102154912-e7106e64919e
k8s.io/klog/v2 v2.120.1
k8s.io/utils v0.0.0-20240310230437-4693a0247e57
open-cluster-management.io/api v0.13.0
open-cluster-management.io/sdk-go v0.13.0
open-cluster-management.io/sdk-go v0.13.1-0.20240321032811-7dbdd1b5c63d
sigs.k8s.io/controller-runtime v0.17.2
)

Expand All @@ -38,10 +38,13 @@ require (
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cloudevents/sdk-go/protocol/mqtt_paho/v2 v2.0.0-20231030012137-0836a524e995 // indirect
github.com/cloudevents/sdk-go/v2 v2.14.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/eclipse/paho.golang v0.11.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
Expand All @@ -59,7 +62,7 @@ require (
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
Expand Down Expand Up @@ -101,20 +104,20 @@ require (
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/term v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
google.golang.org/grpc v1.58.3 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/grpc v1.62.1 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
Expand Down
Loading

0 comments on commit cd70817

Please sign in to comment.