patrickdappollonio / kubectl-slice

Split multiple Kubernetes files into smaller files with ease. Split multi-YAML files into individual files.
MIT License
296 stars 23 forks source link

Comments seem to end up creating -.yaml files #138

Closed hyacin75 closed 2 hours ago

hyacin75 commented 3 hours ago

Hey bud, long time.

I'm getting a -.yaml file from slicing the latest cert-manager.yaml install manifest -

rob@manager:/mnt/cephfs/k8s/nakc-cert-manager$ wget -q -O - https://github.com/cert-manager/cert-manager/releases/download/v1.16.1/cert-manager.yaml | kubectl-slice -o .
Wrote namespace-cert-manager.yaml -- 651 bytes.
Wrote customresourcedefinition-certificaterequests.cert-manager.io.yaml -- 14045 bytes.
Wrote customresourcedefinition-certificates.cert-manager.io.yaml -- 39530 bytes.
Wrote customresourcedefinition-challenges.acme.cert-manager.io.yaml -- 261025 bytes.
Wrote customresourcedefinition-clusterissuers.cert-manager.io.yaml -- 310416 bytes.
Wrote customresourcedefinition-issuers.cert-manager.io.yaml -- 310326 bytes.
Wrote customresourcedefinition-orders.acme.cert-manager.io.yaml -- 12327 bytes.
Wrote serviceaccount-cert-manager-cainjector.yaml -- 403 bytes.
Wrote serviceaccount-cert-manager.yaml -- 385 bytes.
Wrote serviceaccount-cert-manager-webhook.yaml -- 388 bytes.
Wrote clusterrole-cert-manager-cainjector.yaml -- 1097 bytes.
Wrote clusterrole-cert-manager-controller-issuers.yaml -- 787 bytes.
Wrote clusterrole-cert-manager-controller-clusterissuers.yaml -- 822 bytes.
Wrote clusterrole-cert-manager-controller-certificates.yaml -- 1427 bytes.
Wrote clusterrole-cert-manager-controller-orders.yaml -- 1338 bytes.
Wrote clusterrole-cert-manager-controller-challenges.yaml -- 2376 bytes.
Wrote clusterrole-cert-manager-controller-ingress-shim.yaml -- 1462 bytes.
Wrote clusterrole-cert-manager-cluster-view.yaml -- 528 bytes.
Wrote clusterrole-cert-manager-view.yaml -- 837 bytes.
Wrote clusterrole-cert-manager-edit.yaml -- 881 bytes.
Wrote clusterrole-cert-manager-controller-approve:cert-manager-io.yaml -- 659 bytes.
Wrote clusterrole-cert-manager-controller-certificatesigningrequests.yaml -- 1126 bytes.
Wrote clusterrole-cert-manager-webhook:subjectaccessreviews.yaml -- 464 bytes.
Wrote clusterrolebinding-cert-manager-cainjector.yaml -- 558 bytes.
Wrote clusterrolebinding-cert-manager-controller-issuers.yaml -- 556 bytes.
Wrote clusterrolebinding-cert-manager-controller-clusterissuers.yaml -- 570 bytes.
Wrote clusterrolebinding-cert-manager-controller-certificates.yaml -- 566 bytes.
Wrote clusterrolebinding-cert-manager-controller-orders.yaml -- 554 bytes.
Wrote clusterrolebinding-cert-manager-controller-challenges.yaml -- 562 bytes.
Wrote clusterrolebinding-cert-manager-controller-ingress-shim.yaml -- 566 bytes.
Wrote clusterrolebinding-cert-manager-controller-approve:cert-manager-io.yaml -- 590 bytes.
Wrote clusterrolebinding-cert-manager-controller-certificatesigningrequests.yaml -- 596 bytes.
Wrote clusterrolebinding-cert-manager-webhook:subjectaccessreviews.yaml -- 573 bytes.
Wrote role-cert-manager-cainjector:leaderelection.yaml -- 1037 bytes.
Wrote role-cert-manager:leaderelection.yaml -- 614 bytes.
Wrote role-cert-manager-tokenrequest.yaml -- 495 bytes.
Wrote role-cert-manager-webhook:dynamic-serving.yaml -- 652 bytes.
Wrote rolebinding-cert-manager-cainjector:leaderelection.yaml -- 705 bytes.
Wrote rolebinding-cert-manager:leaderelection.yaml -- 665 bytes.
Wrote rolebinding-cert-manager-cert-manager-tokenrequest.yaml -- 641 bytes.
Wrote rolebinding-cert-manager-webhook:dynamic-serving.yaml -- 575 bytes.
Wrote service-cert-manager-cainjector.yaml -- 585 bytes.
Wrote service-cert-manager.yaml -- 607 bytes.
Wrote service-cert-manager-webhook.yaml -- 662 bytes.
Wrote deployment-cert-manager-cainjector.yaml -- 1856 bytes.
Wrote deployment-cert-manager.yaml -- 2669 bytes.
Wrote deployment-cert-manager-webhook.yaml -- 2907 bytes.
Wrote -.yaml -- 351 bytes.
Wrote mutatingwebhookconfiguration-cert-manager-webhook.yaml -- 1223 bytes.
Wrote validatingwebhookconfiguration-cert-manager-webhook.yaml -- 1360 bytes.
50 files generated.
rob@manager:/mnt/cephfs/k8s/nakc-cert-manager$ cat -- -.yaml
# Source: cert-manager/templates/crds.yaml
#
# START crd
---
# Source: cert-manager/templates/crds.yaml
# START crd
---
# Source: cert-manager/templates/crds.yaml
# START crd
---
# Source: cert-manager/templates/crds.yaml
# START crd
---
# Source: cert-manager/templates/crds.yaml
# START crd
---
# Source: cert-manager/templates/crds.yaml
# START crd
rob@manager:/mnt/cephfs/k8s/nakc-cert-manager$

I remember having this issue a long time ago, so I updated to the latest version but it's still happening.

Seems like it's the comments that start with hash marks that cause it -

rob@manager:/mnt/cephfs/k8s/nakc-cert-manager$ wget -q -O - https://github.com/cert-manager/cert-manager/releases/download/v1.16.1/cert-manager.yaml | grep -v ^# | kubectl-slice -o .
Wrote namespace-cert-manager.yaml -- 61 bytes.
Wrote customresourcedefinition-certificaterequests.cert-manager.io.yaml -- 13977 bytes.
Wrote customresourcedefinition-certificates.cert-manager.io.yaml -- 39464 bytes.
Wrote customresourcedefinition-challenges.acme.cert-manager.io.yaml -- 260959 bytes.
Wrote customresourcedefinition-clusterissuers.cert-manager.io.yaml -- 310350 bytes.
Wrote customresourcedefinition-issuers.cert-manager.io.yaml -- 310260 bytes.
Wrote customresourcedefinition-orders.acme.cert-manager.io.yaml -- 12261 bytes.
Wrote serviceaccount-cert-manager-cainjector.yaml -- 339 bytes.
Wrote serviceaccount-cert-manager.yaml -- 332 bytes.
Wrote serviceaccount-cert-manager-webhook.yaml -- 327 bytes.
Wrote clusterrole-cert-manager-cainjector.yaml -- 1043 bytes.
Wrote clusterrole-cert-manager-controller-issuers.yaml -- 719 bytes.
Wrote clusterrole-cert-manager-controller-clusterissuers.yaml -- 747 bytes.
Wrote clusterrole-cert-manager-controller-certificates.yaml -- 1353 bytes.
Wrote clusterrole-cert-manager-controller-orders.yaml -- 1270 bytes.
Wrote clusterrole-cert-manager-controller-challenges.yaml -- 2304 bytes.
Wrote clusterrole-cert-manager-controller-ingress-shim.yaml -- 1388 bytes.
Wrote clusterrole-cert-manager-cluster-view.yaml -- 485 bytes.
Wrote clusterrole-cert-manager-view.yaml -- 794 bytes.
Wrote clusterrole-cert-manager-edit.yaml -- 838 bytes.
Wrote clusterrole-cert-manager-controller-approve:cert-manager-io.yaml -- 517 bytes.
Wrote clusterrole-cert-manager-controller-certificatesigningrequests.yaml -- 868 bytes.
Wrote clusterrole-cert-manager-webhook:subjectaccessreviews.yaml -- 413 bytes.
Wrote clusterrolebinding-cert-manager-cainjector.yaml -- 504 bytes.
Wrote clusterrolebinding-cert-manager-controller-issuers.yaml -- 513 bytes.
Wrote clusterrolebinding-cert-manager-controller-clusterissuers.yaml -- 527 bytes.
Wrote clusterrolebinding-cert-manager-controller-certificates.yaml -- 523 bytes.
Wrote clusterrolebinding-cert-manager-controller-orders.yaml -- 511 bytes.
Wrote clusterrolebinding-cert-manager-controller-challenges.yaml -- 519 bytes.
Wrote clusterrolebinding-cert-manager-controller-ingress-shim.yaml -- 523 bytes.
Wrote clusterrolebinding-cert-manager-controller-approve:cert-manager-io.yaml -- 547 bytes.
Wrote clusterrolebinding-cert-manager-controller-certificatesigningrequests.yaml -- 553 bytes.
Wrote clusterrolebinding-cert-manager-webhook:subjectaccessreviews.yaml -- 522 bytes.
Wrote role-cert-manager-cainjector:leaderelection.yaml -- 959 bytes.
Wrote role-cert-manager:leaderelection.yaml -- 571 bytes.
Wrote role-cert-manager-tokenrequest.yaml -- 452 bytes.
Wrote role-cert-manager-webhook:dynamic-serving.yaml -- 528 bytes.
Wrote rolebinding-cert-manager-cainjector:leaderelection.yaml -- 545 bytes.
Wrote rolebinding-cert-manager:leaderelection.yaml -- 516 bytes.
Wrote rolebinding-cert-manager-cert-manager-tokenrequest.yaml -- 526 bytes.
Wrote rolebinding-cert-manager-webhook:dynamic-serving.yaml -- 524 bytes.
Wrote service-cert-manager-cainjector.yaml -- 528 bytes.
Wrote service-cert-manager.yaml -- 561 bytes.
Wrote service-cert-manager-webhook.yaml -- 608 bytes.
Wrote deployment-cert-manager-cainjector.yaml -- 1796 bytes.
Wrote deployment-cert-manager.yaml -- 2620 bytes.
Wrote deployment-cert-manager-webhook.yaml -- 2850 bytes.
Wrote mutatingwebhookconfiguration-cert-manager-webhook.yaml -- 1160 bytes.
Wrote validatingwebhookconfiguration-cert-manager-webhook.yaml -- 1295 bytes.
49 files generated.
rob@manager:/mnt/cephfs/k8s/nakc-cert-manager$

Probably worth trying to resolve given the uselessness of the generated file and the headaches files that start with hyphens cause people :-)

Hope all is well!

patrickdappollonio commented 2 hours ago

Hey! Good to see you again!

Have you tried with --skip-non-k8s? Comment-only files won't qualify because it won't be able to find an apiVersion, metadata or kind.

Let me know!

hyacin75 commented 2 hours ago

Hey! Good to see you again!

Have you tried with --skip-non-k8s? Comment-only files won't qualify because it won't be able to find an apiVersion, metadata or kind.

Let me know!

Yeah, that keeps it out too! Awesome, ty!

rob@manager:/mnt/cephfs/k8s/nakc-cert-manager$ wget -q -O - https://github.com/cert-manager/cert-manager/releases/download/v1.16.1/cert-manager.yaml | kubectl-slice --skip-non-k8s -o .
Wrote namespace-cert-manager.yaml -- 651 bytes.
Wrote customresourcedefinition-certificaterequests.cert-manager.io.yaml -- 14045 bytes.
Wrote customresourcedefinition-certificates.cert-manager.io.yaml -- 39530 bytes.
Wrote customresourcedefinition-challenges.acme.cert-manager.io.yaml -- 261025 bytes.
Wrote customresourcedefinition-clusterissuers.cert-manager.io.yaml -- 310416 bytes.
Wrote customresourcedefinition-issuers.cert-manager.io.yaml -- 310326 bytes.
Wrote customresourcedefinition-orders.acme.cert-manager.io.yaml -- 12327 bytes.
Wrote serviceaccount-cert-manager-cainjector.yaml -- 403 bytes.
Wrote serviceaccount-cert-manager.yaml -- 385 bytes.
Wrote serviceaccount-cert-manager-webhook.yaml -- 388 bytes.
Wrote clusterrole-cert-manager-cainjector.yaml -- 1097 bytes.
Wrote clusterrole-cert-manager-controller-issuers.yaml -- 787 bytes.
Wrote clusterrole-cert-manager-controller-clusterissuers.yaml -- 822 bytes.
Wrote clusterrole-cert-manager-controller-certificates.yaml -- 1427 bytes.
Wrote clusterrole-cert-manager-controller-orders.yaml -- 1338 bytes.
Wrote clusterrole-cert-manager-controller-challenges.yaml -- 2376 bytes.
Wrote clusterrole-cert-manager-controller-ingress-shim.yaml -- 1462 bytes.
Wrote clusterrole-cert-manager-cluster-view.yaml -- 528 bytes.
Wrote clusterrole-cert-manager-view.yaml -- 837 bytes.
Wrote clusterrole-cert-manager-edit.yaml -- 881 bytes.
Wrote clusterrole-cert-manager-controller-approve:cert-manager-io.yaml -- 659 bytes.
Wrote clusterrole-cert-manager-controller-certificatesigningrequests.yaml -- 1126 bytes.
Wrote clusterrole-cert-manager-webhook:subjectaccessreviews.yaml -- 464 bytes.
Wrote clusterrolebinding-cert-manager-cainjector.yaml -- 558 bytes.
Wrote clusterrolebinding-cert-manager-controller-issuers.yaml -- 556 bytes.
Wrote clusterrolebinding-cert-manager-controller-clusterissuers.yaml -- 570 bytes.
Wrote clusterrolebinding-cert-manager-controller-certificates.yaml -- 566 bytes.
Wrote clusterrolebinding-cert-manager-controller-orders.yaml -- 554 bytes.
Wrote clusterrolebinding-cert-manager-controller-challenges.yaml -- 562 bytes.
Wrote clusterrolebinding-cert-manager-controller-ingress-shim.yaml -- 566 bytes.
Wrote clusterrolebinding-cert-manager-controller-approve:cert-manager-io.yaml -- 590 bytes.
Wrote clusterrolebinding-cert-manager-controller-certificatesigningrequests.yaml -- 596 bytes.
Wrote clusterrolebinding-cert-manager-webhook:subjectaccessreviews.yaml -- 573 bytes.
Wrote role-cert-manager-cainjector:leaderelection.yaml -- 1037 bytes.
Wrote role-cert-manager:leaderelection.yaml -- 614 bytes.
Wrote role-cert-manager-tokenrequest.yaml -- 495 bytes.
Wrote role-cert-manager-webhook:dynamic-serving.yaml -- 652 bytes.
Wrote rolebinding-cert-manager-cainjector:leaderelection.yaml -- 705 bytes.
Wrote rolebinding-cert-manager:leaderelection.yaml -- 665 bytes.
Wrote rolebinding-cert-manager-cert-manager-tokenrequest.yaml -- 641 bytes.
Wrote rolebinding-cert-manager-webhook:dynamic-serving.yaml -- 575 bytes.
Wrote service-cert-manager-cainjector.yaml -- 585 bytes.
Wrote service-cert-manager.yaml -- 607 bytes.
Wrote service-cert-manager-webhook.yaml -- 662 bytes.
Wrote deployment-cert-manager-cainjector.yaml -- 1856 bytes.
Wrote deployment-cert-manager.yaml -- 2669 bytes.
Wrote deployment-cert-manager-webhook.yaml -- 2907 bytes.
Wrote mutatingwebhookconfiguration-cert-manager-webhook.yaml -- 1223 bytes.
Wrote validatingwebhookconfiguration-cert-manager-webhook.yaml -- 1360 bytes.
49 files generated.
rob@manager:/mnt/cephfs/k8s/nakc-cert-manager$
patrickdappollonio commented 2 hours ago

Glad that did the trick! The reason you got a file without a name and just a dash is because of the template used by default. If you change it too, you could make files with comments go to a standalone destination.

Let me know if you need anything else!