diff --git a/pkg/cmd/active.go b/pkg/cmd/active.go index 1863d5d..8255d5b 100644 --- a/pkg/cmd/active.go +++ b/pkg/cmd/active.go @@ -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 diff --git a/pkg/print/connections.go b/pkg/print/connections.go index e5067f9..bc19fd0 100644 --- a/pkg/print/connections.go +++ b/pkg/print/connections.go @@ -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 @@ -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() diff --git a/pkg/print/snaps.go b/pkg/print/snaps.go index 02eaa4a..465d99f 100644 --- a/pkg/print/snaps.go +++ b/pkg/print/snaps.go @@ -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)