Skip to content

Commit fa499d6

Browse files
authored
Add kptfile schema to make generate (#2394)
* Add goswagger to package. * Change github widget function loading method. * Change package definition title. * Add kptfile schema generation make command. * Move to make generate command. * Run go mod tidy. * Refer to $GOBIN/swagger. * go get all deps on generate. * Add GOBIN. * Explicitly install go-swagger. * Don't run mod tidy. * make build pass * Change anon func usage in copy buttons. * Remove unnecessary go.mod changes. * Pin go-swagger version.
1 parent 1737e47 commit fa499d6

File tree

7 files changed

+328
-10
lines changed

7 files changed

+328
-10
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ fmt:
4545
go fmt ./...
4646

4747
generate:
48-
go install ./mdtogo
48+
go install ./mdtogo
49+
(which swagger || go install github.com/go-swagger/go-swagger/cmd/[email protected])
4950
rm -rf internal/docs/generated
5051
mkdir internal/docs/generated
5152
GOBIN=$(GOBIN) go generate ./...

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,8 +933,6 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
933933
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
934934
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
935935
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
936-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
937-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
938936
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
939937
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
940938
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
//go:generate $GOBIN/mdtogo site/reference/cli/pkg internal/docs/generated/pkgdocs --license=none --recursive=true --strategy=cmdDocs
1717
//go:generate $GOBIN/mdtogo site/reference/cli/fn internal/docs/generated/fndocs --license=none --recursive=true --strategy=cmdDocs
1818
//go:generate $GOBIN/mdtogo site/reference/cli/README.md internal/docs/generated/overview --license=none --strategy=cmdDocs
19+
//go:generate $GOBIN/swagger generate spec -m -w pkg/api/kptfile/v1 -o site/reference/schema/kptfile/kptfile.yaml
1920
package main
2021

2122
import (

pkg/api/kptfile/v1/types.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
// Package defines the schema for Kptfile version v1.
15+
// Package defines Kptfile schema.
16+
// Version: v1
17+
// swagger:meta
1618
package v1
1719

1820
import (
@@ -38,6 +40,7 @@ var TypeMeta = yaml.ResourceMeta{
3840
}
3941

4042
// KptFile contains information about a package managed with kpt.
43+
// swagger:model kptfile
4144
type KptFile struct {
4245
yaml.ResourceMeta `yaml:",inline"`
4346

Lines changed: 315 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,315 @@
1+
definitions:
2+
Function:
3+
properties:
4+
ConfigMap:
5+
additionalProperties:
6+
type: string
7+
description: '`ConfigMap` is a convenient way to specify a function config
8+
of kind ConfigMap.'
9+
type: object
10+
ConfigPath:
11+
description: |-
12+
`ConfigPath` specifies a slash-delimited relative path to a file in the current directory
13+
containing a KRM resource used as the function config. This resource is
14+
excluded when resolving 'sources', and as a result cannot be operated on
15+
by the pipeline.
16+
type: string
17+
Image:
18+
description: |-
19+
`Image` specifies the function container image.
20+
It can either be fully qualified, e.g.:
21+
22+
image: gcr.io/kpt-fn/set-labels
23+
24+
Optionally, kpt can be configured to use a image
25+
registry host-path that will be used to resolve the image path in case
26+
the image path is missing (Defaults to gcr.io/kpt-fn).
27+
e.g. The following resolves to gcr.io/kpt-fn/set-labels:
28+
29+
image: set-labels
30+
type: string
31+
title: Function specifies a KRM function.
32+
type: object
33+
x-go-package: github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1
34+
Git:
35+
properties:
36+
Directory:
37+
description: |-
38+
Directory is the sub directory of the git repository.
39+
e.g. 'staging/cockroachdb'
40+
type: string
41+
Ref:
42+
description: Ref can be a Git branch, tag, or a commit SHA-1.
43+
type: string
44+
Repo:
45+
description: |-
46+
Repo is the git repository the package.
47+
e.g. 'https://github.com/kubernetes/examples.git'
48+
type: string
49+
title: Git is the user-specified locator for a package on Git.
50+
type: object
51+
x-go-package: github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1
52+
GitLock:
53+
properties:
54+
Commit:
55+
description: |-
56+
Commit is the SHA-1 for the last fetch of the package.
57+
This is set by kpt for bookkeeping purposes.
58+
type: string
59+
Directory:
60+
description: |-
61+
Directory is the sub directory of the git repository that was fetched.
62+
e.g. 'staging/cockroachdb'
63+
type: string
64+
Ref:
65+
description: |-
66+
Ref can be a Git branch, tag, or a commit SHA-1 that was fetched.
67+
e.g. 'master'
68+
type: string
69+
Repo:
70+
description: |-
71+
Repo is the git repository that was fetched.
72+
e.g. 'https://github.com/kubernetes/examples.git'
73+
type: string
74+
title: GitLock is the resolved locator for a package on Git.
75+
type: object
76+
x-go-package: github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1
77+
Inventory:
78+
description: All of the the parameters are required if any are set.
79+
properties:
80+
Annotations:
81+
additionalProperties:
82+
type: string
83+
type: object
84+
InventoryID:
85+
description: Unique label to identify inventory resource in cluster.
86+
type: string
87+
Labels:
88+
additionalProperties:
89+
type: string
90+
type: object
91+
Name:
92+
description: Name of the inventory resource.
93+
type: string
94+
Namespace:
95+
description: Namespace for the inventory resource.
96+
type: string
97+
title: Inventory encapsulates the parameters for the inventory resource applied
98+
to a cluster.
99+
type: object
100+
x-go-package: github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1
101+
NameMeta:
102+
properties:
103+
name:
104+
description: Name is the metadata.name field of a Resource
105+
type: string
106+
x-go-name: Name
107+
namespace:
108+
description: Namespace is the metadata.namespace field of a Resource
109+
type: string
110+
x-go-name: Namespace
111+
title: NameMeta contains name information.
112+
type: object
113+
x-go-package: sigs.k8s.io/kustomize/kyaml/yaml
114+
ObjectMeta:
115+
description: ObjectMeta contains metadata about a Resource
116+
properties:
117+
annotations:
118+
additionalProperties:
119+
type: string
120+
description: Annotations is the metadata.annotations field of a Resource.
121+
type: object
122+
x-go-name: Annotations
123+
labels:
124+
additionalProperties:
125+
type: string
126+
description: Labels is the metadata.labels field of a Resource
127+
type: object
128+
x-go-name: Labels
129+
name:
130+
description: Name is the metadata.name field of a Resource
131+
type: string
132+
x-go-name: Name
133+
namespace:
134+
description: Namespace is the metadata.namespace field of a Resource
135+
type: string
136+
x-go-name: Namespace
137+
type: object
138+
x-go-package: sigs.k8s.io/kustomize/kyaml/yaml
139+
OriginType:
140+
title: OriginType defines the type of origin for a package.
141+
type: string
142+
x-go-package: github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1
143+
PackageInfo:
144+
description: |-
145+
These fields are not consumed by any functionality in kpt and are simply passed through.
146+
Note that like any other KRM resource, humans and automation can also use `metadata.labels` and
147+
`metadata.annotations` as the extension mechanism.
148+
properties:
149+
Description:
150+
description: Description contains a short description of the package.
151+
type: string
152+
Emails:
153+
description: Email is the list of emails for the package authors.
154+
items:
155+
type: string
156+
type: array
157+
Keywords:
158+
description: Keywords is a list of keywords for this package.
159+
items:
160+
type: string
161+
type: array
162+
License:
163+
description: 'SPDX license identifier (e.g. "Apache-2.0"). See: https://spdx.org/licenses/'
164+
type: string
165+
LicenseFile:
166+
description: Relative slash-delimited path to the license file (e.g. LICENSE.txt)
167+
type: string
168+
Man:
169+
description: Man is the path to documentation about the package
170+
type: string
171+
Site:
172+
description: Site is the URL for package web page.
173+
type: string
174+
title: PackageInfo contains optional information about the package such as license,
175+
documentation, etc.
176+
type: object
177+
x-go-package: github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1
178+
Pipeline:
179+
properties:
180+
Mutators:
181+
description: Mutators defines a list of of KRM functions that mutate resources.
182+
items:
183+
$ref: '#/definitions/Function'
184+
type: array
185+
Validators:
186+
description: |-
187+
Validators defines a list of KRM functions that validate resources.
188+
Validators are not permitted to mutate resources.
189+
items:
190+
$ref: '#/definitions/Function'
191+
type: array
192+
title: Pipeline declares a pipeline of functions used to mutate or validate resources.
193+
type: object
194+
x-go-package: github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1
195+
ResourceMeta:
196+
properties:
197+
annotations:
198+
additionalProperties:
199+
type: string
200+
description: Annotations is the metadata.annotations field of a Resource.
201+
type: object
202+
x-go-name: Annotations
203+
apiVersion:
204+
description: APIVersion is the apiVersion field of a Resource
205+
type: string
206+
x-go-name: APIVersion
207+
kind:
208+
description: Kind is the kind field of a Resource
209+
type: string
210+
x-go-name: Kind
211+
labels:
212+
additionalProperties:
213+
type: string
214+
description: Labels is the metadata.labels field of a Resource
215+
type: object
216+
x-go-name: Labels
217+
name:
218+
description: Name is the metadata.name field of a Resource
219+
type: string
220+
x-go-name: Name
221+
namespace:
222+
description: Namespace is the metadata.namespace field of a Resource
223+
type: string
224+
x-go-name: Namespace
225+
title: ResourceMeta contains the metadata for a both Resource Type and Resource.
226+
type: object
227+
x-go-package: sigs.k8s.io/kustomize/kyaml/yaml
228+
TypeMeta:
229+
description: |-
230+
TypeMeta partially copies apimachinery/pkg/apis/meta/v1.TypeMeta
231+
No need for a direct dependence; the fields are stable.
232+
properties:
233+
apiVersion:
234+
description: APIVersion is the apiVersion field of a Resource
235+
type: string
236+
x-go-name: APIVersion
237+
kind:
238+
description: Kind is the kind field of a Resource
239+
type: string
240+
x-go-name: Kind
241+
type: object
242+
x-go-package: sigs.k8s.io/kustomize/kyaml/yaml
243+
UpdateStrategyType:
244+
title: UpdateStrategyType defines the strategy for updating a package from upstream.
245+
type: string
246+
x-go-package: github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1
247+
Upstream:
248+
properties:
249+
Git:
250+
$ref: '#/definitions/Git'
251+
Type:
252+
$ref: '#/definitions/OriginType'
253+
UpdateStrategy:
254+
$ref: '#/definitions/UpdateStrategyType'
255+
title: Upstream is a user-specified upstream locator for a package.
256+
type: object
257+
x-go-package: github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1
258+
UpstreamLock:
259+
properties:
260+
Git:
261+
$ref: '#/definitions/GitLock'
262+
Type:
263+
$ref: '#/definitions/OriginType'
264+
title: UpstreamLock is a resolved locator for the last fetch of the package.
265+
type: object
266+
x-go-package: github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1
267+
kptfile:
268+
properties:
269+
Info:
270+
$ref: '#/definitions/PackageInfo'
271+
Inventory:
272+
$ref: '#/definitions/Inventory'
273+
Pipeline:
274+
$ref: '#/definitions/Pipeline'
275+
Upstream:
276+
$ref: '#/definitions/Upstream'
277+
UpstreamLock:
278+
$ref: '#/definitions/UpstreamLock'
279+
annotations:
280+
additionalProperties:
281+
type: string
282+
description: Annotations is the metadata.annotations field of a Resource.
283+
type: object
284+
x-go-name: Annotations
285+
apiVersion:
286+
description: APIVersion is the apiVersion field of a Resource
287+
type: string
288+
x-go-name: APIVersion
289+
kind:
290+
description: Kind is the kind field of a Resource
291+
type: string
292+
x-go-name: Kind
293+
labels:
294+
additionalProperties:
295+
type: string
296+
description: Labels is the metadata.labels field of a Resource
297+
type: object
298+
x-go-name: Labels
299+
name:
300+
description: Name is the metadata.name field of a Resource
301+
type: string
302+
x-go-name: Name
303+
namespace:
304+
description: Namespace is the metadata.namespace field of a Resource
305+
type: string
306+
x-go-name: Namespace
307+
title: KptFile contains information about a package managed with kpt.
308+
type: object
309+
x-go-name: KptFile
310+
x-go-package: github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1
311+
info:
312+
title: Kptfile schema.
313+
version: v1
314+
paths: {}
315+
swagger: "2.0"

site/static/js/plugins/copy_buttons.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ function addCodeCopyButtons() {
4040

4141
// Load plugins into Docsify.
4242
window.$docsify = window.$docsify || {};
43-
window.$docsify.plugins = [(hook, _vm) => hook.doneEach(addCodeCopyButtons)].concat(
44-
window.$docsify.plugins || []
45-
);
43+
window.$docsify.plugins = [].concat(function (hook, _vm) {
44+
hook.doneEach(addCodeCopyButtons);
45+
}, window.$docsify.plugins);
4646

4747
// Export functions for testing.
4848
if (typeof module !== "undefined") {

site/static/js/plugins/github_widget.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ function addGitHubWidget() {
3939

4040
// Load plugins into Docsify.
4141
window.$docsify = window.$docsify || {};
42-
window.$docsify.plugins = [
43-
(hook, _vm) => hook.doneEach(addGitHubWidget),
44-
].concat(window.$docsify.plugins || []);
42+
window.$docsify.plugins = [].concat(function (hook, _vm) {
43+
hook.doneEach(addGitHubWidget);
44+
}, window.$docsify.plugins);
4545

4646
// Export functions for testing.
4747
if (typeof module !== "undefined") {

0 commit comments

Comments
 (0)