1 // Copyright 2019 The Kubernetes Authors. 2 // SPDX-License-Identifier: Apache-2.0 3 4 // Package yaml contains libraries for manipulating individual Kubernetes Resource 5 // Configuration as yaml, keeping yaml structure and comments. 6 // 7 // Parsing Resources 8 // 9 // Typically Resources will be initialized as collections through the kio package libraries. 10 // However it is possible to directly initialize Resources using Parse. 11 // resource, err := yaml.Parse("apiVersion: apps/v1\nkind: Deployment") 12 // 13 // Processing Resources 14 // 15 // Individual Resources are manipulated using the Pipe and PipeE to apply Filter functions 16 // to transform the Resource data. 17 // err := resource.PipeE(yaml.SetAnnotation("key", "value")) 18 // 19 // If multiple Filter functions are provided to Pipe or PipeE, each function is applied to 20 // the result of the last function -- e.g. yaml.Lookup(...), yaml.SetField(...) 21 // 22 // Field values may also be retrieved using Pipe. 23 // annotationValue, err := resource.Pipe(yaml.GetAnnotation("key")) 24 // 25 // See http://www.linfo.org/filters.html for a definition of filters. 26 // 27 // Common Filters 28 // 29 // There are a number of standard filter functions provided by the yaml package. 30 // 31 // Working with annotations: 32 // [AnnotationSetter{}, AnnotationGetter{}, AnnotationClearer{}] 33 // 34 // Working with fields by path: 35 // [PathMatcher{}, PathGetter{}] 36 // 37 // Working with individual fields on Maps and Objects: 38 // [FieldMatcher{}, FieldSetter{}, FieldGetter{}] 39 // 40 // Working with individual elements in Sequences: 41 // [ElementAppender{}, ElementSetter{}, ElementMatcher{}] 42 // 43 // Writing Filters 44 // 45 // Users may implement their own filter functions. When doing so, can be necessary to work with 46 // the RNode directly rather than through Pipe. RNode provides a number of functions for doing 47 // so. See: 48 // [GetMeta(), Fields(), Elements(), String()] 49 package yaml 50