mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Merge pull request #2010 from prachirp/funcAnnotation
Add support for config.k8s.io/function annotation
This commit is contained in:
@@ -596,6 +596,7 @@ sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbL
|
|||||||
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
|
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
|
||||||
sigs.k8s.io/kustomize/api v0.3.0 h1:e7Erw2n8lT8+IWUukktozF0bgWwH2fFC+qsXP0gabg0=
|
sigs.k8s.io/kustomize/api v0.3.0 h1:e7Erw2n8lT8+IWUukktozF0bgWwH2fFC+qsXP0gabg0=
|
||||||
sigs.k8s.io/kustomize/api v0.3.0/go.mod h1:4jaPCtRzxfQLFdYq4gYo40dBGW1hyPp/f4AuiZB5dAQ=
|
sigs.k8s.io/kustomize/api v0.3.0/go.mod h1:4jaPCtRzxfQLFdYq4gYo40dBGW1hyPp/f4AuiZB5dAQ=
|
||||||
|
sigs.k8s.io/kustomize/api v0.3.1 h1:oqMIXvS6tFEUVuKIRUKDa05eC4Hh+cb9JYg8Zhp2d24=
|
||||||
sigs.k8s.io/kustomize/api v0.3.1/go.mod h1:A+ATnlHqzictQfQC1q3KB/T6MSr0UWQsrrLxMWkge2E=
|
sigs.k8s.io/kustomize/api v0.3.1/go.mod h1:A+ATnlHqzictQfQC1q3KB/T6MSr0UWQsrrLxMWkge2E=
|
||||||
sigs.k8s.io/kustomize/cmd/config v0.0.2 h1:FphfIoGJ0jGGJJXq9WoG5sqqEIuTeDGx58E5NWHV8Hc=
|
sigs.k8s.io/kustomize/cmd/config v0.0.2 h1:FphfIoGJ0jGGJJXq9WoG5sqqEIuTeDGx58E5NWHV8Hc=
|
||||||
sigs.k8s.io/kustomize/cmd/config v0.0.2/go.mod h1:c6IBoPpAAm5a2aD+0iH8IfeyCF5GPsY5Ws57Dwpcvg0=
|
sigs.k8s.io/kustomize/cmd/config v0.0.2/go.mod h1:c6IBoPpAAm5a2aD+0iH8IfeyCF5GPsY5Ws57Dwpcvg0=
|
||||||
|
|||||||
@@ -197,6 +197,13 @@ func GetContainerName(n *yaml.RNode) (string, string) {
|
|||||||
// path to the function, this will be mounted into the container
|
// path to the function, this will be mounted into the container
|
||||||
path := meta.Annotations[kioutil.PathAnnotation]
|
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"]
|
container := meta.Annotations["config.kubernetes.io/container"]
|
||||||
if container != "" {
|
if container != "" {
|
||||||
return container, path
|
return container, path
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ metadata:
|
|||||||
c, _ := GetContainerName(n)
|
c, _ := GetContainerName(n)
|
||||||
assert.Equal(t, "gcr.io/foo/bar:something", c)
|
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
|
n, err = yaml.Parse(`apiVersion: v1
|
||||||
kind: MyThing
|
kind: MyThing
|
||||||
metadata:
|
metadata:
|
||||||
@@ -329,6 +329,21 @@ metadata:
|
|||||||
c, _ = GetContainerName(n)
|
c, _ = GetContainerName(n)
|
||||||
assert.Equal(t, "gcr.io/foo/bar:something", c)
|
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
|
// doesn't have a container
|
||||||
n, err = yaml.Parse(`apiVersion: v1
|
n, err = yaml.Parse(`apiVersion: v1
|
||||||
kind: MyThing
|
kind: MyThing
|
||||||
|
|||||||
Reference in New Issue
Block a user