Skip to content

Commit

Permalink
add basic vault integration
Browse files Browse the repository at this point in the history
  • Loading branch information
adelowo committed Feb 2, 2025
1 parent 36a6f26 commit 9903815
Show file tree
Hide file tree
Showing 13 changed files with 158 additions and 19 deletions.
3 changes: 2 additions & 1 deletion cmd/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (
"go.uber.org/zap"
)

func addMigrateCommand(c *cobra.Command, cfg *config.Config) {
func addMigrateCommand(c *cobra.Command,
cfg *config.Config) {

Check warning on line 17 in cmd/migrate.go

View check run for this annotation

Codecov / codecov/patch

cmd/migrate.go#L17

Added line #L17 was not covered by tests

cmd := &cobra.Command{
Use: "migrate",
Expand Down
1 change: 1 addition & 0 deletions generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ package malak
//go:generate mockgen -source=preferences.go -destination=mocks/preferences.go -package=malak_mocks
//go:generate mockgen -source=integration.go -destination=mocks/integration.go -package=malak_mocks
//go:generate mockgen -source=internal/pkg/billing/billing.go -destination=mocks/billing.go -package=malak_mocks
//go:generate mockgen -source=internal/vault/vault.go -destination=mocks/vault.go -package=malak_mocks
5 changes: 5 additions & 0 deletions integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ type WorkspaceIntegration struct {
IntegrationID uuid.UUID `json:"integration_id,omitempty"`
Integration *Integration `bun:"rel:belongs-to,join:integration_id=id" json:"integration,omitempty"`

// IsEnabled - this integration is enabled and data can be fetched
IsEnabled bool `json:"is_enabled,omitempty"`

// IsActive determines if the connection to the integration has been tested and works
IsActive bool `json:"is_active,omitempty"`

CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp" json:"created_at,omitempty"`
UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp" json:"updated_at,omitempty"`
DeletedAt *time.Time `bun:",soft_delete,nullzero" json:"-,omitempty"`
Expand Down Expand Up @@ -86,5 +90,6 @@ type IntegrationDataPoint struct {

type IntegrationProviderClient interface {
Name() IntegrationProvider
Ping(context.Context) error
io.Closer
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE workspace_integrations DROP COLUMN is_active;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE workspace_integrations ADD COLUMN is_active BOOLEAN DEFAULT FALSE;
3 changes: 3 additions & 0 deletions internal/integrations/paystack.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package integrations

type PaystackClient struct{}
12 changes: 12 additions & 0 deletions internal/vault/vault.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package vault

import (
"context"
"io"
)

type Vault interface {
io.Closer
Create(context.Context) error
Delete(context.Context) error
}
50 changes: 32 additions & 18 deletions mocks/integration.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 83 additions & 0 deletions mocks/vault.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions swagger/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3091,7 +3091,12 @@ const docTemplate = `{
"integration_id": {
"type": "string"
},
"is_active": {
"description": "IsActive determines if the connection to the integration has been tested and works",
"type": "boolean"
},
"is_enabled": {
"description": "IsEnabled - this integration is enabled and data can be fetched",
"type": "boolean"
},
"reference": {
Expand Down
5 changes: 5 additions & 0 deletions swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,12 @@
"integration_id": {
"type": "string"
},
"is_active": {
"description": "IsActive determines if the connection to the integration has been tested and works",
"type": "boolean"
},
"is_enabled": {
"description": "IsEnabled - this integration is enabled and data can be fetched",
"type": "boolean"
},
"reference": {
Expand Down
5 changes: 5 additions & 0 deletions swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,12 @@ components:
$ref: '#/components/schemas/malak.Integration'
integration_id:
type: string
is_active:
description: IsActive determines if the connection to the integration has
been tested and works
type: boolean
is_enabled:
description: IsEnabled - this integration is enabled and data can be fetched
type: boolean
reference:
type: string
Expand Down
3 changes: 3 additions & 0 deletions web/ui/src/client/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ export interface MalakWorkspaceIntegration {
id?: string;
integration?: MalakIntegration;
integration_id?: string;
/** IsActive determines if the connection to the integration has been tested and works */
is_active?: boolean;
/** IsEnabled - this integration is enabled and data can be fetched */
is_enabled?: boolean;
reference?: string;
updated_at?: string;
Expand Down

0 comments on commit 9903815

Please sign in to comment.