Skip to content

Commit 1c6243a

Browse files
author
Tobias Fuhrimann
committed
Fix linting issues
1 parent 34dfb71 commit 1c6243a

20 files changed

Lines changed: 81 additions & 72 deletions

backup.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ package main
44
type Backup struct {
55
Metadata CFMetadata `json:"metadata"`
66
Entity struct {
7-
ServiceInstanceID string `json:"service_instance_id"`
8-
Status string `json:"status"`
9-
Restores []Restore `json:"restores"`
7+
Status string `json:"status"`
8+
Restores []Restore `json:"restores"`
109
} `json:"entity"`
1110
}
1211

backups.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ func (p *AppCloudPlugin) Backups(c plugin.CliConnection, serviceInstanceName str
6262

6363
table.Add(b.Metadata.CreatedAt.Format(time.RFC3339), b.Metadata.GUID, formatStatus(overallStatus))
6464
}
65-
table.Print()
65+
err := table.Print()
66+
if err != nil {
67+
return errors.Wrap(err, "Couldn't print table")
68+
}
6669
} else {
6770
p.ui.Say("No backups found")
6871
}

billing_account.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"encoding/json"
5+
"fmt"
56

67
"net/url"
78
"strings"
@@ -14,24 +15,8 @@ import (
1415
// BillingAccount is an entity of the Swisscom Application Cloud which handles billing.
1516
type BillingAccount struct {
1617
Metadata struct {
17-
GUID string `json:"guid"`
18-
URL string `json:"url"`
19-
CreatedAt string `json:"created_at"`
20-
UpdatedAt string `json:"updated_at"`
18+
GUID string `json:"guid"`
2119
} `json:"metadata"`
22-
Entity struct {
23-
Status string `json:"status"`
24-
StatusReasonData struct {
25-
Code string `json:"code"`
26-
Description string `json:"description"`
27-
} `json:"status_reason_data"`
28-
Prohibited bool `json:"prohibited"`
29-
Name string `json:"name"`
30-
CustomerNumber string `json:"customer_number"`
31-
CustomerType string `json:"customer_type"`
32-
OrganizationCount int `json:"organization_count"`
33-
MaxOrganizations int `json:"max_organizations"`
34-
} `json:"entity"`
3520
}
3621

3722
// BillingAccountResponse is a response from the server to a billing account request.
@@ -42,7 +27,7 @@ type BillingAccountResponse struct {
4227

4328
// getBillingAccount retrieves a billing account by name.
4429
func getBillingAccount(c plugin.CliConnection, name string) (BillingAccount, error) {
45-
accURL := url.QueryEscape("/custom/accounts?q=name:%s")
30+
accURL := url.QueryEscape(fmt.Sprintf("/custom/accounts?q=name:%s", name))
4631
resLines, err := c.CliCommandWithoutTerminalOutput("curl", accURL)
4732

4833
if err != nil {

billing_account_invitations.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ func (p *AppCloudPlugin) BillingAccountInvitations(c plugin.CliConnection, billi
5151
for _, inv := range res.Resources {
5252
table.Add(inv.Entity.Invitee, strings.Join(inv.Entity.Roles, ","), inv.Entity.Status)
5353
}
54-
table.Print()
54+
err := table.Print()
55+
if err != nil {
56+
return errors.Wrap(err, "Couldn't print table")
57+
}
5558
} else {
5659
p.ui.Say("No invitations found")
5760
}

event.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ type Event struct {
1212
Metadata CFMetadata `json:"metadata"`
1313
Entity struct {
1414
Type string `json:"type"`
15-
Actor string `json:"actor"`
16-
ActorType string `json:"actor_type"`
1715
ActorName string `json:"actor_name"`
18-
Actee string `json:"actee"`
19-
ActeeType string `json:"actee_type"`
20-
ActeeName string `json:"actee_name"`
21-
TimeStamp string `json:"timestamp"`
22-
SpaceGUID string `json:"space_guid"`
23-
OrgGUID string `json:"organization_guid"`
2416
} `json:"entity"`
2517
}

invitation.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ import (
99
"github.com/pkg/errors"
1010
)
1111

12+
// These are the different statuses an invitation can have.
13+
const (
14+
StatusSent = "SENT"
15+
StatusConfirmed = "CONFIRMED"
16+
)
17+
1218
// Invitation is an invitation a user received to join a specific entity.
1319
type Invitation struct {
1420
Metadata CFMetadata `json:"metadata"`
1521
Entity struct {
1622
Invitee string `json:"invitee"`
1723
Roles []string `json:"roles"`
18-
ActorUsername string `json:"actor_username"`
19-
ActorUserID string `json:"actor_user_id"`
2024
AccountID string `json:"account_id"`
2125
AccountName string `json:"account_name"`
2226
OrganizationID string `json:"organization_id"`
@@ -87,9 +91,7 @@ func getAllInvitations(c plugin.CliConnection) ([]Invitation, error) {
8791
return []Invitation{}, fmt.Errorf("Error response from server: %s", res.Description)
8892
}
8993

90-
for _, i := range res.Resources {
91-
invitations = append(invitations, i)
92-
}
94+
invitations = append(invitations, res.Resources...)
9395
}
9496

9597
return invitations, nil

invitations.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ func (p *AppCloudPlugin) Invitations(c plugin.CliConnection) error {
2828
entityType, entityName := invitationEntityTypeAndName(inv)
2929
table.Add(inv.Metadata.GUID, formatEntityType(entityType), entityName)
3030
}
31-
table.Print()
31+
err := table.Print()
32+
if err != nil {
33+
return errors.Wrap(err, "Couldn't print table")
34+
}
3235
} else {
3336
p.ui.Say("No invitations found")
3437
}

invite_billing_account_user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (p *AppCloudPlugin) InviteBillingAccountUser(c plugin.CliConnection, invite
5555
return errors.Wrap(err, "Couldn't read JSON response from server")
5656
}
5757

58-
if res.Entity.Status != "SENT" && res.Entity.Status != "CONFIRMED" {
58+
if res.Entity.Status != StatusSent && res.Entity.Status != StatusConfirmed {
5959
return errors.Wrap(err, "Couldn't send invitation")
6060
}
6161

invite_org_user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (p *AppCloudPlugin) InviteOrgUser(c plugin.CliConnection, invitee string, o
5959
return errors.Wrap(err, "Couldn't read JSON response from server")
6060
}
6161

62-
if res.Entity.Status != "SENT" && res.Entity.Status != "CONFIRMED" {
62+
if res.Entity.Status != StatusSent && res.Entity.Status != StatusConfirmed {
6363
return errors.Wrap(err, "Couldn't send invitation")
6464
}
6565

invite_space_user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (p *AppCloudPlugin) InviteSpaceUser(c plugin.CliConnection, invitee string,
5959
return errors.Wrap(err, "Couldn't read JSON response from server")
6060
}
6161

62-
if res.Entity.Status != "SENT" && res.Entity.Status != "CONFIRMED" {
62+
if res.Entity.Status != StatusSent && res.Entity.Status != StatusConfirmed {
6363
return errors.Wrap(err, "Couldn't send invitation")
6464
}
6565

0 commit comments

Comments
 (0)