big-spring-14945
05/31/2023, 4:33 PMcopyFrom
but it only exists in build actions. What if I need to copyFrom
a build action into a deploy action? Isn't that a valid use case too?kind: Deploy
type: kubernetes
name: test
source:
repository:
url: https://github.com/prometheus-operator/kube-prometheus.git#0198f98f682f1d7e40b1dd5615437a916107f1aa
spec:
files:
- manifests/grafana-dashboardDefinitions.yaml
Because I need to add a special annotation too, I want to run a kustomization on top of this. But when specifying
spec:
kustomize:
path: .
it does not find the kustomize.yaml
, because it is not part of the "action context" (What do you call this in a deploy action?)
I thought maybe I could do
kind: Build
type: exec
name: prometheus-operator-dashboards
source:
repository:
url: https://github.com/prometheus-operator/kube-prometheus.git#0198f98f682f1d7e40b1dd5615437a916107f1aa
path: manifests
And then I have a deploy like this:
kind: Deploy
type: kubernetes
name: test
copyFrom:
- build: prometheus-operator-dashboards
sourcePath: grafana-dashboardDefinitions.yaml
spec:
kustomization:
path: .
files:
- grafana-dashboardDefinitions.yaml
alert-helicopter-61082
05/31/2023, 6:38 PMbuild
on Deploy actions, and then you shouldn't need the copyFrom
. The Deploy's source path then becomes the build path of the Build action you reference.big-spring-14945
06/01/2023, 9:09 AM`
kind: Project
apiVersion: garden.io/v1
name: repro
environments:
- name: default
providers:
- name: local-kubernetes
---
# Get prometheus-operator Grafana default dashboards
kind: Build
type: exec
name: github-kube-prometheus
source:
repository:
url: https://github.com/prometheus-operator/kube-prometheus.git#3fff8b56097778f1491edba968aee3cfbd5652ef
---
# Combine the dashboards we need with the kustomization we need
kind: Build
type: exec
name: grafana-default-dashboards-with-kustomization
dependencies:
- build.github-kube-prometheus
copyFrom:
- build: github-kube-prometheus
sourcePath: manifests/grafana-dashboardDefinitions.yaml
targetPath: grafana-prometheus-default.yaml
include:
- kustomize-add-label/**/*
- grafana-prometheus-default.yaml
---
# Deploy the default dashboards after applying the kustomization
kind: Deploy
type: kubernetes
name: grafana-default-dashboards
description: Additional grafana dashboards
dependencies:
- build.grafana-default-dashboards-with-kustomization
build: grafana-default-dashboards-with-kustomization
spec:
namespace: monitoring
kustomize:
path: ./kustomize-add-label/
files:
- grafana-prometheus-default.yaml
error:
✖ deploy.grafana-default-dashboards → Failed resolving status for Deploy type=kubernetes name=grafana-default-dashboards (took 0.04 sec). Here is the output:
ENOENT: no such file or directory, open '/Users/steffen/repro2/grafana-prometheus-default.yaml'
alert-helicopter-61082
06/01/2023, 11:09 AMaction.basePath()
instead of action.getBuildPath()
(see https://github.com/garden-io/garden/blob/5b59b9ffc39b4f99d387faa5905c3578c68809d5/core/src/actions/base.ts#L662).
Which is to say, this is in some sense accounted for in the framework but incorrectly handled in various plugin handlers. However, that's such an easy mistake to make and to keep making it, so instead of fixing it from that point of view I'd suggest making it a bit more obvious which action.<something>Path()
is the right one for each context. I think "basePath" should likely only be an private method on actions, because its semantics aren't obvious.big-spring-14945
06/06/2023, 11:55 AM