mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-07-26 00:35:19 -04:00
cli: format output in writeOutput
This commit is contained in:
parent
ea4b9d2d85
commit
dbfbdfe3cd
1 changed files with 24 additions and 13 deletions
|
@ -8,6 +8,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"net"
|
"net"
|
||||||
|
"text/tabwriter"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/cli/azure"
|
"github.com/edgelesssys/constellation/cli/azure"
|
||||||
"github.com/edgelesssys/constellation/cli/file"
|
"github.com/edgelesssys/constellation/cli/file"
|
||||||
|
@ -228,24 +229,34 @@ func (r activationResult) writeWGQuickFile(fileHandler file.Handler, config *con
|
||||||
return fileHandler.Write(*config.WGQuickConfigPath, data, false)
|
return fileHandler.Write(*config.WGQuickConfigPath, data, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r activationResult) writeOutput(w io.Writer, fileHandler file.Handler, config *config.Config) error {
|
func (r activationResult) writeOutput(wr io.Writer, fileHandler file.Handler, config *config.Config) error {
|
||||||
fmt.Fprintln(w, "Your Constellation was successfully initialized.")
|
fmt.Fprint(wr, "Your Constellation was successfully initialized.\n\n")
|
||||||
fmt.Fprintf(w, "Your WireGuard IP is %s\n", r.clientVpnIP)
|
|
||||||
fmt.Fprintf(w, "The Coordinator's public IP is %s\n", r.coordinatorPubIP)
|
tw := tabwriter.NewWriter(wr, 0, 0, 2, ' ', 0)
|
||||||
fmt.Fprintf(w, "The Coordinator's public key is %s\n", r.coordinatorPubKey)
|
writeRow(tw, "Your WireGuard IP", r.clientVpnIP)
|
||||||
fmt.Fprintf(w, "The Constellation's owner identifier is %s\n", r.ownerID)
|
writeRow(tw, "Coordinator's public IP", r.coordinatorPubIP)
|
||||||
fmt.Fprintf(w, "The Constellation's unique identifier is %s\n", r.clusterID)
|
writeRow(tw, "Coordinator's public key", r.coordinatorPubKey)
|
||||||
fmt.Fprintf(w, "Your WireGuard configuration file was written to %s\n", *config.WGQuickConfigPath)
|
writeRow(tw, "Constellation's owner identifier", r.ownerID)
|
||||||
|
writeRow(tw, "Constellation's unique identifier", r.clusterID)
|
||||||
|
writeRow(tw, "WireGuard configuration file", *config.WGQuickConfigPath)
|
||||||
|
writeRow(tw, "Kubernetes configuration", *config.AdminConfPath)
|
||||||
|
tw.Flush()
|
||||||
|
fmt.Fprintln(wr)
|
||||||
|
|
||||||
if err := fileHandler.Write(*config.AdminConfPath, []byte(r.kubeconfig), false); err != nil {
|
if err := fileHandler.Write(*config.AdminConfPath, []byte(r.kubeconfig), false); err != nil {
|
||||||
return err
|
return fmt.Errorf("write kubeconfig: %w", err)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(w, "Your Constellation Kubernetes configuration was successfully written to %s\n", *config.AdminConfPath)
|
|
||||||
fmt.Fprintln(w, "\nYou can now connect to your Constellation by executing:")
|
fmt.Fprintln(wr, "You can now connect to your Constellation by executing:")
|
||||||
fmt.Fprintf(w, "wg-quick up ./%s\n", *config.WGQuickConfigPath)
|
fmt.Fprintf(wr, "\twg-quick up ./%s\n", *config.WGQuickConfigPath)
|
||||||
fmt.Fprintf(w, "export KUBECONFIG=\"$PWD/%s\"\n", *config.AdminConfPath)
|
fmt.Fprintf(wr, "\texport KUBECONFIG=\"$PWD/%s\"\n", *config.AdminConfPath)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func writeRow(wr io.Writer, col1 string, col2 string) {
|
||||||
|
fmt.Fprint(wr, col1, "\t", col2, "\n")
|
||||||
|
}
|
||||||
|
|
||||||
// evalFlagArgs gets the flag values and does preprocessing of these values like
|
// evalFlagArgs gets the flag values and does preprocessing of these values like
|
||||||
// reading the content from file path flags and deriving other values from flag combinations.
|
// reading the content from file path flags and deriving other values from flag combinations.
|
||||||
func evalFlagArgs(cmd *cobra.Command, fileHandler file.Handler, config *config.Config) (flagArgs, error) {
|
func evalFlagArgs(cmd *cobra.Command, fileHandler file.Handler, config *config.Config) (flagArgs, error) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue