-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package testworkflow | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
|
||
testworkflowsv1 "github.com/kubeshop/testkube-operator/api/testworkflows/v1" | ||
testworkflowsclientv1 "github.com/kubeshop/testkube-operator/pkg/client/testworkflows/v1" | ||
"github.com/kubeshop/testkube/pkg/cloud" | ||
"github.com/kubeshop/testkube/pkg/cloud/data/executor" | ||
testworkflowmappers "github.com/kubeshop/testkube/pkg/mapper/testworkflows" | ||
|
||
"github.com/pkg/errors" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
var _ testworkflowsclientv1.TestWorkflowTemplatesInterface = (*CloudTestWorkflowTemplateRepository)(nil) | ||
|
||
type CloudTestWorkflowTemplateRepository struct { | ||
executor executor.Executor | ||
} | ||
|
||
func NewCloudTestWorkflowTemplateRepository(client cloud.TestKubeCloudAPIClient, grpcConn *grpc.ClientConn, apiKey string) *CloudTestWorkflowTemplateRepository { | ||
return &CloudTestWorkflowTemplateRepository{executor: executor.NewCloudGRPCExecutor(client, grpcConn, apiKey)} | ||
} | ||
|
||
func (r *CloudTestWorkflowTemplateRepository) List(selector string) (*testworkflowsv1.TestWorkflowTemplateList, error) { | ||
return nil, errors.New("unimplemented") | ||
} | ||
|
||
func (r *CloudTestWorkflowTemplateRepository) ListLabels() (map[string][]string, error) { | ||
return make(map[string][]string), nil | ||
} | ||
|
||
func (r *CloudTestWorkflowTemplateRepository) Get(name string) (*testworkflowsv1.TestWorkflowTemplate, error) { | ||
req := TestWorkflowTemplateGetRequest{Name: name} | ||
response, err := r.executor.Execute(context.Background(), CmdTestWorkflowTemplateGet, req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var commandResponse TestWorkflowTemplateGetResponse | ||
if err := json.Unmarshal(response, &commandResponse); err != nil { | ||
return nil, err | ||
} | ||
return testworkflowmappers.MapTemplateAPIToKube(&commandResponse.TestWorkflowTemplate), nil | ||
} | ||
|
||
// Create creates new TestWorkflow | ||
func (r *CloudTestWorkflowTemplateRepository) Create(workflow *testworkflowsv1.TestWorkflowTemplate) (*testworkflowsv1.TestWorkflowTemplate, error) { | ||
return nil, errors.New("unimplemented") | ||
} | ||
|
||
func (r *CloudTestWorkflowTemplateRepository) Update(workflow *testworkflowsv1.TestWorkflowTemplate) (*testworkflowsv1.TestWorkflowTemplate, error) { | ||
return nil, errors.New("unimplemented") | ||
} | ||
|
||
func (r *CloudTestWorkflowTemplateRepository) Apply(workflow *testworkflowsv1.TestWorkflowTemplate) error { | ||
return errors.New("unimplemented") | ||
} | ||
|
||
func (r *CloudTestWorkflowTemplateRepository) Delete(name string) error { | ||
return errors.New("unimplemented") | ||
} | ||
|
||
func (r *CloudTestWorkflowTemplateRepository) DeleteAll() error { | ||
return errors.New("unimplemented") | ||
} | ||
|
||
func (r *CloudTestWorkflowTemplateRepository) DeleteByLabels(selector string) error { | ||
return errors.New("unimplemented") | ||
} | ||
|
||
func (r *CloudTestWorkflowTemplateRepository) UpdateStatus(workflow *testworkflowsv1.TestWorkflowTemplate) error { | ||
// This is the actual implementation, as update status | ||
// should update k8s crd's status field, but we don't have it when stored in mongo | ||
return nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package testworkflow | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
|
||
testworkflowsv1 "github.com/kubeshop/testkube-operator/api/testworkflows/v1" | ||
testworkflowsclientv1 "github.com/kubeshop/testkube-operator/pkg/client/testworkflows/v1" | ||
"github.com/kubeshop/testkube/pkg/cloud" | ||
"github.com/kubeshop/testkube/pkg/cloud/data/executor" | ||
testworkflowmappers "github.com/kubeshop/testkube/pkg/mapper/testworkflows" | ||
|
||
"github.com/pkg/errors" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
var _ testworkflowsclientv1.Interface = (*CloudTestWorkflowRepository)(nil) | ||
|
||
type CloudTestWorkflowRepository struct { | ||
executor executor.Executor | ||
} | ||
|
||
func NewCloudTestWorkflowRepository(client cloud.TestKubeCloudAPIClient, grpcConn *grpc.ClientConn, apiKey string) *CloudTestWorkflowRepository { | ||
return &CloudTestWorkflowRepository{executor: executor.NewCloudGRPCExecutor(client, grpcConn, apiKey)} | ||
} | ||
|
||
func (r *CloudTestWorkflowRepository) List(selector string) (*testworkflowsv1.TestWorkflowList, error) { | ||
req := TestWorkflowListRequest{Selector: selector} | ||
response, err := r.executor.Execute(context.Background(), CmdTestWorkflowList, req) | ||
Check failure on line 29 in pkg/cloud/data/testworkflow/workflows.go GitHub Actions / api
Check failure on line 29 in pkg/cloud/data/testworkflow/workflows.go GitHub Actions / testworkflow (testworkflow-toolkit)
Check failure on line 29 in pkg/cloud/data/testworkflow/workflows.go GitHub Actions / Lint Go
Check failure on line 29 in pkg/cloud/data/testworkflow/workflows.go GitHub Actions / Lint Go
Check failure on line 29 in pkg/cloud/data/testworkflow/workflows.go GitHub Actions / Lint Go
Check failure on line 29 in pkg/cloud/data/testworkflow/workflows.go GitHub Actions / Unit Tests
Check failure on line 29 in pkg/cloud/data/testworkflow/workflows.go GitHub Actions / Unit Tests
Check failure on line 29 in pkg/cloud/data/testworkflow/workflows.go GitHub Actions / Integration Tests
|
||
if err != nil { | ||
return nil, err | ||
} | ||
var commandResponse TestWorkflowListResponse | ||
if err := json.Unmarshal(response, &commandResponse); err != nil { | ||
return nil, err | ||
} | ||
list := testworkflowmappers.MapListAPIToKube(commandResponse.TestWorkflows) | ||
return &list, nil | ||
} | ||
|
||
func (r *CloudTestWorkflowRepository) ListLabels() (map[string][]string, error) { | ||
return make(map[string][]string), errors.New("unimplemented") | ||
} | ||
|
||
func (r *CloudTestWorkflowRepository) Get(name string) (*testworkflowsv1.TestWorkflow, error) { | ||
req := TestWorkflowGetRequest{Name: name} | ||
response, err := r.executor.Execute(context.Background(), CmdTestWorkflowGet, req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var commandResponse TestWorkflowGetResponse | ||
if err := json.Unmarshal(response, &commandResponse); err != nil { | ||
return nil, err | ||
} | ||
return testworkflowmappers.MapAPIToKube(&commandResponse.TestWorkflow), nil | ||
} | ||
|
||
// Create creates new TestWorkflow | ||
func (r *CloudTestWorkflowRepository) Create(workflow *testworkflowsv1.TestWorkflow) (*testworkflowsv1.TestWorkflow, error) { | ||
return nil, errors.New("unimplemented") | ||
} | ||
|
||
func (r *CloudTestWorkflowRepository) Update(workflow *testworkflowsv1.TestWorkflow) (*testworkflowsv1.TestWorkflow, error) { | ||
return nil, errors.New("unimplemented") | ||
} | ||
|
||
func (r *CloudTestWorkflowRepository) Apply(workflow *testworkflowsv1.TestWorkflow) error { | ||
return errors.New("unimplemented") | ||
} | ||
|
||
func (r *CloudTestWorkflowRepository) Delete(name string) error { | ||
return errors.New("unimplemented") | ||
} | ||
|
||
func (r *CloudTestWorkflowRepository) DeleteAll() error { | ||
return errors.New("unimplemented") | ||
} | ||
|
||
func (r *CloudTestWorkflowRepository) DeleteByLabels(selector string) error { | ||
return errors.New("unimplemented") | ||
} | ||
|
||
func (r *CloudTestWorkflowRepository) UpdateStatus(workflow *testworkflowsv1.TestWorkflow) error { | ||
// This is the actual implementation, as update status | ||
// should update k8s crd's status field, but we don't have it when stored in mongo | ||
return nil | ||
} |