-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Adding ENV keyword #364
Adding ENV keyword #364
Conversation
@olblak for context, this PR is the result of a "mob programming" session we did the 3 of us (@pilere , @lemeurherve and I). We might have to rework, but it's a first shot on cosntrained time, which is a good start \o/ Thanks @pilere , we'll start the code review as soon as one of us have time :) (but you can already start to fix the issues raised by the automatic linter: https://github.com/updatecli/updatecli/runs/4188685268?check_suite_focus=true TL;DR; you might want to use golangici-lint on your environment and follow its directives) Output of golangci-lint:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good, thanks!
I confirm that it work: I've tested your PR with the following example:
---
title: Show a set of dockerfile "coordinates" resources as a generic example
sources:
## Dummy source as Dockerfile does not support sources
lastVersion:
kind: shell
spec:
command: echo 1.2.3
conditions:
isARGGoVersionExisting:
# Is the Dockerfile having any ARG instruction with a key "GO_VERSION" and a default value?
kind: dockerfile
spec:
file: Dockerfile
instruction:
keyword: ARG
matcher: 'GO_VERSION='
targets:
updateFROMJenkinsVersion:
name: Update all the "FROM jenkins/jenkins*" instructions
kind: dockerfile
sourceID: lastVersion
spec:
file: Dockerfile
instruction:
keyword: FROM
matcher: "jenkins/jenkins"
updateArgGoVersion:
name: Update all the "ARG GO_VERSION*" instructions
kind: dockerfile
sourceID: lastVersion
spec:
file: Dockerfile
instruction:
keyword: ARG
matcher: GO_VERSION
updateEnvJavaVersion:
name: Update all the "ENV JAVA_VERSION*" instructions
kind: dockerfile
sourceID: lastVersion
spec:
file: Dockerfile
instruction:
keyword: ENV
matcher: JAVA_VERSION
- With the version 0.14.1 of updatecli:
# ...
updateEnvJavaVersion
--------------------
**Dry Run enabled**
ERROR: Something went wrong in target "updateEnvJavaVersion" :
ERROR: ✗ Provided keyword "ENV" not supported (yet). Feel free to open an issue explaining your use-case to help adding the implementation.
- With your PR:
# ...
updateEnvJavaVersion
--------------------
**Dry Run enabled**
🐋 On (Docker)file "Dockerfile":
✔ The line #19, matched by the keyword "ENV" and the matcher "JAVA_VERSION", is changed from "ENV JAVA_VERSION=8" to "ENV JAVA_VERSION=1.2.3".
Signed-off-by: Damien Duportal <damien.duportal@gmail.com>
Signed-off-by: Damien Duportal <damien.duportal@gmail.com>
Many thanks @pilere !!! |
#322