-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description Add command to easily get credentials printed during zarf init (i.e. git, logging, registry) ## Related Issue Fixes #1098 ## Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Other (security config, docs update, etc) ## Checklist before merging - [ ] Test, docs, adr added or updated as needed - [ ] [Contributor Guide Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow) followed
- Loading branch information
1 parent
3a193fe
commit b0474b8
Showing
7 changed files
with
108 additions
and
38 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
10 changes: 5 additions & 5 deletions
10
...i-commands/zarf_tools_get-git-password.md → .../100-cli-commands/zarf_tools_get-creds.md
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
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,66 @@ | ||
package utils | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/defenseunicorns/zarf/src/pkg/message" | ||
"github.com/defenseunicorns/zarf/src/types" | ||
"github.com/pterm/pterm" | ||
) | ||
|
||
// Display credentials in a table | ||
func PrintCredentialTable(state types.ZarfState, componentsToDeploy []types.DeployedComponent) { | ||
if len(componentsToDeploy) == 0 { | ||
componentsToDeploy = []types.DeployedComponent{{Name: "logging"}, {Name: "git-server"}} | ||
} | ||
|
||
pterm.Println() | ||
loginTableHeader := pterm.TableData{ | ||
{" Application", "Username", "Password", "Connect"}, | ||
} | ||
|
||
loginTable := pterm.TableData{} | ||
if state.RegistryInfo.InternalRegistry { | ||
loginTable = append(loginTable, pterm.TableData{{" Registry", state.RegistryInfo.PushUsername, state.RegistryInfo.PushPassword, "zarf connect registry"}}...) | ||
} | ||
|
||
for _, component := range componentsToDeploy { | ||
// Show message if including logging stack | ||
if component.Name == "logging" { | ||
loginTable = append(loginTable, pterm.TableData{{" Logging", "zarf-admin", state.LoggingSecret, "zarf connect logging"}}...) | ||
} | ||
// Show message if including git-server | ||
if component.Name == "git-server" { | ||
loginTable = append(loginTable, pterm.TableData{ | ||
{" Git", state.GitServer.PushUsername, state.GitServer.PushPassword, "zarf connect git"}, | ||
{" Git (read-only)", state.GitServer.PullUsername, state.GitServer.PullPassword, "zarf connect git"}, | ||
}...) | ||
} | ||
} | ||
|
||
if len(loginTable) > 0 { | ||
loginTable = append(loginTableHeader, loginTable...) | ||
_ = pterm.DefaultTable.WithHasHeader().WithData(loginTable).Render() | ||
} | ||
} | ||
|
||
// Display credentials for a single component | ||
func PrintComponentCredential(state types.ZarfState, componentName string) { | ||
switch strings.ToLower(componentName) { | ||
case "logging": | ||
message.Note("Logging credentials (username: zarf-admin):") | ||
fmt.Println(state.LoggingSecret) | ||
case "git": | ||
message.Note("Git Server push password (username: " + state.GitServer.PushUsername + "):") | ||
fmt.Println(state.GitServer.PushPassword) | ||
case "git-readonly": | ||
message.Note("Git Server (read-only) password (username: " + state.GitServer.PullUsername + "):") | ||
fmt.Println(state.GitServer.PullPassword) | ||
case "registry": | ||
message.Note("Image Registry password (username: " + state.RegistryInfo.PushUsername + "):") | ||
fmt.Println(state.RegistryInfo.PushPassword) | ||
default: | ||
message.Warn("Unknown component: " + componentName) | ||
} | ||
} |