Skip to content

Commit

Permalink
Scaffold the login command (kolide#1748)
Browse files Browse the repository at this point in the history
  • Loading branch information
marpaia authored May 1, 2018
1 parent ee0a400 commit 920f4af
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 14 deletions.
57 changes: 57 additions & 0 deletions cmd/fleetctl/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package main

import (
"os"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/urfave/cli"
)

func setupCommand() cli.Command {
var (
flAddress string
)
return cli.Command{
Name: "setup",
Usage: "Setup a Kolide Fleet instance",
UsageText: `fleetctl config login [options]`,
Flags: []cli.Flag{
cli.StringFlag{
Name: "address",
Value: "",
Destination: &flAddress,
Usage: "The address of the Kolide Fleet instance",
},
},
Action: func(cliCtx *cli.Context) error {
logger := log.NewLogfmtLogger(os.Stdout)
level.Info(logger).Log("msg", "setting up fleet")
return nil
},
}
}

func loginCommand() cli.Command {
var (
flAddress string
)
return cli.Command{
Name: "login",
Usage: "Login to Kolide Fleet",
UsageText: `fleetctl config login [options]`,
Flags: []cli.Flag{
cli.StringFlag{
Name: "address",
Value: "",
Destination: &flAddress,
Usage: "The address of the Kolide Fleet instance",
},
},
Action: func(cliCtx *cli.Context) error {
logger := log.NewLogfmtLogger(os.Stdout)
level.Info(logger).Log("msg", "logging in to fleet")
return nil
},
}
}
26 changes: 12 additions & 14 deletions cmd/fleetctl/fleetctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,27 @@ func main() {

app.Commands = []cli.Command{
cli.Command{
Name: "create",
Usage: "Create resources",
Name: "query",
Usage: "run a query across your fleet",
Subcommands: []cli.Command{},
},
cli.Command{
Name: "get",
Usage: "Get and list resources",
Name: "apply",
Usage: "apply a set of osquery configurations",
Subcommands: []cli.Command{},
},
cli.Command{
Name: "put",
Usage: "Create or update resources",
Name: "edit",
Usage: "edit your complete configuration in an ephemeral editor",
Subcommands: []cli.Command{},
},
cli.Command{
Name: "delete",
Usage: "Delete resources",
Subcommands: []cli.Command{},
},
cli.Command{
Name: "ensure",
Usage: "Ensures the state of resources",
Subcommands: []cli.Command{},
Name: "config",
Usage: "modify how and which Fleet server to connect to",
Subcommands: []cli.Command{
loginCommand(),
setupCommand(),
},
},
}

Expand Down
3 changes: 3 additions & 0 deletions server/kolide/packs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type PackStore interface {
// ApplyPackSpecs applies a list of PackSpecs to the datastore,
// creating and updating packs as necessary.
ApplyPackSpecs(specs []*PackSpec) error

// GetPackSpecs returns all of the stored PackSpecs.
GetPackSpecs() ([]*PackSpec, error)

Expand All @@ -20,6 +21,7 @@ type PackStore interface {

// ListPacks lists all packs in the datastore.
ListPacks(opt ListOptions) ([]*Pack, error)

// PackByName fetches pack if it exists, if the pack
// exists the bool return value is true
PackByName(name string, opts ...OptionalArg) (*Pack, bool, error)
Expand All @@ -44,6 +46,7 @@ type PackService interface {
// ApplyPackSpecs applies a list of PackSpecs to the datastore,
// creating and updating packs as necessary.
ApplyPackSpecs(ctx context.Context, specs []*PackSpec) error

// GetPackSpecs returns all of the stored PackSpecs.
GetPackSpecs(ctx context.Context) ([]*PackSpec, error)

Expand Down

0 comments on commit 920f4af

Please sign in to comment.