-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.0.13: lcl clean and misc refinements
- Loading branch information
Showing
22 changed files
with
655 additions
and
330 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Anchor CLI | ||
|
||
`anchor` is a command line interface for the [Anchor.dev](https://anchor.dev) certificate management platform. | ||
|
||
## Installation | ||
|
||
### macOS | ||
|
||
`anchor` is available via [Homebrew][] or as a downloadable binary from the [releases page][]. | ||
|
||
#### Homebrew | ||
|
||
| Install: | Upgrade: | | ||
| -------------------------------------- | -------------------------------------- | | ||
| `brew install anchordotdev/tap/anchor` | `brew upgrade anchordotdev/tap/anchor` | | ||
|
||
### Linux & BSD | ||
|
||
`anchor` is available via [Homebrew][] or as a downloadable binary from the [releases page][]. | ||
|
||
#### Homebrew | ||
|
||
| Install: | Upgrade: | | ||
| -------------------------------------- | -------------------------------------- | | ||
| `brew install anchordotdev/tap/anchor` | `brew upgrade anchordotdev/tap/anchor` | | ||
|
||
### Windows | ||
|
||
`anchor` is not yet supported. | ||
|
||
### Install from source | ||
|
||
To install `anchor` from source run `go install github.com/anchordotdev/cli/cmd/anchor@latest`. | ||
|
||
[Homebrew]: https://brew.sh | ||
[releases page]: https://github.com/anchordotdev/cli/releases/latest |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,70 @@ | ||
package lcl | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/anchordotdev/cli" | ||
"github.com/anchordotdev/cli/api" | ||
"github.com/anchordotdev/cli/auth" | ||
"github.com/anchordotdev/cli/lcl/models" | ||
"github.com/anchordotdev/cli/trust" | ||
"github.com/anchordotdev/cli/ui" | ||
) | ||
|
||
type LclClean struct { | ||
Config *cli.Config | ||
|
||
anc *api.Session | ||
orgSlug, realmSlug string | ||
} | ||
|
||
func (c LclClean) UI() cli.UI { | ||
return cli.UI{ | ||
RunTUI: c.run, | ||
} | ||
} | ||
|
||
func (c LclClean) run(ctx context.Context, drv *ui.Driver) error { | ||
var err error | ||
clientCmd := &auth.Client{ | ||
Config: c.Config, | ||
Anc: c.anc, | ||
} | ||
c.anc, err = clientCmd.Perform(ctx, drv) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
c.Config.Trust.Clean.States = []string{"all"} | ||
|
||
if c.orgSlug == "" { | ||
userInfo, err := c.anc.UserInfo(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
c.orgSlug = userInfo.PersonalOrg.Slug | ||
} | ||
|
||
if c.realmSlug == "" { | ||
c.realmSlug = "localhost" | ||
} | ||
|
||
drv.Activate(ctx, &models.LclCleanHeader{}) | ||
drv.Activate(ctx, &models.LclCleanHint{ | ||
TrustStores: c.Config.Trust.Stores, | ||
}) | ||
|
||
cmd := &trust.Clean{ | ||
Config: c.Config, | ||
Anc: c.anc, | ||
OrgSlug: c.orgSlug, | ||
RealmSlug: c.realmSlug, | ||
} | ||
|
||
err = cmd.Perform(ctx, drv) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
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,49 @@ | ||
package models | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/anchordotdev/cli/ui" | ||
"github.com/charmbracelet/bubbles/spinner" | ||
tea "github.com/charmbracelet/bubbletea" | ||
) | ||
|
||
type LclCleanHeader struct{} | ||
|
||
func (LclCleanHeader) Init() tea.Cmd { return nil } | ||
|
||
func (m *LclCleanHeader) Update(tea.Msg) (tea.Model, tea.Cmd) { return m, nil } | ||
|
||
func (m *LclCleanHeader) View() string { | ||
var b strings.Builder | ||
fmt.Fprintln(&b, ui.Header(fmt.Sprintf("Clean lcl.host CA Certificates from Local Trust Store(s) %s", ui.Whisper("`anchor trust clean`")))) | ||
return b.String() | ||
} | ||
|
||
type LclCleanHint struct { | ||
TrustStores []string | ||
|
||
spinner spinner.Model | ||
} | ||
|
||
func (c *LclCleanHint) Init() tea.Cmd { | ||
c.spinner = ui.WaitingSpinner() | ||
|
||
return c.spinner.Tick | ||
} | ||
|
||
func (c *LclCleanHint) Update(msg tea.Msg) (tea.Model, tea.Cmd) { | ||
var cmd tea.Cmd | ||
c.spinner, cmd = c.spinner.Update(msg) | ||
return c, cmd | ||
} | ||
|
||
func (c *LclCleanHint) View() string { | ||
stores := strings.Join(c.TrustStores, ", ") | ||
|
||
var b strings.Builder | ||
fmt.Fprintln(&b, ui.Hint(fmt.Sprintf("Removing lcl.host CA certificates from the %s store(s).", stores))) | ||
|
||
return b.String() | ||
} |
Oops, something went wrong.