From d40e7deb3dd1a750af36b26bcdaa980199d32dc0 Mon Sep 17 00:00:00 2001 From: Donny Xia Date: Fri, 30 Apr 2021 15:24:06 -0700 Subject: [PATCH] Add types for structured function results (#1629) --- pkg/api/fnresult/v1alpha2/types.go | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 pkg/api/fnresult/v1alpha2/types.go diff --git a/pkg/api/fnresult/v1alpha2/types.go b/pkg/api/fnresult/v1alpha2/types.go new file mode 100644 index 0000000000..4e420a5052 --- /dev/null +++ b/pkg/api/fnresult/v1alpha2/types.go @@ -0,0 +1,52 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v1alpha2 + +import ( + kptfilev1alpha2 "github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1alpha2" + "sigs.k8s.io/kustomize/kyaml/fn/framework" + "sigs.k8s.io/kustomize/kyaml/yaml" +) + +// Result contains the structured result from an individual function +type Result struct { + // Image is the full name of the image that generates this result + // Image and Exec are mutually exclusive + Image string `yaml:"image,omitempty"` + // ExecPath is the the absolute os-specific path to the executable file + ExecPath string `yaml:"exec,omitempty"` + // Stderr is the content in function stderr + Stderr string `yaml:"stderr,omitempty"` + // ExitCode is the exit code from running the function + ExitCode int `yaml:"exitCode,omitempty"` + // Results is the list of results for the function + Results []framework.ResultItem `yaml:"results,omitempty"` +} + +const ( + ResultListKind = "FunctionResultList" + ResultListGroup = kptfilev1alpha2.KptFileGroup + ResultListVersion = kptfilev1alpha2.KptFileVersion + ResultListAPIVersion = ResultListGroup + "/" + ResultListVersion +) + +// ResultList contains aggregated results from multiple functions +type ResultList struct { + yaml.ResourceMeta `yaml:",inline"` + // ExitCode is the exit code of kpt command + ExitCode int `yaml:"exitCode,omitempty"` + // Items contain a list of function result + Items []Result `yaml:"items,omitempty"` +}