Skip to content

Commit

Permalink
address comments.
Browse files Browse the repository at this point in the history
Signed-off-by: morvencao <[email protected]>
  • Loading branch information
morvencao committed Apr 18, 2024
1 parent 7ad6107 commit a7bac3b
Show file tree
Hide file tree
Showing 24 changed files with 34 additions and 952 deletions.
12 changes: 0 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ verify: verify-gocilint
deploy-ocm:
examples/deploy/ocm/install.sh

deploy-ocm-cloudevents:
examples/deploy/ocm-cloudevents/install.sh

deploy-hosted-ocm:
examples/deploy/hosted-ocm/install.sh

Expand All @@ -74,12 +71,6 @@ deploy-helloworld: ensure-kustomize
$(KUSTOMIZE) build examples/deploy/addon/helloworld | $(KUBECTL) apply -f -
mv examples/deploy/addon/helloworld/kustomization.yaml.tmp examples/deploy/addon/helloworld/kustomization.yaml

deploy-helloworld-cloudevents: ensure-kustomize
cp examples/deploy/addon/helloworld-cloudevents/kustomization.yaml examples/deploy/addon/helloworld-cloudevents/kustomization.yaml.tmp
cd examples/deploy/addon/helloworld-cloudevents && ../../../../$(KUSTOMIZE) edit set image quay.io/open-cluster-management/addon-examples=$(EXAMPLE_IMAGE_NAME)
$(KUSTOMIZE) build examples/deploy/addon/helloworld-cloudevents | $(KUBECTL) apply -f -
mv examples/deploy/addon/helloworld-cloudevents/kustomization.yaml.tmp examples/deploy/addon/helloworld-cloudevents/kustomization.yaml

deploy-helloworld-helm: ensure-kustomize
cp examples/deploy/addon/helloworld-helm/kustomization.yaml examples/deploy/addon/helloworld-helm/kustomization.yaml.tmp
cd examples/deploy/addon/helloworld-helm && ../../../../$(KUSTOMIZE) edit set image quay.io/open-cluster-management/addon-examples=$(EXAMPLE_IMAGE_NAME)
Expand Down Expand Up @@ -120,9 +111,6 @@ undeploy-busybox: ensure-kustomize
undeploy-helloworld: ensure-kustomize
$(KUSTOMIZE) build examples/deploy/addon/helloworld | $(KUBECTL) delete --ignore-not-found -f -

undeploy-helloworld-cloudevents: ensure-kustomize
$(KUSTOMIZE) build examples/deploy/addon/helloworld-cloudevents | $(KUBECTL) delete --ignore-not-found -f -

undeploy-helloworld-helm: ensure-kustomize
$(KUSTOMIZE) build examples/deploy/addon/helloworld-helm | $(KUBECTL) delete --ignore-not-found -f -

Expand Down
1 change: 0 additions & 1 deletion build/Dockerfile.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ RUN make build --warn-undefined-variables
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
COPY --from=builder /go/src/open-cluster-management.io/addon-framework/busybox /
COPY --from=builder /go/src/open-cluster-management.io/addon-framework/helloworld /
COPY --from=builder /go/src/open-cluster-management.io/addon-framework/helloworld_cloudevents /
COPY --from=builder /go/src/open-cluster-management.io/addon-framework/helloworld_helm /
COPY --from=builder /go/src/open-cluster-management.io/addon-framework/helloworld_hosted /

27 changes: 22 additions & 5 deletions cmd/example/helloworld/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"open-cluster-management.io/addon-framework/examples/helloworld_agent"
"open-cluster-management.io/addon-framework/pkg/addonfactory"
"open-cluster-management.io/addon-framework/pkg/addonmanager"
"open-cluster-management.io/addon-framework/pkg/addonmanager/cloudevents"
cmdfactory "open-cluster-management.io/addon-framework/pkg/cmd/factory"
"open-cluster-management.io/addon-framework/pkg/utils"
"open-cluster-management.io/addon-framework/pkg/version"
Expand Down Expand Up @@ -66,24 +67,40 @@ func newCommand() *cobra.Command {
}

func newControllerCommand() *cobra.Command {
o := cloudevents.NewCloudEventsOptions()
c := &addManagerConfig{cloudeventsOptions: 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 cloudevents configuration for addon manager
type addManagerConfig struct {
cloudeventsOptions *cloudevents.CloudEventsOptions
}

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)
if err != nil {
return err
var mgr addonmanager.AddonManager
if c.cloudeventsOptions.WorkDriver == "kube" {
mgr, err = addonmanager.New(kubeConfig)
if err != nil {
return err
}
} else {
mgr, err = cloudevents.New(kubeConfig, c.cloudeventsOptions)
if err != nil {
return err
}
}

registrationOption := helloworld.NewRegistrationOption(
Expand Down
145 changes: 0 additions & 145 deletions cmd/example/helloworld_cloudevents/main.go

This file was deleted.

28 changes: 0 additions & 28 deletions examples/deploy/addon/helloworld-cloudevents/kustomization.yaml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit a7bac3b

Please sign in to comment.