github.com/wmuizelaar/kpt@v0.0.0-20221018115725-bd564717b2ed/pkg/api/fnresult/v1/types.go (about) 1 // Copyright 2021 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package v1 16 17 import ( 18 "k8s.io/apimachinery/pkg/runtime/schema" 19 "sigs.k8s.io/kustomize/kyaml/fn/framework" 20 "sigs.k8s.io/kustomize/kyaml/yaml" 21 ) 22 23 // Result contains the structured result from an individual function 24 type Result struct { 25 // Image is the full name of the image that generates this result 26 // Image and Exec are mutually exclusive 27 Image string `yaml:"image,omitempty"` 28 // ExecPath is the the absolute os-specific path to the executable file 29 // If user provides an executable file with commands, ExecPath should 30 // contain the entire input string. 31 ExecPath string `yaml:"exec,omitempty"` 32 // TODO(droot): This is required for making structured results subpackage aware. 33 // Enable this once test harness supports filepath based assertions. 34 // Pkg is OS specific Absolute path to the package. 35 // Pkg string `yaml:"pkg,omitempty"` 36 // Stderr is the content in function stderr 37 Stderr string `yaml:"stderr,omitempty"` 38 // ExitCode is the exit code from running the function 39 ExitCode int `yaml:"exitCode"` 40 // Results is the list of results for the function 41 Results framework.Results `yaml:"results,omitempty"` 42 } 43 44 const ( 45 // Deprecated: prefer ResultListGVK 46 ResultListKind = "FunctionResultList" 47 // Deprecated: prefer ResultListGVK 48 ResultListGroup = "kpt.dev" 49 // Deprecated: prefer ResultListGVK 50 ResultListVersion = "v1" 51 // Deprecated: prefer ResultListGVK 52 ResultListAPIVersion = ResultListGroup + "/" + ResultListVersion 53 ) 54 55 // KptFileGVK is the GroupVersionKind of FunctionResultList objects 56 func ResultListGVK() schema.GroupVersionKind { 57 return schema.GroupVersionKind{ 58 Group: "kpt.dev", 59 Version: "v1", 60 Kind: "FunctionResultList", 61 } 62 } 63 64 // ResultList contains aggregated results from multiple functions 65 type ResultList struct { 66 yaml.ResourceMeta `yaml:",inline"` 67 // ExitCode is the exit code of kpt command 68 ExitCode int `yaml:"exitCode"` 69 // Items contain a list of function result 70 Items []Result `yaml:"items,omitempty"` 71 } 72 73 // NewResultList returns an instance of ResultList with metadata 74 // field populated. 75 func NewResultList() *ResultList { 76 return &ResultList{ 77 ResourceMeta: yaml.ResourceMeta{ 78 TypeMeta: yaml.TypeMeta{ 79 APIVersion: ResultListAPIVersion, 80 Kind: ResultListKind, 81 }, 82 ObjectMeta: yaml.ObjectMeta{ 83 NameMeta: yaml.NameMeta{ 84 Name: "fnresults", 85 }, 86 }, 87 }, 88 Items: []Result{}, 89 } 90 }