-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Andy Doan <[email protected]>
- Loading branch information
Showing
3 changed files
with
116 additions
and
0 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
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,64 @@ | ||
package el2g | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
|
||
"github.com/foundriesio/fioctl/subcommands" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func init() { | ||
cmd.AddCommand(&cobra.Command{ | ||
Use: "status", | ||
Short: "Show the overall status of the Edgelock 2Go integration", | ||
Run: doStatus, | ||
}) | ||
} | ||
|
||
func doStatus(cmd *cobra.Command, args []string) { | ||
factory := viper.GetString("factory") | ||
|
||
products, err := api.El2gProducts(factory) | ||
subcommands.DieNotNil(err) | ||
|
||
overview, err := api.El2gOverview(factory) | ||
subcommands.DieNotNil(err) | ||
fmt.Println("# Subdomain:", overview.Subdomain) | ||
fmt.Println("\n# Product IDs") | ||
t := subcommands.Tabby(1, "ID", "NAME") | ||
for _, id := range overview.ProductIds { | ||
name := "" | ||
for _, prod := range products { | ||
if prod.Nc12 == strconv.Itoa(id) { | ||
name = prod.Type | ||
break | ||
} | ||
} | ||
t.AddLine(id, name) | ||
} | ||
t.Print() | ||
|
||
secureObjects, err := api.El2gSecureObjects(factory) | ||
subcommands.DieNotNil(err) | ||
fmt.Println("\n# Secure Objects") | ||
t = subcommands.Tabby(1, "TYPE", "NAME", "OBJECT ID") | ||
for _, so := range secureObjects { | ||
t.AddLine(so.Type, so.Name, so.ObjectId) | ||
} | ||
t.Print() | ||
|
||
fmt.Println("\n# Intermediate CAs") | ||
cas, err := api.El2gIntermediateCas(factory) | ||
subcommands.DieNotNil(err) | ||
for i, ca := range cas { | ||
if i > 0 { | ||
fmt.Println() | ||
} | ||
fmt.Println("Name:", ca.Name) | ||
fmt.Println("Algorithm:", ca.Algorithm) | ||
fmt.Println("ID:", ca.Id) | ||
fmt.Println(ca.Value) | ||
} | ||
} |