-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpublish.go
More file actions
34 lines (26 loc) · 885 Bytes
/
publish.go
File metadata and controls
34 lines (26 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package app
import (
"bufio"
"os"
"github.com/aserto-dev/ds-load/cli/pkg/clients"
"github.com/aserto-dev/ds-load/cli/pkg/publish"
"github.com/aserto-dev/ds-load/sdk/common/cc"
"github.com/aserto-dev/ds-load/sdk/plugin"
"github.com/pkg/errors"
)
type PublishCmd struct {
clients.Config
}
func (l *PublishCmd) Run(commonCtx *cc.CommonCtx) error {
var publisher publish.Publisher
dirClient, err := clients.NewDirectoryV3ImportClient(commonCtx.Context, &l.Config)
if err != nil {
return errors.Wrap(err, "Could not connect to the directory")
}
publisher = publish.NewDirectoryPublisher(commonCtx, dirClient)
return l.processMessagesFromStdIn(commonCtx, publisher)
}
func (l *PublishCmd) processMessagesFromStdIn(commonCtx *cc.CommonCtx, publisher plugin.Publisher) error {
reader := bufio.NewReader(os.Stdin)
return publisher.Publish(commonCtx.Context, reader)
}