-
Notifications
You must be signed in to change notification settings - Fork 118
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
feat: consolidate all the conditions that trigger a transformer in one place #882
Comments
Example of how an existing Helm chart transformer would change:
apiVersion: move2kube.konveyor.io/v1alpha1
kind: Transformer
metadata:
name: CustomHelmChartGen
labels:
move2kube.konveyor.io/built-in: false
spec:
class: "Starlark"
directoryDetect:
levels: -1
consumes:
Service:
merge: false
override:
matchLabels:
move2kube.konveyor.io/built-in: "true"
config:
starFile: "customhelmchartgen.star" turns into apiVersion: move2kube.konveyor.io/v1beta1
kind: Transformer
metadata:
name: CustomHelmChartGen
labels:
move2kube.konveyor.io/built-in: false
spec:
class: "Starlark"
on:
plan:
directories: all
transform:
artifacts:
- type: Service
merge: false
transformers:
- override: true
matchLabels:
move2kube.konveyor.io/built-in: "true"
config:
starFile: "customhelmchartgen.star" |
apiVersion: move2kube.konveyor.io/v1alpha1
kind: Transformer
metadata:
name: IKSKubernetes
labels:
move2kube.konveyor.io/built-in: false
spec:
class: "Kubernetes"
directoryDetect:
levels: 0
consumes:
IR:
merge: true
produces:
KubernetesYamls:
disabled: false
override:
matchLabels:
move2kube.konveyor.io/name: Kubernetes
dependency:
matchLabels:
move2kube.konveyor.io/name: IKSClusterSelector
config:
outputPath: "deploy/yamls/iks"
ingressName: "{{ .ProjectName }}" turns into apiVersion: move2kube.konveyor.io/v1beta1
kind: Transformer
metadata:
name: IKSKubernetes
labels:
move2kube.konveyor.io/built-in: false
spec:
class: "Kubernetes"
on:
transform:
artifacts:
- type: IR
transformers:
- override: true
matchLabels:
move2kube.konveyor.io/name: Kubernetes
- runAfter: true
matchLabels:
move2kube.konveyor.io/name: IKSClusterSelector
produces:
KubernetesYamls:
disabled: false
config:
outputPath: "deploy/yamls/iks"
ingressName: "{{ .ProjectName }}" Since we don't want the transformer to run during the plan phase, we can omit that trigger. |
apiVersion: move2kube.konveyor.io/v1alpha1
kind: Transformer
metadata:
name: AdvancedCustomParameterizer
labels:
move2kube.konveyor.io/built-in: false
spec:
class: "Parameterizer"
directoryDetect:
levels: -1
consumes:
Service:
merge: false
KubernetesYamlsInSource:
merge: false
KubernetesYamls:
merge: true
override:
matchLabels:
move2kube.konveyor.io/name: Parameterizer
config:
helmPath: "{{ $pathType := EnvPathType .YamlsPath}}{{ $rel := Rel .YamlsPath }}{{ if eq $pathType \"Source\" }}source/{{end}}{{ $rel }}{{ if ne $rel \".\" }}/..{{end}}/{{ FilePathBase .YamlsPath }}-parameterized/helm-chart"
ocTemplatePath: "{{ $pathType := EnvPathType .YamlsPath}}{{ $rel := Rel .YamlsPath }}{{ if eq $pathType \"Source\" }}source/{{end}}{{ $rel }}{{ if ne $rel \".\" }}/..{{end}}/{{ FilePathBase .YamlsPath }}-parameterized/openshift-template"
kustomizePath: "{{ $pathType := EnvPathType .YamlsPath}}{{ $rel := Rel .YamlsPath }}{{ if eq $pathType \"Source\" }}source/{{end}}{{ $rel }}{{ if ne $rel \".\" }}/..{{end}}/{{ FilePathBase .YamlsPath }}-parameterized/kustomize"
projectName: "{{ if eq .ArtifactType \"KubernetesYamls\" }}{{ .ProjectName }}{{ else }}{{ if eq .ArtifactType \"KubernetesYamlsInSource\" }}{{ .ArtifactName }}{{ else }}{{ .ServiceName }}{{end}}{{end}}" turns into apiVersion: move2kube.konveyor.io/v1beta1
kind: Transformer
metadata:
name: AdvancedCustomParameterizer
labels:
move2kube.konveyor.io/built-in: false
spec:
class: "Parameterizer"
on:
plan:
directories: all
transform:
artifacts:
- type: Service
merge: false
- type: KubernetesYamlsInSource
merge: false
- type: KubernetesYamls
merge: true
transformers:
- override: true
matchLabels:
move2kube.konveyor.io/name: Parameterizer
config:
helmPath: "{{ $pathType := EnvPathType .YamlsPath}}{{ $rel := Rel .YamlsPath }}{{ if eq $pathType \"Source\" }}source/{{end}}{{ $rel }}{{ if ne $rel \".\" }}/..{{end}}/{{ FilePathBase .YamlsPath }}-parameterized/helm-chart"
ocTemplatePath: "{{ $pathType := EnvPathType .YamlsPath}}{{ $rel := Rel .YamlsPath }}{{ if eq $pathType \"Source\" }}source/{{end}}{{ $rel }}{{ if ne $rel \".\" }}/..{{end}}/{{ FilePathBase .YamlsPath }}-parameterized/openshift-template"
kustomizePath: "{{ $pathType := EnvPathType .YamlsPath}}{{ $rel := Rel .YamlsPath }}{{ if eq $pathType \"Source\" }}source/{{end}}{{ $rel }}{{ if ne $rel \".\" }}/..{{end}}/{{ FilePathBase .YamlsPath }}-parameterized/kustomize"
projectName: "{{ if eq .ArtifactType \"KubernetesYamls\" }}{{ .ProjectName }}{{ else }}{{ if eq .ArtifactType \"KubernetesYamlsInSource\" }}{{ .ArtifactName }}{{ else }}{{ .ServiceName }}{{end}}{{end}}" |
Is your feature request related to a problem? Please describe.
Currently we have a bunch of different fields to indicate when a transformer might run.
Examples:
https://github.com/konveyor/move2kube-transformers/blob/525d3854a18e9c85582178395099544e3e351363/add-custom-files-directories-in-custom-locations/transformer.yaml#L9-L16
https://github.com/konveyor/move2kube-transformers/blob/525d3854a18e9c85582178395099544e3e351363/custom-default-transformer/transformer.yaml#L9-L14
Describe the solution you'd like
We can consolidate all the different conditions under a single field similar to Github workflows:
move2kube/.github/workflows/assignproject.yml
Lines 3 to 5 in 6ee8f6b
For default transformers:
For normal transformers that consume artifacts of certain types:
We could also trigger on path mappings.
This could be useful if we want to add a common LICENSE on top of each file we generate.
Running after other transformers:
For transformers that run during both the plan and transform phase:
This is also a good chance to move away from
1
,0
,-1
for thelevels
and use more meaningful names.Additional context
Since we are moving to
v0.4
this is a good time to add any breaking changes we would like.The text was updated successfully, but these errors were encountered: