Skip to content

Commit

Permalink
chore: remove redundant jsonapiclient interface
Browse files Browse the repository at this point in the history
  • Loading branch information
leg100 committed Oct 29, 2023
1 parent eceab7e commit 5aa153a
Show file tree
Hide file tree
Showing 18 changed files with 33 additions and 48 deletions.
14 changes: 7 additions & 7 deletions internal/agent/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ func newClient(config ExternalConfig) (*remoteClient, error) {

return &remoteClient{
Client: api,
stateClient: &stateClient{JSONAPIClient: api},
configClient: &configClient{JSONAPIClient: api},
variableClient: &variableClient{JSONAPIClient: api},
tokensClient: &tokensClient{JSONAPIClient: api},
workspaceClient: &workspaceClient{JSONAPIClient: api},
runClient: &runClient{JSONAPIClient: api, Config: config.APIConfig},
logsClient: &logsClient{JSONAPIClient: api},
stateClient: &stateClient{Client: api},
configClient: &configClient{Client: api},
variableClient: &variableClient{Client: api},
tokensClient: &tokensClient{Client: api},
workspaceClient: &workspaceClient{Client: api},
runClient: &runClient{Client: api, Config: config.APIConfig},
logsClient: &logsClient{Client: api},
}, nil
}
4 changes: 2 additions & 2 deletions internal/auth/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"fmt"
"net/url"

"github.com/leg100/otf/internal"
otfapi "github.com/leg100/otf/internal/api"
)

type (
Client struct {
internal.JSONAPIClient
*otfapi.Client

AuthService
}
Expand Down
2 changes: 1 addition & 1 deletion internal/auth/team_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewTeamCommand(api *otfapi.Client) *cobra.Command {
if err := cmd.Parent().PersistentPreRunE(cmd.Parent(), args); err != nil {
return err
}
cli.AuthService = &Client{JSONAPIClient: api}
cli.AuthService = &Client{Client: api}
return nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion internal/auth/user_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewUserCommand(api *otfapi.Client) *cobra.Command {
if err := cmd.Parent().PersistentPreRunE(cmd.Parent(), args); err != nil {
return err
}
cli.UserService = &Client{JSONAPIClient: api}
cli.UserService = &Client{Client: api}
return nil
},
}
Expand Down
4 changes: 2 additions & 2 deletions internal/configversion/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"fmt"
"net/url"

"github.com/leg100/otf/internal"
otfapi "github.com/leg100/otf/internal/api"
)

type Client struct {
internal.JSONAPIClient
*otfapi.Client

// Client does not implement all of service yet
Service
Expand Down
15 changes: 0 additions & 15 deletions internal/jsonapi.go

This file was deleted.

3 changes: 2 additions & 1 deletion internal/logs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"strconv"

"github.com/leg100/otf/internal"
otfapi "github.com/leg100/otf/internal/api"
)

type Client struct {
internal.JSONAPIClient
*otfapi.Client
}

func (c *Client) PutChunk(ctx context.Context, opts internal.PutChunkOptions) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/organization/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewCommand(api *otfapi.Client) *cobra.Command {
if err := cmd.Parent().PersistentPreRunE(cmd.Parent(), args); err != nil {
return err
}
cli.Service = &Client{JSONAPIClient: api}
cli.Service = &Client{Client: api}
return nil
},
}
Expand Down
4 changes: 2 additions & 2 deletions internal/organization/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"context"
"fmt"

"github.com/leg100/otf/internal"
otfapi "github.com/leg100/otf/internal/api"
"github.com/leg100/otf/internal/resource"
)

type Client struct {
internal.JSONAPIClient
*otfapi.Client

Service
}
Expand Down
4 changes: 2 additions & 2 deletions internal/run/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func NewCommand(api *otfapi.Client) *cobra.Command {
if err := cmd.Parent().PersistentPreRunE(cmd.Parent(), args); err != nil {
return err
}
cli.Service = &Client{JSONAPIClient: api}
cli.ConfigurationVersionService = &configversion.Client{JSONAPIClient: api}
cli.Service = &Client{Client: api}
cli.ConfigurationVersionService = &configversion.Client{Client: api}
return nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion internal/run/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

type Client struct {
internal.JSONAPIClient
*otfapi.Client
otfapi.Config

// Client does not implement all of service yet
Expand Down
4 changes: 2 additions & 2 deletions internal/state/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func NewCommand(api *otfapi.Client) *cobra.Command {
if err := cmd.Parent().PersistentPreRunE(cmd.Parent(), args); err != nil {
return err
}
cli.Service = &Client{JSONAPIClient: api}
cli.WorkspaceService = &workspace.Client{JSONAPIClient: api}
cli.Service = &Client{Client: api}
cli.WorkspaceService = &workspace.Client{Client: api}
return nil
},
}
Expand Down
3 changes: 2 additions & 1 deletion internal/state/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import (
"net/url"

"github.com/leg100/otf/internal"
otfapi "github.com/leg100/otf/internal/api"
"github.com/leg100/otf/internal/resource"
"github.com/leg100/otf/internal/tfeapi/types"
)

type Client struct {
internal.JSONAPIClient
*otfapi.Client

// Client does not implement all of service yet
Service
Expand Down
2 changes: 1 addition & 1 deletion internal/tokens/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewAgentsCommand(api *otfapi.Client) *cobra.Command {
if err := cmd.Parent().PersistentPreRunE(cmd.Parent(), args); err != nil {
return err
}
cli.TokensService = &Client{JSONAPIClient: api}
cli.TokensService = &Client{Client: api}
return nil
},
}
Expand Down
6 changes: 2 additions & 4 deletions internal/tokens/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ import (
"context"

otfapi "github.com/leg100/otf/internal/api"

"github.com/leg100/otf/internal"
)

type Client struct {
internal.JSONAPIClient
*otfapi.Client

// client doesn't implement all of service yet
TokensService
}

func NewClient(api *otfapi.Client) (*Client, error) {
return &Client{JSONAPIClient: api}, nil
return &Client{Client: api}, nil
}

func (c *Client) CreateRunToken(ctx context.Context, opts CreateRunTokenOptions) ([]byte, error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/variable/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"context"
"fmt"

"github.com/leg100/otf/internal"
otfapi "github.com/leg100/otf/internal/api"
)

type Client struct {
internal.JSONAPIClient
*otfapi.Client
}

func (c *Client) ListEffectiveVariables(ctx context.Context, runID string) ([]*Variable, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/workspace/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewCommand(api *otfapi.Client) *cobra.Command {
if err := cmd.Parent().PersistentPreRunE(cmd.Parent(), args); err != nil {
return err
}
cli.Service = &Client{JSONAPIClient: api}
cli.Service = &Client{Client: api}
return nil
},
}
Expand Down
4 changes: 2 additions & 2 deletions internal/workspace/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"fmt"
"net/url"

"github.com/leg100/otf/internal"
otfapi "github.com/leg100/otf/internal/api"
"github.com/leg100/otf/internal/resource"
)

type Client struct {
internal.JSONAPIClient
*otfapi.Client

WorkspaceService
}
Expand Down

0 comments on commit 5aa153a

Please sign in to comment.