From c9312129ef3563fbf11ceed4e11e1a4113e0300f Mon Sep 17 00:00:00 2001 From: Kazuki Suda <230185+superbrothers@users.noreply.github.com> Date: Sat, 9 Mar 2019 01:41:12 +0900 Subject: [PATCH] Add `spec.homepage` field to the plugin manifest (#158) * Add `spec.homepage` field to the plugin manifest The `spec.homepage` field of the plugin manifest defines the url of the plugin project homepage. The field value should be a valid url. In addition, if the `spec.homepage` field is defined in plugin manifest, `kubectl krew info` command displays that field value as HOMEPAGE as follows: $ kubectl krew info krew NAME: krew URI: https://storage.googleapis.com/krew/v0.2.1/krew.tar.gz SHA256: dc2f2e1ec8a0acb6f3e23580d4a8b38c44823e948c40342e13ff6e8e12edb15a VERSION: v0.2.1 HOMEPAGE: https://github.com/GoogleContainerTools/krew ... * Reorder the output fields of `krew info` command By this change, the output fields of `krew info` command are reordered as follows: ``` $ out/bin/krew-darwin_amd64 info krew NAME: krew URI: https://storage.googleapis.com/krew/v0.2.1/krew.tar.gz SHA256: dc2f2e1ec8a0acb6f3e23580d4a8b38c44823e948c40342e13ff6e8e12edb15a VERSION: v0.2.1 HOMEPAGE: https://github.com/GoogleContainerTools/krew CAVEATS: \ ... ``` * Edit testdata to add homepage field * Remove validating code for homepage field --- cmd/krew/cmd/info.go | 9 ++++++--- docs/DEVELOPER_GUIDE.md | 1 + .../indexscanner/testdata/testindex/plugins/foo.yaml | 2 +- pkg/index/types.go | 1 + pkg/index/validate_test.go | 1 + 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cmd/krew/cmd/info.go b/cmd/krew/cmd/info.go index 54ba4c27..e4dd856d 100644 --- a/cmd/krew/cmd/info.go +++ b/cmd/krew/cmd/info.go @@ -68,12 +68,15 @@ func printPluginInfo(out io.Writer, plugin index.Plugin) { fmt.Fprintf(out, "SHA256: %s\n", platform.Sha256) } } - if plugin.Spec.Description != "" { - fmt.Fprintf(out, "DESCRIPTION: \n%s\n", plugin.Spec.Description) - } if plugin.Spec.Version != "" { fmt.Fprintf(out, "VERSION: %s\n", plugin.Spec.Version) } + if plugin.Spec.Homepage != "" { + fmt.Fprintf(out, "HOMEPAGE: %s\n", plugin.Spec.Homepage) + } + if plugin.Spec.Description != "" { + fmt.Fprintf(out, "DESCRIPTION: \n%s\n", plugin.Spec.Description) + } if plugin.Spec.Caveats != "" { fmt.Fprintln(out, prepCaveats(plugin.Spec.Caveats)) } diff --git a/docs/DEVELOPER_GUIDE.md b/docs/DEVELOPER_GUIDE.md index 00f4dc19..1bf77436 100644 --- a/docs/DEVELOPER_GUIDE.md +++ b/docs/DEVELOPER_GUIDE.md @@ -109,6 +109,7 @@ spec: to: "." # '.' refers to the root of plugin install directory bin: "./kubectl-foo" # path to the plugin executable after copying files above shortDescription: Prints the environment variables. + homepage: https://github.com/GoogleContainerTools/krew # optional, url for the project homepage # (optional) use caveats field to show post-installation recommendations caveats: | This plugin needs the following programs: diff --git a/pkg/index/indexscanner/testdata/testindex/plugins/foo.yaml b/pkg/index/indexscanner/testdata/testindex/plugins/foo.yaml index 4f050cb9..3fa8555d 100644 --- a/pkg/index/indexscanner/testdata/testindex/plugins/foo.yaml +++ b/pkg/index/indexscanner/testdata/testindex/plugins/foo.yaml @@ -33,4 +33,4 @@ spec: matchLabels: os: "windows" shortDescription: "exists" - + homepage: "https://example.com/foo" diff --git a/pkg/index/types.go b/pkg/index/types.go index 9c4c9f65..5b7f6e47 100644 --- a/pkg/index/types.go +++ b/pkg/index/types.go @@ -33,6 +33,7 @@ type PluginSpec struct { ShortDescription string `json:"shortDescription,omitempty"` Description string `json:"description,omitempty"` Caveats string `json:"caveats,omitempty"` + Homepage string `json:"homepage,omitempty"` Platforms []Platform `json:"platforms,omitempty"` } diff --git a/pkg/index/validate_test.go b/pkg/index/validate_test.go index 60f4c8dd..87022111 100644 --- a/pkg/index/validate_test.go +++ b/pkg/index/validate_test.go @@ -112,6 +112,7 @@ func TestPlugin_Validate(t *testing.T) { ShortDescription: "short", Description: "", Caveats: "", + Homepage: "", Platforms: []Platform{{ Head: "http://example.com", URI: "",