Skip to content

Commit

Permalink
update common labels to not federate things blocked by webhook
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Lamarre <[email protected]>
  • Loading branch information
alexandreLamarre committed May 15, 2024
1 parent 81149c6 commit 87a4a9a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 2 additions & 0 deletions dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
_ "github.com/rancher/wrangler/pkg/generated/controllers/apiextensions.k8s.io"
_ "github.com/rancher/wrangler/pkg/generated/controllers/networking.k8s.io"
"github.com/rancher/wrangler/pkg/kubeconfig"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -45,6 +46,7 @@ func (o *DummyOperator) Run(cmd *cobra.Command, _ []string) error {
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
logrus.SetReportCaller(true)
debugConfig.MustSetupDebug()

cfg := kubeconfig.GetNonInteractiveClientConfig(o.Kubeconfig)
Expand Down
7 changes: 4 additions & 3 deletions pkg/controllers/common/operatorlabels.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ func GetCommonLabels(projectID string) map[string]string {
labels := map[string]string{
HelmProjectOperatedLabel: "true",
}
if len(projectID) != 0 {
labels[HelmProjectOperatorProjectLabel] = projectID
}
// FIXME: this causes webhook to reject it
// if len(projectID) != 0 {
// labels[HelmProjectOperatorProjectLabel] = projectID
// }
return labels
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/controllers/namespace/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ func Register(
// Single Namespace Handler

func (h *handler) OnSingleNamespaceChange(_ /*name*/ string, namespace *corev1.Namespace) (*corev1.Namespace, error) {
// TODO : figure out how to handle this edgecase
if namespace == nil {
// namespace has been deleted
return namespace, nil
}
if namespace.Name != h.systemNamespace {
// enqueue system namespace to ensure that rolebindings are updated

Expand Down
3 changes: 1 addition & 2 deletions pkg/controllers/namespace/reconcilers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ func (h *handler) addReconcilers(apply apply.Apply, dynamic dynamic.Interface) a
NamespaceableResourceInterface: dynamic.Resource(corev1.SchemeGroupVersion.WithResource("configmaps")),
}
apply = apply.WithReconciler(corev1.SchemeGroupVersion.WithKind("ConfigMap"), r.deleteAndReplace)

logrus.Infof("Adding reconcilers on the apply object %s", apply)
logrus.Debugf("Adding reconcilers on the apply object %s", apply)
return apply
}

Expand Down
5 changes: 3 additions & 2 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ cd $(dirname $0)/..
./scripts/build-chart

mkdir -p bin
GO_BUILD_FLAGS="-gcflags=all=-trimpath=${GOPATH} -asmflags all=-trimpath=${GOPATH}"
if [ "$(uname)" = "Linux" ]; then
OTHER_LINKFLAGS="-extldflags -static -s"
OTHER_LINKFLAGS="-extldflags -static -s -w"
fi
LINKFLAGS="-X github.com/rancher/helm-project-operator/pkg/version.Version=$VERSION"
LINKFLAGS="-X github.com/rancher/helm-project-operator/pkg/version.GitCommit=$COMMIT $LINKFLAGS"
CGO_ENABLED=0 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/helm-project-operator
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/helm-project-operator
if [ "$CROSS" = "true" ] && [ "$ARCH" = "amd64" ]; then
GOOS=darwin go build -ldflags "$LINKFLAGS" -o bin/helm-project-operator-darwin
GOOS=windows go build -ldflags "$LINKFLAGS" -o bin/helm-project-operator-windows
Expand Down

0 comments on commit 87a4a9a

Please sign in to comment.