microsoft / fabrikate

Making GitOps with Kubernetes easier one component at a time
MIT License
38 stars 5 forks source link

Fabrikate doesn't fail with a non-zero exit code on warnings that fail to generate yaml #288

Open andrebriggs opened 4 years ago

andrebriggs commented 4 years ago

Describe the bug: Fabrikate gives a 0 exit code on a failure to generate my helm template. My manifest yaml is empty and Fabrikate give a warning but doesn't fail.

Not sure if this is the expected behavior

To Reproduce:

$ ~/Downloads/fab generate
INFO[22-02-2020 16:32:18] fab version 0.17.3                           
INFO[22-02-2020 16:32:18] 💾  Loading component.yaml                    
INFO[22-02-2020 16:32:18] 💾  Loading fabrikam2019/component.yaml       
INFO[22-02-2020 16:32:18] 💾  Loading fabrikam2019/config/common.yaml   
INFO[22-02-2020 16:32:18] 💾  Loading components/traefik2/definitions/traefik2/component.yaml 
INFO[22-02-2020 16:32:18] 💾  Loading fabrikam2019/fabrikam.acme.frontend/component.yaml 
INFO[22-02-2020 16:32:18] 💾  Loading fabrikam2019/fabrikam.acme.frontend/config/common.yaml 
INFO[22-02-2020 16:32:18] 💾  Loading components/traefik2/definitions/traefik2/config/common.yaml 
INFO[22-02-2020 16:32:18] 💾  Loading fabrikam2019/fabrikam.acme.frontend/master/component.yaml 
INFO[22-02-2020 16:32:18] 💾  Loading fabrikam2019/fabrikam.acme.frontend/master/config/common.yaml 
INFO[22-02-2020 16:32:18] 🚚  Generating component 'traefik2' with helm with repo https://github.com/containous/traefik-helm-chart 
INFO[22-02-2020 16:32:18] 🚚  Generating component 'static' statically from path ./static 
INFO[22-02-2020 16:32:18] 🚚  Generating component 'chart' with helm with repo https://dev.azure.com/abrig/spk/_git/fabrikam-helm-charts 
INFO[22-02-2020 16:32:18] 📝  Running `helm template` on template '/Users/andrebriggs/Code/spk/tests/spk-env/fabrikam-hld/fabrikam2019/fabrikam.acme.frontend/master/helm_repos/chart/fabrikam.acme.frontend/chart' 
INFO[22-02-2020 16:32:18] 📝  Running `helm template` on template '/Users/andrebriggs/Code/spk/tests/spk-env/fabrikam-hld/components/traefik2/definitions/traefik2/helm_repos/traefik2/traefik' 
INFO[22-02-2020 16:32:19] ✂  Removing empty entries from generated manifests from chart '/Users/andrebriggs/Code/spk/tests/spk-env/fabrikam-hld/fabrikam2019/fabrikam.acme.frontend/master/helm_repos/chart/fabrikam.acme.frontend/chart' 
WARN[22-02-2020 16:32:19] ❓  Unable to unmarshal manifest into type 'map[interface {}]interface {}', this is most likely a warning message outputted from `helm template`.
Removing manifest entry: '
apiVersion: apps/v1
kind: Deployment
metadata:
  name: { { .Chart.Name } }
spec:
  replicas: { { .Values.replicaCount } }
  selector:
    matchLabels:
      app.kubernetes.io/name: { { .Chart.Name } }
      app.kubernetes.io/instance: { { .Release.Name } }
  minReadySeconds: { { .Values.minReadySeconds } }
  strategy:
    type: RollingUpdate # describe how we do rolling updates
    rollingUpdate:
      maxUnavailable: 1 # When updating take one pod down at a time
      maxSurge: 1 # When updating never have more than one extra pod. If replicas = 2 then never 3 pods when updating
  template:
    metadata:
      labels:
        app: { { .Chart.Name } }
        app.kubernetes.io/name: { { .Chart.Name } }
        app.kubernetes.io/instance: { { .Release.Name } }
      annotations:
        prometheus.io/port: 8080
        prometheus.io/scrape: true
    spec:
      containers:
        - name: { { .Chart.Name } }
          image: andrebriggs.azurecr.io/fabrikam.acme.frontend:latest
          imagePullPolicy: { { .Values.image.pullPolicy } }
          ports:
            - containerPort: { { .Values.service.containerPort } }'
Unmarshal error encountered: 'yaml: invalid map key: map[interface {}]interface {}{".Chart.Name":interface {}(nil)}' 
WARN[22-02-2020 16:32:19] ❓  Unable to unmarshal manifest into type 'map[interface {}]interface {}', this is most likely a warning message outputted from `helm template`.
Removing manifest entry: '
apiVersion: v1
kind: Service
metadata:
  name: { { .Chart.Name } }
  labels:
    app: { { .Chart.Name } }
spec:
  type: LoadBalancer
  ports:
    - port: 8080
      name: http
  selector:
    app: { { .Chart.Name } }

'
Unmarshal error encountered: 'yaml: invalid map key: map[interface {}]interface {}{".Chart.Name":interface {}(nil)}' 
INFO[22-02-2020 16:32:19] ✂  Removing empty entries from generated manifests from chart '/Users/andrebriggs/Code/spk/tests/spk-env/fabrikam-hld/components/traefik2/definitions/traefik2/helm_repos/traefik2/traefik' 
INFO[22-02-2020 16:32:19] 💾  Writing generated/common/fabrikam2019/fabrikam2019.yaml 
INFO[22-02-2020 16:32:19] 💾  Writing generated/common/default-component.yaml 
INFO[22-02-2020 16:32:19] 💾  Writing generated/common/traefik2/fabrikate-traefik2.yaml 
INFO[22-02-2020 16:32:19] 💾  Writing generated/common/fabrikam2019/fabrikam.acme.frontend/fabrikam.acme.frontend.yaml 
INFO[22-02-2020 16:32:19] 💾  Writing generated/common/fabrikam2019/fabrikam.acme.frontend/master/master.yaml 
INFO[22-02-2020 16:32:19] 💾  Writing generated/common/fabrikam2019/fabrikam.acme.frontend/master/static.yaml 
INFO[22-02-2020 16:32:19] 💾  Writing generated/common/fabrikam2019/fabrikam.acme.frontend/master/chart.yaml 
INFO[22-02-2020 16:32:19] 💾  Writing generated/common/traefik2/traefik2.yaml 
INFO[22-02-2020 16:32:19] 🙌  Finished generate                         
$ $?
-bash: 0: command not found

Expected behavior: Fabrikate should fail with a non-zero exit code

Additional context:

Desktop (please complete the following information):