Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions cmd/reporter/approveDeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ type ApprovalPayload struct {
func newApproveDeploymentCmd(out io.Writer) *cobra.Command {
o := new(approvalOptions)
cmd := &cobra.Command{
Use: "approval ARTIFACT-NAME-OR-PATH",
Short: "Approve deploying an artifact in Merkely. ",
Long: approveDeploymentDesc(),
Use: "approval ARTIFACT-NAME-OR-PATH",
Short: "Approve deploying an artifact in Merkely. ",
Long: approveDeploymentDesc(),
DisableAutoGenTag: true,
PreRunE: func(cmd *cobra.Command, args []string) error {
err := RequireGlobalFlags(global, []string{"Owner", "ApiToken"})
if err != nil {
Expand Down Expand Up @@ -98,8 +99,8 @@ func newApproveDeploymentCmd(out io.Writer) *cobra.Command {

func approveDeploymentDesc() string {
return `
Approve a deployment of an artifact in Merkely.
The artifact SHA256 fingerprint is calculated or alternatively it can be provided directly.
Approve a deployment of an artifact in Merkely.
The artifact SHA256 fingerprint is calculated or alternatively it can be provided directly.
`
}

Expand Down
13 changes: 7 additions & 6 deletions cmd/reporter/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ type ArtifactPayload struct {
func newArtifactCmd(out io.Writer) *cobra.Command {
o := new(artifactOptions)
cmd := &cobra.Command{
Use: "artifact ARTIFACT-NAME-OR-PATH",
Short: "Report/Log an artifact to Merkely. ",
Long: artifactDesc(),
Use: "artifact ARTIFACT-NAME-OR-PATH",
Short: "Report/Log an artifact to Merkely. ",
Long: artifactDesc(),
DisableAutoGenTag: true,
PreRunE: func(cmd *cobra.Command, args []string) error {
err := RequireGlobalFlags(global, []string{"Owner", "ApiToken"})
if err != nil {
Expand Down Expand Up @@ -86,8 +87,8 @@ func newArtifactCmd(out io.Writer) *cobra.Command {

func artifactDesc() string {
return `
Report an artifact to a pipeline in Merkely.
The artifact SHA256 fingerprint is calculated and reported
or,alternatively, can be provided directly.
Report an artifact to a pipeline in Merkely.
The artifact SHA256 fingerprint is calculated and reported
or,alternatively, can be provided directly.
` + GetCIDefaultsTemplates(supportedCIs, []string{"git-commit", "build-url", "commit-url"})
}
7 changes: 4 additions & 3 deletions cmd/reporter/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ const controlDesc = `Check if artifact is allowed to be deployed.`

func newControlCmd(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "control",
Short: controlDesc,
Long: controlDesc,
Use: "control",
Short: controlDesc,
Long: controlDesc,
DisableAutoGenTag: true,
}

// Add subcommands
Expand Down
9 changes: 5 additions & 4 deletions cmd/reporter/controlDeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ type controlDeploymentOptions struct {
func newControlDeploymentCmd(out io.Writer) *cobra.Command {
o := new(controlDeploymentOptions)
cmd := &cobra.Command{
Use: "deployment ARTIFACT-NAME-OR-PATH",
Short: "Check if an artifact in Merkely has been approved for deployment.",
Long: controlDeploymentDesc(),
Use: "deployment ARTIFACT-NAME-OR-PATH",
Short: "Check if an artifact in Merkely has been approved for deployment.",
Long: controlDeploymentDesc(),
DisableAutoGenTag: true,
PreRunE: func(cmd *cobra.Command, args []string) error {
err := RequireGlobalFlags(global, []string{"Owner", "ApiToken"})
if err != nil {
Expand Down Expand Up @@ -76,6 +77,6 @@ func newControlDeploymentCmd(out io.Writer) *cobra.Command {

func controlDeploymentDesc() string {
return `Check if an artifact in Merkely has been approved for deployment.
The artifact SHA256 fingerprint is calculated or alternatively it can be provided directly.
The artifact SHA256 fingerprint is calculated or alternatively it can be provided directly.
`
}
7 changes: 4 additions & 3 deletions cmd/reporter/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ const createDesc = `Create objects in Merkely.`

func newCreateCmd(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "create",
Short: createDesc,
Long: createDesc,
Use: "create",
Short: createDesc,
Long: createDesc,
DisableAutoGenTag: true,
}

// Add subcommands
Expand Down
11 changes: 6 additions & 5 deletions cmd/reporter/createEnvironment.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ type CreateEnvironmentPayload struct {
func newEnvironmentCmd(out io.Writer) *cobra.Command {
payload := new(CreateEnvironmentPayload)
cmd := &cobra.Command{
Use: "environment",
Short: "Create a Merkely environment",
Long: createEnvDesc,
Example: createEnvExample,
Args: NoArgs,
Use: "environment",
Short: "Create a Merkely environment",
Long: createEnvDesc,
Example: createEnvExample,
DisableAutoGenTag: true,
Args: NoArgs,
PreRunE: func(cmd *cobra.Command, args []string) error {
err := RequireGlobalFlags(global, []string{"Owner", "ApiToken"})
if err != nil {
Expand Down
13 changes: 7 additions & 6 deletions cmd/reporter/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ type DeploymentPayload struct {
func newDeploymentCmd(out io.Writer) *cobra.Command {
o := new(deploymentOptions)
cmd := &cobra.Command{
Use: "deployment ARTIFACT-NAME-OR-PATH",
Short: "Report/Log a deployment to Merkely. ",
Long: deploymentDesc(),
Use: "deployment ARTIFACT-NAME-OR-PATH",
Short: "Report/Log a deployment to Merkely. ",
Long: deploymentDesc(),
DisableAutoGenTag: true,
PreRunE: func(cmd *cobra.Command, args []string) error {
err := RequireGlobalFlags(global, []string{"Owner", "ApiToken"})
if err != nil {
Expand Down Expand Up @@ -82,8 +83,8 @@ func newDeploymentCmd(out io.Writer) *cobra.Command {

func deploymentDesc() string {
return `
Report a deployment of an artifact to an environment in Merkely.
The artifact SHA256 fingerprint is calculated and reported
or,alternatively, can be provided directly.
Report a deployment of an artifact to an environment in Merkely.
The artifact SHA256 fingerprint is calculated and reported
or,alternatively, can be provided directly.
` + GetCIDefaultsTemplates(supportedCIs, []string{"build-url"})
}
11 changes: 6 additions & 5 deletions cmd/reporter/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ func newDocsCmd(out io.Writer) *cobra.Command {
o := &docsOptions{}

cmd := &cobra.Command{
Use: "docs",
Short: "generate documentation as markdown",
Long: docsDesc,
Hidden: true,
Args: NoArgs,
Use: "docs",
Short: "generate documentation as markdown",
Long: docsDesc,
Hidden: true,
Args: NoArgs,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, args []string) error {
o.topCmd = cmd.Root()
return o.run(out)
Expand Down
13 changes: 7 additions & 6 deletions cmd/reporter/ecsEnv.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
)

const ecsEnvDesc = `
List the artifacts deployed in an AWS ECS cluster and their digests
and report them to Merkely.
List the artifacts deployed in an AWS ECS cluster and their digests
and report them to Merkely.
`

const ecsEnvExample = `
Expand All @@ -29,10 +29,11 @@ type ecsEnvOptions struct {
func newEcsEnvCmd(out io.Writer) *cobra.Command {
o := new(ecsEnvOptions)
cmd := &cobra.Command{
Use: "ecs env-name",
Short: "Report images data from AWS ECS cluster to Merkely.",
Long: ecsEnvDesc,
Example: ecsEnvExample,
Use: "ecs env-name",
Short: "Report images data from AWS ECS cluster to Merkely.",
Long: ecsEnvDesc,
Example: ecsEnvExample,
DisableAutoGenTag: true,
PreRunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 1 {
return fmt.Errorf("only environment name argument is allowed")
Expand Down
9 changes: 5 additions & 4 deletions cmd/reporter/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ This allows Merkely to determine Runtime compliance status of the environment.

func newEnvCmd(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "env",
Short: "Report running artifacts in an environment to Merkely.",
Long: envDesc,
Aliases: []string{"environment"},
Use: "env",
Short: "Report running artifacts in an environment to Merkely.",
Long: envDesc,
DisableAutoGenTag: true,
Aliases: []string{"environment"},
}

// Add subcommands
Expand Down
11 changes: 6 additions & 5 deletions cmd/reporter/evidence.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ type EvidencePayload struct {
func newEvidenceCmd(out io.Writer) *cobra.Command {
o := new(evidenceOptions)
cmd := &cobra.Command{
Use: "evidence ARTIFACT-NAME-OR-PATH",
Short: "Report/Log an evidence to an artifact in Merkely. ",
Long: evidenceDesc(),
Use: "evidence ARTIFACT-NAME-OR-PATH",
Short: "Report/Log an evidence to an artifact in Merkely. ",
Long: evidenceDesc(),
DisableAutoGenTag: true,
PreRunE: func(cmd *cobra.Command, args []string) error {
err := RequireGlobalFlags(global, []string{"Owner", "ApiToken"})
if err != nil {
Expand Down Expand Up @@ -87,7 +88,7 @@ func newEvidenceCmd(out io.Writer) *cobra.Command {

func evidenceDesc() string {
return `
Report an evidence to an artifact in Merkely.
The artifact SHA256 fingerprint is calculated or alternatively it can be provided directly.
Report an evidence to an artifact in Merkely.
The artifact SHA256 fingerprint is calculated or alternatively it can be provided directly.
` + GetCIDefaultsTemplates(supportedCIs, []string{"build-url"})
}
7 changes: 4 additions & 3 deletions cmd/reporter/fingerprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ type fingerprintOptions struct {
func newFingerprintCmd(out io.Writer) *cobra.Command {
o := new(fingerprintOptions)
cmd := &cobra.Command{
Use: "fingerprint",
Short: "Print the SHA256 fingerprint of an artifact.",
Long: fingerprintDesc,
Use: "fingerprint",
Short: "Print the SHA256 fingerprint of an artifact.",
Long: fingerprintDesc,
DisableAutoGenTag: true,
PreRunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 1 {
return fmt.Errorf("only one argument (docker image name or file/dir path) is allowed")
Expand Down
17 changes: 9 additions & 8 deletions cmd/reporter/k8sEnv.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import (
)

const k8sEnvDesc = `
List the artifacts deployed in the k8s environment and their digests
and report them to Merkely.
List the artifacts deployed in the k8s environment and their digests
and report them to Merkely.
`

const k8sEnvExample = `
* report what's running in an entire cluster using kubeconfig at $HOME/.kube/config:
merkely report env k8s prod --api-token 1234 --owner exampleOrg --id prod-cluster

* report what's running in an entire cluster using kubeconfig at $HOME/.kube/config
* report what's running in an entire cluster using kubeconfig at $HOME/.kube/config
(with global flags defined in environment or in a config file):
merkely report env k8s prod

Expand Down Expand Up @@ -57,11 +57,12 @@ func newK8sEnvCmd(out io.Writer) *cobra.Command {

o := new(k8sEnvOptions)
cmd := &cobra.Command{
Use: "k8s [-n namespace | -x namespace]... [-k /path/to/kube/config] [-i infrastructure-identifier] env-name",
Short: "Report images data from specific namespace(s) or entire cluster to Merkely.",
Long: k8sEnvDesc,
Aliases: []string{"kubernetes"},
Example: k8sEnvExample,
Use: "k8s [-n namespace | -x namespace]... [-k /path/to/kube/config] [-i infrastructure-identifier] env-name",
Short: "Report images data from specific namespace(s) or entire cluster to Merkely.",
Long: k8sEnvDesc,
Aliases: []string{"kubernetes"},
Example: k8sEnvExample,
DisableAutoGenTag: true,
PreRunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 1 {
return fmt.Errorf("only environment name argument is allowed")
Expand Down
11 changes: 6 additions & 5 deletions cmd/reporter/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

const pipelineDesc = `
Create a Merkely pipeline by providing a JSON pipefile.
Create a Merkely pipeline by providing a JSON pipefile.
The pipefile contains the pipeline metadata and compliance template.
`

Expand Down Expand Up @@ -45,10 +45,11 @@ type Pipefile struct {

func newPipelineCmd(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "pipeline",
Short: "Create a Merkely pipeline",
Long: pipelineDesc,
Example: pipelineExample,
Use: "pipeline",
Short: "Create a Merkely pipeline",
Long: pipelineDesc,
Example: pipelineExample,
DisableAutoGenTag: true,
PreRunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 1 {
return fmt.Errorf("only pipefile path argument is allowed")
Expand Down
9 changes: 5 additions & 4 deletions cmd/reporter/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ Report compliance events back to Merkely.

func newReportCmd(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "report",
Short: "Report compliance events to Merkely.",
Long: reportDesc,
Aliases: []string{"log"},
Use: "report",
Short: "Report compliance events to Merkely.",
Long: reportDesc,
DisableAutoGenTag: true,
Aliases: []string{"log"},
//SuggestFor: []string{"reportenv", "env report", "envreport"},
}

Expand Down
9 changes: 5 additions & 4 deletions cmd/reporter/requestApproval.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (
func newRequestApprovalCmd(out io.Writer) *cobra.Command {
o := new(approvalOptions)
cmd := &cobra.Command{
Use: "request ARTIFACT-NAME-OR-PATH",
Short: "Request an approval for deploying an artifact in Merkely. ",
Long: requestApprovalDesc(),
Use: "request ARTIFACT-NAME-OR-PATH",
Short: "Request an approval for deploying an artifact in Merkely. ",
Long: requestApprovalDesc(),
DisableAutoGenTag: true,
PreRunE: func(cmd *cobra.Command, args []string) error {
err := RequireGlobalFlags(global, []string{"Owner", "ApiToken"})
if err != nil {
Expand Down Expand Up @@ -71,6 +72,6 @@ func newRequestApprovalCmd(out io.Writer) *cobra.Command {
func requestApprovalDesc() string {
return `
Request an approval of a deployment of an artifact in Merkely. The request should be reviewed in Merkely UI.
The artifact SHA256 fingerprint is calculated or alternatively it can be provided directly.
The artifact SHA256 fingerprint is calculated or alternatively it can be provided directly.
`
}
13 changes: 7 additions & 6 deletions cmd/reporter/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Environment variables:
| $MERKELY_HOST | set the Merkely host. |
| $MERKELY_DRY_RUN | indicate whether or not Merkely CLI is running in Dry Run mode. |
| $MERKELY_MAX_API_RETRIES | set the maximum number of API calling retries when the API host is not reachable. |
| $MERKELY_CONFIG_FILE | set the path to Merkely config file where you can set your options. |
| $MERKELY_CONFIG_FILE | set the path to Merkely config file where you can set your options. |
`

const (
Expand Down Expand Up @@ -50,11 +50,12 @@ type GlobalOpts struct {
func newRootCmd(out io.Writer, args []string) (*cobra.Command, error) {
global = new(GlobalOpts)
cmd := &cobra.Command{
Use: "merkely",
Short: "The Merkely evidence reporting CLI.",
Long: globalUsage,
SilenceUsage: true,
TraverseChildren: true,
Use: "merkely",
Short: "The Merkely evidence reporting CLI.",
Long: globalUsage,
SilenceUsage: true,
TraverseChildren: true,
DisableAutoGenTag: true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only line you need to disable the autogen tag. Since this is the root command, all others will respect this without explicitly setting it on each of them.

PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
// You can bind cobra and viper in a few locations, but PersistencePreRunE on the root command works well
return initializeConfig(cmd)
Expand Down
15 changes: 8 additions & 7 deletions cmd/reporter/serverEnv.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
)

const serverEnvDesc = `
List the artifacts deployed in a server environment and their digests
and report them to Merkely.
List the artifacts deployed in a server environment and their digests
and report them to Merkely.
`

const serverEnvExample = `
Expand All @@ -28,11 +28,12 @@ type serverEnvOptions struct {
func newServerEnvCmd(out io.Writer) *cobra.Command {
o := new(serverEnvOptions)
cmd := &cobra.Command{
Use: "server [-p /path/of/artifacts/directory] [-i infrastructure-identifier] env-name",
Short: "Report directory artifacts data in the given list of paths to Merkely.",
Long: serverEnvDesc,
Aliases: []string{"directories"},
Example: serverEnvExample,
Use: "server [-p /path/of/artifacts/directory] [-i infrastructure-identifier] env-name",
Short: "Report directory artifacts data in the given list of paths to Merkely.",
Long: serverEnvDesc,
Aliases: []string{"directories"},
Example: serverEnvExample,
DisableAutoGenTag: true,
PreRunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 1 {
return fmt.Errorf("only environment name argument is allowed")
Expand Down
Loading