Skip to content

Commit

Permalink
Add cli skeleton for kando chronicle push (#6178)
Browse files Browse the repository at this point in the history
* Add cli skeleton for kando chronicle push

* Update go/src/github.com/kanisterio/kanister/pkg/kando/chronicle_push.go
  • Loading branch information
tdmanv authored and Ilya Kislenko committed Jul 31, 2019
1 parent 6888049 commit 687ab93
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 0 deletions.
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
github.com/aws/aws-sdk-go v1.14.31 h1:amhorvKh1zNxo9YCntvA5uDmgw+pCYXOp4xO8WS1oDg=
github.com/aws/aws-sdk-go v1.14.31/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0=
github.com/aws/aws-sdk-go v1.20.12 h1:xV7xfLSkiqd7JOnLlfER+Jz8kI98rAGJvtXssYkCRs4=
github.com/aws/aws-sdk-go v1.20.12/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.20.20 h1:OAR/GtjMOhenkp1NNKr1N1FgIP3mQXHeGbRhvVIAQp0=
github.com/aws/aws-sdk-go v1.20.20/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
Expand Down
21 changes: 21 additions & 0 deletions pkg/chronicle/chronicle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package chronicle

import (
"time"
)

type PushParams struct {
ProfilePath string
ArtifactPath string
Frequency time.Duration
EnvDir string
Command []string
}

func (p PushParams) Validate() error {
return nil
}

func Push(p PushParams) error {
return nil
}
14 changes: 14 additions & 0 deletions pkg/kando/chronicle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package kando

import (
"github.com/spf13/cobra"
)

func newChronicleCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "chronicle <command>",
Short: "Manage periodic output streams in object storage",
}
cmd.AddCommand(newChroniclePushCommand())
return cmd
}
37 changes: 37 additions & 0 deletions pkg/kando/chronicle_push.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package kando

import (
"time"

"github.com/kanisterio/kanister/pkg/chronicle"
"github.com/spf13/cobra"
)

const (
profilePathFlagName = "profile-path"
artifactPathFlagName = "artifact-path"
frequencyFlagName = "frequency"
envDirFlagName = "env-dir"
)

func newChroniclePushCommand() *cobra.Command {
params := chronicle.PushParams{}
cmd := &cobra.Command{
Use: "push <command>",
Short: "Periodically push the output of a command to object storage",
Args: cobra.MinimumNArgs(1),
RunE: func(c *cobra.Command, args []string) error {
if err := params.Validate(); err != nil {
return err
}
params.Command = args
return chronicle.Push(params)
},
}
cmd.PersistentFlags().StringVarP(&params.ProfilePath, profilePathFlagName, "s", "", "Specify a path suffix (optional)")
cmd.MarkPersistentFlagRequired(profilePathFlagName)
cmd.PersistentFlags().StringVarP(&params.ArtifactPath, artifactPathFlagName, "p", "", "Path to a Profile as a JSON string (required)")
cmd.PersistentFlags().StringVarP(&params.EnvDir, envDirFlagName, "e", "", "Get environment variables from a (optional)")
cmd.PersistentFlags().DurationVarP(&params.Frequency, frequencyFlagName, "f", time.Minute, "The Frequency to push to object storage ")
return cmd
}
1 change: 1 addition & 0 deletions pkg/kando/kando.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ func newRootCommand() *cobra.Command {
}
rootCmd.AddCommand(newLocationCommand())
rootCmd.AddCommand(newOutputCommand())
rootCmd.AddCommand(newChronicleCommand())
return rootCmd
}

0 comments on commit 687ab93

Please sign in to comment.