Skip to content

Commit ab07ea2

Browse files
authored
refactor: task/hook plugins server should have constructor (#11)
Signed-off-by: Kush Sharma <[email protected]>
1 parent 95372d6 commit ab07ea2

File tree

6 files changed

+43
-13
lines changed

6 files changed

+43
-13
lines changed

api/handler/v1/runtime.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ func (sv *RuntimeServiceServer) DeployJobSpecification(req *pb.DeployJobSpecific
121121
log: logrus.New(),
122122
})
123123

124-
// delete specs not sent for deployment
125-
// currently we don't support deploying a single dag at a time so this will change
126-
// once we do that
124+
// delete specs not sent for deployment from internal repository
127125
if err := sv.jobSvc.KeepOnly(namespaceSpec, jobsToKeep, observers); err != nil {
128126
return status.Error(codes.Internal, fmt.Sprintf("%s: failed to delete jobs", err.Error()))
129127
}

docs/concepts/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Basic building blocks of Optimus are
99

1010
### Overview
1111

12-
![Overview](OptimusArchitecture_dark_07June2021.png?raw=true "OptimusArchitecture")
12+
![Overview](https://github.com/odpf/optimus/blob/95372d614af47dc0140f6b96f819bf08eb62a189/docs/concepts/OptimusArchitecture_dark_07June2021.png?raw=true "OptimusArchitecture")
1313

1414
### Optimus CLI
1515

job/service.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -425,17 +425,17 @@ func (srv *Service) notifyProgress(po progress.Observer, event progress.Event) {
425425
po.Notify(event)
426426
}
427427

428-
func setSubstract(left []string, right []string) []string {
429-
rightMap := make(map[string]struct{})
430-
for _, item := range right {
431-
rightMap[item] = struct{}{}
428+
// remove items present in from
429+
func setSubstract(from []string, remove []string) []string {
430+
removeMap := make(map[string]bool)
431+
for _, item := range remove {
432+
removeMap[item] = true
432433
}
433434

434435
res := make([]string, 0)
435-
for _, leftKey := range left {
436-
_, exists := rightMap[leftKey]
437-
if !exists {
438-
res = append(res, leftKey)
436+
for _, fromKey := range from {
437+
if _, exists := removeMap[fromKey]; !exists {
438+
res = append(res, fromKey)
439439
}
440440
}
441441

plugin/hook/connector.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package hook
33
import (
44
"context"
55

6+
v1 "github.com/odpf/optimus/api/handler/v1"
7+
68
"github.com/odpf/optimus/models"
79

810
"github.com/hashicorp/go-plugin"
@@ -39,3 +41,17 @@ func (p *Plugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *g
3941
projectSpecAdapter: p.ProjectSpecAdapter,
4042
}, nil
4143
}
44+
45+
func NewPlugin(impl models.HookPlugin) *Plugin {
46+
return &Plugin{
47+
Impl: impl,
48+
ProjectSpecAdapter: v1.NewAdapter(nil, nil, nil),
49+
}
50+
}
51+
52+
func NewPluginWithAdapter(impl models.HookPlugin, projAdapt ProjectSpecAdapter) *Plugin {
53+
return &Plugin{
54+
Impl: impl,
55+
ProjectSpecAdapter: projAdapt,
56+
}
57+
}

plugin/task/connector.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package task
33
import (
44
"context"
55

6+
v1 "github.com/odpf/optimus/api/handler/v1"
7+
68
"github.com/odpf/optimus/models"
79

810
"github.com/hashicorp/go-plugin"
@@ -39,3 +41,17 @@ func (p *Plugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *g
3941
projectSpecAdapter: p.ProjectSpecAdapter,
4042
}, nil
4143
}
44+
45+
func NewPlugin(impl models.TaskPlugin) *Plugin {
46+
return &Plugin{
47+
Impl: impl,
48+
ProjectSpecAdapter: v1.NewAdapter(nil, nil, nil),
49+
}
50+
}
51+
52+
func NewPluginWithAdapter(impl models.TaskPlugin, projAdapt ProjectSpecAdapter) *Plugin {
53+
return &Plugin{
54+
Impl: impl,
55+
ProjectSpecAdapter: projAdapt,
56+
}
57+
}

store/gcs/job_repository.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func (repo *JobRepository) pathFor(j models.Job) string {
205205

206206
func (repo *JobRepository) jobNameFromPath(filePath string) string {
207207
jobFileName := path.Base(filePath)
208-
return strings.TrimRight(jobFileName, repo.Suffix)
208+
return strings.TrimSuffix(jobFileName, repo.Suffix)
209209
}
210210

211211
func cleanPrefix(prefix string) string {

0 commit comments

Comments
 (0)