Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negated selectors don't apply to objects that have no metadata.labels #467

Closed
antoineco opened this issue Oct 9, 2021 · 0 comments · Fixed by #473
Closed

Negated selectors don't apply to objects that have no metadata.labels #467

antoineco opened this issue Oct 9, 2021 · 0 comments · Fixed by #473

Comments

@antoineco
Copy link
Contributor

antoineco commented Oct 9, 2021

Version: ko 0.9.3

What happened

Given a list of Kubernetes manifests where only CustomResourceDefinition kinds are labeled with knative.dev/crd-install: '' (or 'true' or any other value), the following command filters everything but objects with metadata.labels set and not empty.

$ ko resolve -f config/ -l '!knative.dev/crd-install'
---

---

---

---

---

---

---

---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: triggermesh-webhook
  name: triggermesh-webhook
  namespace: triggermesh
spec:
  ports:
    - name: https-webhook
      port: 443
      targetPort: 8443
  selector:
    app: triggermesh-webhook
---

What I expected

A Deployment and a bunch of other objects such as ClusterRoles should have been included (and images resolved + built), but were not, because they don't have any metadata.labels set.

I also tried setting an empty list of labels on these objects, without success:

diff --git a/config/500-controller.yaml b/config/500-controller.yaml
index b3483e0..c5fb016 100644
--- a/config/500-controller.yaml
+++ b/config/500-controller.yaml
@@ -17,6 +17,7 @@ kind: Deployment
 metadata:
   name: triggermesh-controller
   namespace: triggermesh
+  labels: []

 spec:
   replicas: 1

Workaround

Setting a non-empty metadata.labels works 🎉

diff --git a/config/500-controller.yaml b/config/500-controller.yaml
index b3483e0..0de084f 100644
--- a/config/500-controller.yaml
+++ b/config/500-controller.yaml
@@ -17,6 +17,8 @@ kind: Deployment
 metadata:
   name: triggermesh-controller
   namespace: triggermesh
+  labels:
+    ko-please: ''

 spec:
   replicas: 1
$ ko resolve -f config/ -l '!knative.dev/crd-install'
---

---

---
2021/10/09 13:03:56 Using base gcr.io/distroless/static:nonroot for github.com/triggermesh/triggermesh/cmd/triggermesh-controller
...
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant