mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 00:52:55 +00:00
Add support for config.k8s.io/function annotation
This commit is contained in:
@@ -197,6 +197,13 @@ func GetContainerName(n *yaml.RNode) (string, string) {
|
||||
// path to the function, this will be mounted into the container
|
||||
path := meta.Annotations[kioutil.PathAnnotation]
|
||||
|
||||
functionAnnotation := meta.Annotations["config.k8s.io/function"]
|
||||
if functionAnnotation != "" {
|
||||
annotationContent, _ := yaml.Parse(functionAnnotation)
|
||||
image, _ := annotationContent.Pipe(yaml.Lookup("container", "image"))
|
||||
return image.YNode().Value, path
|
||||
}
|
||||
|
||||
container := meta.Annotations["config.kubernetes.io/container"]
|
||||
if container != "" {
|
||||
return container, path
|
||||
|
||||
@@ -316,7 +316,7 @@ metadata:
|
||||
c, _ := GetContainerName(n)
|
||||
assert.Equal(t, "gcr.io/foo/bar:something", c)
|
||||
|
||||
// container from annotation
|
||||
// container from config.kubernetes.io/container annotation
|
||||
n, err = yaml.Parse(`apiVersion: v1
|
||||
kind: MyThing
|
||||
metadata:
|
||||
@@ -329,6 +329,21 @@ metadata:
|
||||
c, _ = GetContainerName(n)
|
||||
assert.Equal(t, "gcr.io/foo/bar:something", c)
|
||||
|
||||
// container from config.k8s.io/function annotation
|
||||
n, err = yaml.Parse(`apiVersion: v1
|
||||
kind: MyThing
|
||||
metadata:
|
||||
annotations:
|
||||
config.k8s.io/function: |
|
||||
container:
|
||||
image: gcr.io/foo/bar:something
|
||||
`)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
c, _ = GetContainerName(n)
|
||||
assert.Equal(t, "gcr.io/foo/bar:something", c)
|
||||
|
||||
// doesn't have a container
|
||||
n, err = yaml.Parse(`apiVersion: v1
|
||||
kind: MyThing
|
||||
|
||||
Reference in New Issue
Block a user