Skip to content

Commit

Permalink
chore: raw workspace configs
Browse files Browse the repository at this point in the history
  • Loading branch information
achettyiitr committed Feb 8, 2024
1 parent 9d8fc91 commit c19d7c4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
11 changes: 10 additions & 1 deletion internal/clients/namespace/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (c *Client) Get(ctx context.Context, path string) (*http.Request, error) {
return req, nil
}

func (c *Client) GetWorkspaceConfigs(ctx context.Context) (*modelv2.WorkspaceConfigs, error) {
func (c *Client) GetRawWorkspaceConfigs(ctx context.Context) ([]byte, error) {
req, err := c.Get(ctx, "/data-plane/v2/namespaces/"+c.Identity.Namespace+"/config")
if err != nil {
return nil, err
Expand All @@ -39,6 +39,15 @@ func (c *Client) GetWorkspaceConfigs(ctx context.Context) (*modelv2.WorkspaceCon
return nil, err
}

return data, nil
}

func (c *Client) GetWorkspaceConfigs(ctx context.Context) (*modelv2.WorkspaceConfigs, error) {
data, err := c.GetRawWorkspaceConfigs(ctx)
if err != nil {
return nil, err
}

wcs, err := parser.Parse(data)
if err != nil {
return nil, err
Expand Down
11 changes: 10 additions & 1 deletion internal/clients/workspace/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (c *Client) Get(ctx context.Context, path string) (*http.Request, error) {
return req, nil
}

func (c *Client) GetWorkspaceConfigs(ctx context.Context) (*modelv2.WorkspaceConfigs, error) {
func (c *Client) GetRawWorkspaceConfigs(ctx context.Context) ([]byte, error) {
req, err := c.Get(ctx, "/data-plane/v2/workspaceConfig")
if err != nil {
return nil, err
Expand All @@ -39,6 +39,15 @@ func (c *Client) GetWorkspaceConfigs(ctx context.Context) (*modelv2.WorkspaceCon
return nil, err
}

return data, nil
}

func (c *Client) GetWorkspaceConfigs(ctx context.Context) (*modelv2.WorkspaceConfigs, error) {
data, err := c.GetRawWorkspaceConfigs(ctx)
if err != nil {
return nil, err
}

wcs, err := parser.Parse(data)
if err != nil {
return nil, err
Expand Down
7 changes: 7 additions & 0 deletions sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type ControlPlane struct {

type Client interface {
GetWorkspaceConfigs(ctx context.Context) (*modelv2.WorkspaceConfigs, error)
GetRawWorkspaceConfigs(ctx context.Context) ([]byte, error)
GetUpdatedWorkspaceConfigs(ctx context.Context, updatedAfter time.Time) (*modelv2.WorkspaceConfigs, error)
}

Expand Down Expand Up @@ -154,6 +155,12 @@ func (cp *ControlPlane) GetWorkspaceConfigs() (*modelv2.WorkspaceConfigs, error)
}
}

// GetRawWorkspaceConfigs returns the raw workspace configs.
// Currently, it does not support for incremental updates.
func (cp *ControlPlane) GetRawWorkspaceConfigs() ([]byte, error) {
return cp.Client.GetRawWorkspaceConfigs(context.Background())
}

type Subscriber interface {
Notifications() chan notifications.WorkspaceConfigNotification
}
Expand Down

0 comments on commit c19d7c4

Please sign in to comment.