-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
8 changed files
with
199 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.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) { | ||
return nil, errors.New("unimplemented") | ||
} | ||
|
||
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 | ||
} |