github.com/caicloud/helm@v2.5.0+incompatible/pkg/engine/pollute.go (about) 1 /* 2 Copyright 2016 The Kubernetes Authors All rights reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package engine 18 19 import ( 20 "fmt" 21 22 "k8s.io/helm/pkg/releaseutil" 23 ) 24 25 // pollute adds pollutant to resource annotations. 26 func pollute(resources string, r *renderable) string { 27 annos := make(map[releaseutil.AnnotationKey]string) 28 values := r.vals.AsMap() 29 if rmap, ok := values["Release"]; ok { 30 if release, ok := rmap.(map[string]interface{}); ok { 31 if value, ok := release["Namespace"]; ok { 32 annos[releaseutil.DefaultNamespaceKey] = fmt.Sprint(value) 33 } 34 if value, ok := release["Name"]; ok { 35 annos[releaseutil.DefaultReleaseKey] = fmt.Sprint(value) 36 } 37 } 38 } 39 annos[releaseutil.DefaultPathKey] = r.path 40 docs := releaseutil.SplitManifests(resources) 41 result := "" 42 for _, doc := range docs { 43 if result != "" { 44 result += "\n---\n" 45 } 46 result += releaseutil.InjectAnnotations(doc, annos) 47 } 48 return result 49 }