Skip to content

Commit

Permalink
<feat>(K8s): Add DeleteJob
Browse files Browse the repository at this point in the history
  • Loading branch information
joelbraga committed Dec 11, 2018
1 parent 684ad5b commit 7cd5bf7
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 27 deletions.
157 changes: 132 additions & 25 deletions internal/pb/k8s_service.pb.go

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

9 changes: 9 additions & 0 deletions internal/pb/k8s_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ message CreateJobRequest {
message CreateJobResponse {
}

message DeleteJobRequest {
string Name = 1;
}

message DeleteJobResponse {
}

service K8sService {
rpc GetConfigMap (GetConfigMapRequest) returns (GetConfigMapResponse) {
}
Expand All @@ -63,4 +70,6 @@ service K8sService {
}
rpc CreateJob (CreateJobRequest) returns (CreateJobResponse) {
}
rpc DeleteJob (DeleteJobRequest) returns (DeleteJobResponse) {
}
}
5 changes: 5 additions & 0 deletions pkg/server/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,8 @@ func (s *K8sService) CreateJob(ctx context.Context, in *pb.CreateJobRequest) (*p
err = s.manager.CreateJob(&jobTemplateData, false)
return &pb.CreateJobResponse{}, err
}

func (s *K8sService) DeleteJob(ctx context.Context, in *pb.DeleteJobRequest) (*pb.DeleteJobResponse, error) {
err := s.manager.DeleteJob(in.Name)
return &pb.DeleteJobResponse{}, err
}
3 changes: 1 addition & 2 deletions pkg/server/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ func TestNewK8sService(t *testing.T) {

t.Run("GetConfigMap", func(t *testing.T) {
res, err := service.GetConfigMap(context.Background(), &pb.GetConfigMapRequest{
Namespace: os.Getenv("K8S_NAMESPACE"),
Key: "mrs-service-scheduler",
Key: "mrs-service-scheduler",
})
if err != nil {
t.Error(err)
Expand Down

0 comments on commit 7cd5bf7

Please sign in to comment.