Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teleport logout #50

Merged
merged 2 commits into from
Dec 1, 2023
Merged
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
2 changes: 1 addition & 1 deletion digitalocean/doctl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func New(l log.Logger) (plugin.Plugin, error) {

// ...

inst.kubectl, err = kubectl.New(l, inst.c)
inst.kubectl, err = kubectl.New(l, inst.cache)
if err != nil {
return nil, errors.Wrap(err, "failed to create kubectl")
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/c-bata/go-prompt v0.2.6
github.com/cloudrecipes/packagejson v1.0.0
github.com/digitalocean/godo v1.106.0
github.com/foomo/posh v0.5.1
github.com/foomo/posh v0.5.2
github.com/google/go-github/v47 v47.1.0
github.com/joho/godotenv v1.5.1
github.com/pkg/errors v0.9.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w=
github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg=
github.com/foomo/posh v0.5.1 h1:KH40t4XmykL6r4xHbooBF6jYqQbrusA1Ut4Z9N9aegs=
github.com/foomo/posh v0.5.1/go.mod h1:r+8JfqSxwZhROoL4teWvjoA47bDjATPtTxq1MEkyAhM=
github.com/foomo/posh v0.5.2 h1:EyKd/JZdz/KEA1RXP97FU35lPNd2mJh8B/4GdHlkyGQ=
github.com/foomo/posh v0.5.2/go.mod h1:ZAPH4wZaRPrDL/RZYH31C6O7L4+N0Al6Sse5jks1skc=
github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/franklinkim/go-prompt v0.2.7-0.20210427061716-a8f4995d7aa5 h1:kXNtle4AoQnngdm+gwt4ku6Llbzw3EFHgZYpL618JaI=
Expand Down
21 changes: 19 additions & 2 deletions gravitational/teleport/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ func NewCommand(l log.Logger, cache cache.Cache, teleport *Teleport, kubectl *ku
Execute: inst.auth,
Nodes: tree.Nodes{
{
Name: "auth",
Execute: inst.auth,
Name: "auth",
Description: "Log in to a cluster and retrieve the session certificate",
Execute: inst.auth,
},
{
Name: "kubeconfig",
Expand Down Expand Up @@ -95,6 +96,11 @@ func NewCommand(l log.Logger, cache cache.Cache, teleport *Teleport, kubectl *ku
},
Execute: inst.database,
},
{
Name: "logout",
Description: "Log out",
Execute: inst.logout,
},
},
})

Expand Down Expand Up @@ -180,3 +186,14 @@ func (c *Command) auth(ctx context.Context, r *readline.Readline) error {
}
return nil
}

func (c *Command) logout(ctx context.Context, r *readline.Readline) error {
if err := shell.New(ctx, c.l, "tsh", "logout").
Args(r.Flags()...).
Args(r.AdditionalArgs()...).
Args(r.AdditionalFlags()...).
Run(); err != nil {
return err
}
return nil
}
62 changes: 62 additions & 0 deletions stern/stern/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,65 @@

## Usage

### Plugin

```go
package main

import (
"github.com/foomo/posh/provider/foomo/gotsrpc"
"github.com/foomo/posh/pkg/command"
"github.com/foomo/posh/pkg/log"
"github.com/foomo/posh/pkg/plugin"
"github.com/spf13/viper"
)

type Plugin struct {
l log.Logger
cache cache.Cache
kubectl *kubectl.Kubectl
commands command.Commands
}

func New(l log.Logger) (plugin.Plugin, error) {
var err error
inst := &Plugin{
l: l,
cache: &cache.MemoryCache{},
commands: command.Commands{},
}

// ...

inst.kubectl, err = kubectl.New(l, inst.cache)
if err != nil {
return nil, errors.Wrap(err, "failed to create kubectl")
}

inst.squadron, err = squadron.New(l, inst.kubectl)
if err != nil {
return nil, errors.Wrap(err, "failed to create squadron")
}

// ...

inst.commands.Add(stern.NewCommand(l, inst.kubectl, inst.squadron))

// ...

return inst, nil
}
```

### Ownbrew

To install binary locally, add:

```yaml
ownbrew:
packages:
## https://github.com/stern/stern/releases
- name: stern
tap: foomo/tap/stern/stern
version: 1.27.0
```