Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit d526186

Browse files
update common labels to not federate things blocked by webhook
Signed-off-by: Alexandre Lamarre <[email protected]>
1 parent 81149c6 commit d526186

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

dummy.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
_ "github.com/rancher/wrangler/pkg/generated/controllers/apiextensions.k8s.io"
1414
_ "github.com/rancher/wrangler/pkg/generated/controllers/networking.k8s.io"
1515
"github.com/rancher/wrangler/pkg/kubeconfig"
16+
"github.com/sirupsen/logrus"
1617
"github.com/spf13/cobra"
1718
)
1819

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

5052
cfg := kubeconfig.GetNonInteractiveClientConfig(o.Kubeconfig)

pkg/controllers/common/operatorlabels.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ func GetCommonLabels(projectID string) map[string]string {
3636
labels := map[string]string{
3737
HelmProjectOperatedLabel: "true",
3838
}
39-
if len(projectID) != 0 {
40-
labels[HelmProjectOperatorProjectLabel] = projectID
41-
}
39+
// FIXME: this causes webhook to reject it
40+
// if len(projectID) != 0 {
41+
// labels[HelmProjectOperatorProjectLabel] = projectID
42+
// }
4243
return labels
4344
}
4445

@@ -56,7 +57,8 @@ func GetProjectNamespaceLabels(projectID, projectLabel, projectLabelValue string
5657
if isOrphaned {
5758
labels[HelmProjectOperatedNamespaceOrphanedLabel] = "true"
5859
}
59-
labels[projectLabel] = projectLabelValue
60+
// FIXME: this is not allowed by webhook
61+
// labels[projectLabel] = projectLabelValue
6062
return labels
6163
}
6264

pkg/controllers/namespace/controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ func Register(
107107
// Single Namespace Handler
108108

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

pkg/controllers/namespace/reconcilers.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ func (h *handler) addReconcilers(apply apply.Apply, dynamic dynamic.Interface) a
2323
NamespaceableResourceInterface: dynamic.Resource(corev1.SchemeGroupVersion.WithResource("configmaps")),
2424
}
2525
apply = apply.WithReconciler(corev1.SchemeGroupVersion.WithKind("ConfigMap"), r.deleteAndReplace)
26-
27-
logrus.Infof("Adding reconcilers on the apply object %s", apply)
26+
logrus.Debugf("Adding reconcilers on the apply object %s", apply)
2827
return apply
2928
}
3029

scripts/build

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ cd $(dirname $0)/..
88
./scripts/build-chart
99

1010
mkdir -p bin
11+
GO_BUILD_FLAGS="-gcflags=all=-trimpath=${GOPATH} -asmflags all=-trimpath=${GOPATH}"
1112
if [ "$(uname)" = "Linux" ]; then
12-
OTHER_LINKFLAGS="-extldflags -static -s"
13+
OTHER_LINKFLAGS="-extldflags -static -s -w"
1314
fi
1415
LINKFLAGS="-X github.com/rancher/helm-project-operator/pkg/version.Version=$VERSION"
1516
LINKFLAGS="-X github.com/rancher/helm-project-operator/pkg/version.GitCommit=$COMMIT $LINKFLAGS"
16-
CGO_ENABLED=0 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/helm-project-operator
17+
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/helm-project-operator
1718
if [ "$CROSS" = "true" ] && [ "$ARCH" = "amd64" ]; then
1819
GOOS=darwin go build -ldflags "$LINKFLAGS" -o bin/helm-project-operator-darwin
1920
GOOS=windows go build -ldflags "$LINKFLAGS" -o bin/helm-project-operator-windows

0 commit comments

Comments
 (0)