Skip to content

Commit d40e7de

Browse files
Add types for structured function results (#1629)
1 parent 6219473 commit d40e7de

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

pkg/api/fnresult/v1alpha2/types.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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 v1alpha2
16+
17+
import (
18+
kptfilev1alpha2 "github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1alpha2"
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+
ExecPath string `yaml:"exec,omitempty"`
30+
// Stderr is the content in function stderr
31+
Stderr string `yaml:"stderr,omitempty"`
32+
// ExitCode is the exit code from running the function
33+
ExitCode int `yaml:"exitCode,omitempty"`
34+
// Results is the list of results for the function
35+
Results []framework.ResultItem `yaml:"results,omitempty"`
36+
}
37+
38+
const (
39+
ResultListKind = "FunctionResultList"
40+
ResultListGroup = kptfilev1alpha2.KptFileGroup
41+
ResultListVersion = kptfilev1alpha2.KptFileVersion
42+
ResultListAPIVersion = ResultListGroup + "/" + ResultListVersion
43+
)
44+
45+
// ResultList contains aggregated results from multiple functions
46+
type ResultList struct {
47+
yaml.ResourceMeta `yaml:",inline"`
48+
// ExitCode is the exit code of kpt command
49+
ExitCode int `yaml:"exitCode,omitempty"`
50+
// Items contain a list of function result
51+
Items []Result `yaml:"items,omitempty"`
52+
}

0 commit comments

Comments
 (0)