Skip to content

Commit

Permalink
updated connection and credential handling to take protocol changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ogazitt committed Jul 12, 2020
1 parent af7e570 commit 08943a0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
1 change: 0 additions & 1 deletion pkg/cmd/active.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ snap active logs [active snap ID] details [log ID] will return the output for ea
if len(args) > 2 && logID != "" {
// select the entry that matches the log ID
logEntry := gjson.GetBytes(response, fmt.Sprintf("data.#(timestamp==%s)|@pretty", logID)).Raw

if logEntry == "" {
utils.PrintError(fmt.Sprintf("log ID %s not found for active snap ID %s", logID, activeSnapID))
return
Expand Down
20 changes: 18 additions & 2 deletions pkg/print/connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import (
"github.com/snapmaster-io/snap/pkg/utils"
)

// CredentialsResponse defines the fields to unmarshal from a get credential-sets operation
type CredentialsResponse struct {
Status string `json:"status"`
Message string `json:"message"`
Data []map[string]string `json:"data"`
}

// ConnectionsTable prints out the connected providers as a table
func ConnectionsTable(response []byte) {
var toolsResponse ToolsResponse
Expand Down Expand Up @@ -39,8 +46,17 @@ func ConnectionsTable(response []byte) {

// CredentialsTable prints out the credentials of a connection as a table
func CredentialsTable(response []byte, connection string) {
var credentials []map[string]string
json.Unmarshal(response, &credentials)
var credentialsResponse CredentialsResponse
json.Unmarshal(response, &credentialsResponse)

if credentialsResponse.Status == "error" {
utils.PrintStatus(credentialsResponse.Status, credentialsResponse.Message)
return
}

credentials := credentialsResponse.Data
//var credentials []map[string]string
//json.Unmarshal(response, &credentials)

// write out the table
t := table.NewWriter()
Expand Down
1 change: 0 additions & 1 deletion pkg/print/snaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ func SnapsTable(response []byte) {
t.SetTitle("Snaps")
t.AppendHeader(table.Row{"Snap ID", "Description", "Trigger"})
for _, snap := range snaps {
//t.AppendRow(table.Row{snap["snapId"], snap["description"], snap["provider"]})
t.AppendRow(table.Row{snap.SnapID, snap.Description, snap.Provider})
}
t.SetStyle(tableStyle)
Expand Down

0 comments on commit 08943a0

Please sign in to comment.