-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
984 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
## kyverno-json jp | ||
|
||
Provides a command-line interface to JMESPath, enhanced with custom functions. | ||
|
||
### Synopsis | ||
|
||
Provides a command-line interface to JMESPath, enhanced with custom functions. | ||
|
||
|
||
``` | ||
kyverno-json jp [flags] | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
# List functions | ||
kyverno-json jp function | ||
# Evaluate query | ||
kyverno-json jp query -i object.yaml 'request.object.metadata.name | truncate(@, `9`)' | ||
# Parse expression | ||
kyverno-json jp parse 'request.object.metadata.name | truncate(@, `9`)' | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for jp | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [kyverno-json](kyverno-json.md) - kyverno-json | ||
* [kyverno-json jp function](kyverno-json_jp_function.md) - Provides function informations. | ||
* [kyverno-json jp parse](kyverno-json_jp_parse.md) - Parses jmespath expression and shows corresponding AST. | ||
* [kyverno-json jp query](kyverno-json_jp_query.md) - Provides a command-line interface to JMESPath, enhanced with Kyverno specific custom functions. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## kyverno-json jp function | ||
|
||
Provides function informations. | ||
|
||
### Synopsis | ||
|
||
Provides function informations. | ||
|
||
|
||
``` | ||
kyverno-json jp function [function_name]... [flags] | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
# List functions | ||
jp function | ||
# Get function infos | ||
jp function truncate | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for function | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [kyverno-json jp](kyverno-json_jp.md) - Provides a command-line interface to JMESPath, enhanced with custom functions. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
## kyverno-json jp parse | ||
|
||
Parses jmespath expression and shows corresponding AST. | ||
|
||
### Synopsis | ||
|
||
Parses jmespath expression and shows corresponding AST. | ||
|
||
``` | ||
kyverno-json jp parse [-f file|expression]... [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-f, --file strings Read input from a JSON or YAML file instead of stdin | ||
-h, --help help for parse | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [kyverno-json jp](kyverno-json_jp.md) - Provides a command-line interface to JMESPath, enhanced with custom functions. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## kyverno-json jp query | ||
|
||
Provides a command-line interface to JMESPath, enhanced with Kyverno specific custom functions. | ||
|
||
### Synopsis | ||
|
||
Provides a command-line interface to JMESPath, enhanced with Kyverno specific custom functions. | ||
|
||
``` | ||
kyverno-json jp query [-i input] [-q query|query]... [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-c, --compact Produce compact JSON output that omits non essential whitespace | ||
-h, --help help for query | ||
-i, --input string Read input from a JSON or YAML file instead of stdin | ||
-q, --query strings Read JMESPath expression from the specified file | ||
-u, --unquoted If the final result is a string, it will be printed without quotes | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [kyverno-json jp](kyverno-json_jp.md) - Provides a command-line interface to JMESPath, enhanced with custom functions. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package command | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
type Command struct { | ||
parent *cobra.Command | ||
experimental bool | ||
description []string | ||
websiteUrl string | ||
examples []Example | ||
} | ||
|
||
func new(parent *cobra.Command, experimental bool, options ...option) Command { | ||
cmd := Command{ | ||
parent: parent, | ||
experimental: experimental, | ||
} | ||
for _, opt := range options { | ||
if opt != nil { | ||
opt(&cmd) | ||
} | ||
} | ||
return cmd | ||
} | ||
|
||
func New(parent *cobra.Command, options ...option) Command { | ||
return new(parent, false, options...) | ||
} | ||
|
||
func NewExperimental(parent *cobra.Command, options ...option) Command { | ||
return new(parent, true, options...) | ||
} | ||
|
||
func Description(c Command, short bool) string { | ||
if len(c.description) == 0 { | ||
return "" | ||
} | ||
var lines []string | ||
lines = append(lines, c.description[0]) | ||
if !short { | ||
lines = append(lines, "") | ||
lines = append(lines, c.description[1:]...) | ||
if c.experimental { | ||
lines = append(lines, "", "NOTE: This is an experimental command.") | ||
} | ||
if c.websiteUrl != "" { | ||
lines = append(lines, "", "For more information visit "+c.websiteUrl) | ||
} | ||
} | ||
return strings.Join(lines, "\n") | ||
} | ||
|
||
func Examples(c Command) string { | ||
if len(c.examples) == 0 { | ||
return "" | ||
} | ||
var useLine string | ||
if c.parent != nil { | ||
useLine = c.parent.UseLine() + " " | ||
} | ||
var lines []string | ||
for _, example := range c.examples { | ||
lines = append(lines, " # "+example.title) | ||
lines = append(lines, " "+useLine+example.command) | ||
lines = append(lines, "") | ||
} | ||
return strings.Join(lines, "\n") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package command | ||
|
||
type Example struct { | ||
title string | ||
command string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package command | ||
|
||
type option = func(*Command) | ||
|
||
func WithDescription(description ...string) option { | ||
return func(d *Command) { | ||
d.description = description | ||
} | ||
} | ||
|
||
func WithWebsiteUrl(websiteUrl string) option { | ||
return func(d *Command) { | ||
d.websiteUrl = websiteUrl | ||
} | ||
} | ||
|
||
func WithExample(title, command string) option { | ||
return func(d *Command) { | ||
d.examples = append(d.examples, Example{ | ||
title: title, | ||
command: command, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.