-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Only substitute manifest image when there's a full match #10643
Only substitute manifest image when there's a full match #10643
Conversation
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.
@DJLemkes Thanks for the contribution.
It's almost there; you need to bump up the task patch version to allow these changes to be shipped.
@@ -8,7 +8,8 @@ import * as yaml from 'js-yaml'; | |||
import * as TaskInputParameters from '../models/TaskInputParameters'; | |||
import * as fileHelper from '../utils/FileHelper'; | |||
import * as helper from './KubernetesObjectUtility'; | |||
import { KubernetesWorkload } from '../models/constants'; | |||
import { KubernetesWorkload } from '../models/constants'; | |||
import {StringComparer, isEqual} from '../utils/StringComparison'; |
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.
NIT: spacing
@@ -4,16 +4,16 @@ import * as tl from 'vsts-task-lib/task'; | |||
import * as yaml from 'js-yaml'; | |||
import { Resource } from 'kubernetes-common/kubectl-object-model'; | |||
import { KubernetesWorkload, recognizedWorkloadTypes } from '../models/constants'; | |||
import {StringComparer, isEqual} from '../utils/StringComparison'; |
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.
NIT: spacing
@@ -3,13 +3,14 @@ | |||
import { Kubectl } from 'kubernetes-common/kubectl-object-model'; | |||
import * as utils from '../utils/utilities'; | |||
import * as TaskInputParameters from '../models/TaskInputParameters'; | |||
import {StringComparer, isEqual} from '../utils/StringComparison'; |
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.
NIT: Spacing
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 is missing
@@ -1,7 +1,7 @@ | |||
'use strict'; | |||
|
|||
import * as tl from 'vsts-task-lib/task'; | |||
import * as utils from '../utils/utilities'; | |||
import {StringComparer, isEqual} from '../utils/StringComparison'; |
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.
NIT: Spacing
@@ -7,7 +7,7 @@ | |||
"resolved": "https://registry.npmjs.org/@types/del/-/del-2.2.33.tgz", |
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.
Undo theses changes
@DJLemkes If you build after the task version bump up, that would bump it up in |
Ok, I see. Sorry about that. Will do a build, add the When building, the |
If you notice the changes correctly in the generated You can ignore this for now, as |
Previously, the line `image: nginx-init` would already match an 'nginx:42' container in the task definition resulting in `image: nginx:42`. This leads to unexpected images being deployed.
c74e7b8
to
68e70ab
Compare
Did a rebase and left the |
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.
LGTM 👍
@@ -3,13 +3,14 @@ | |||
import { Kubectl } from 'kubernetes-common/kubectl-object-model'; | |||
import * as utils from '../utils/utilities'; | |||
import * as TaskInputParameters from '../models/TaskInputParameters'; | |||
import {StringComparer, isEqual} from '../utils/StringComparison'; |
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 is missing
This introduced a regression bug. The use case below was working, and now it isn't. Given the spec below with an untagged image, the task should be able to correctly apply the tag at deploy time. spec:
containers:
- name: myapp
image: myrepo.azurecr.io/myapp - task: KubernetesManifest@0
displayName: Deploy application
inputs:
action: deploy
manifests: kubernetes/deployment.yaml
containers: 'myrepo.azurecr.io/myapp:$(Build.BuildID)' This is currently not working anymore, unless you do something like spec:
containers:
- name: myapp
image: myrepo.azurecr.io/myapp:dummytag |
@bansalaseem @DS-MS PTAL. |
While using this task, I encountered some strange behavior. Using a deployment file (snippet) like:
And a containers element in my task definition like:
I got the following output which is incorrect and potentially dangerous because of unexpected containers being deployed
This PR fixes that issue and only matches when there is a full match on the target image name. The solution is still doing raw string processing. Personally I would prefer using a Yaml lib (or even Kubernetes Yaml model) for parsing the incoming Yaml file but there are probably reasons for not doing this.
While writing test cases, I encountered runtime errors because of a circular import between
utilities.ts
andconstants.ts
. Because of that I moved the string equality utility to a separate file. This resolved the issue.Note that I'm completely new to TypeScript (did some JS before) so please forgive possible style and convention mistakes.