Skip to content

Commit

Permalink
Add spec.homepage field to the plugin manifest (#158)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
superbrothers authored and ahmetb committed Mar 8, 2019
1 parent c94ea89 commit c931212
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions cmd/krew/cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
1 change: 1 addition & 0 deletions docs/DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pkg/index/indexscanner/testdata/testindex/plugins/foo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ spec:
matchLabels:
os: "windows"
shortDescription: "exists"

homepage: "https://example.com/foo"
1 change: 1 addition & 0 deletions pkg/index/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
1 change: 1 addition & 0 deletions pkg/index/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func TestPlugin_Validate(t *testing.T) {
ShortDescription: "short",
Description: "",
Caveats: "",
Homepage: "",
Platforms: []Platform{{
Head: "http://example.com",
URI: "",
Expand Down

0 comments on commit c931212

Please sign in to comment.