rename config.k8s.io/function to config.kubernetes.io/function

This commit is contained in:
Phillip Wittrock
2020-01-07 11:11:59 -08:00
parent 2437e1ffe7
commit 0cae0feb9b
14 changed files with 33 additions and 23 deletions

View File

@@ -194,6 +194,13 @@ func (c *IsReconcilerFilter) Filter(inputs []*yaml.RNode) ([]*yaml.RNode, error)
return out, nil
}
const (
FunctionAnnotationKey = "config.kubernetes.io/function"
oldFunctionAnnotationKey = "config.k8s.io/function"
)
var functionAnnotationKeys = []string{FunctionAnnotationKey, oldFunctionAnnotationKey}
// GetContainerName returns the container image for an API if one exists
func GetContainerName(n *yaml.RNode) (string, string) {
meta, _ := n.GetMeta()
@@ -201,11 +208,14 @@ 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
// check previous keys for backwards compatibility
for _, s := range functionAnnotationKeys {
functionAnnotation := meta.Annotations[s]
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"]

View File

@@ -333,12 +333,12 @@ metadata:
c, _ = GetContainerName(n)
assert.Equal(t, "gcr.io/foo/bar:something", c)
// container from config.k8s.io/function annotation
// container from config.kubernetes.io/function annotation
n, err = yaml.Parse(`apiVersion: v1
kind: MyThing
metadata:
annotations:
config.k8s.io/function: |
config.kubernetes.io/function: |
container:
image: gcr.io/foo/bar:something
`)