[DEPRECATED] Go implementation of plcbundle
1package plcbundle
2
3import (
4 "tangled.org/atscan.net/plcbundle/bundle"
5 "tangled.org/atscan.net/plcbundle/internal/plcclient"
6)
7
8type config struct {
9 bundleConfig *bundle.Config
10 plcClient *plcclient.Client
11}
12
13func defaultConfig() *config {
14 return &config{
15 bundleConfig: bundle.DefaultConfig("./plc_bundles"),
16 }
17}
18
19// Option configures the Manager
20type Option func(*config)
21
22// WithDirectory sets the bundle storage directory
23func WithDirectory(dir string) Option {
24 return func(c *config) {
25 c.bundleConfig.BundleDir = dir
26 }
27}
28
29// WithPLCDirectory sets the PLC directory URL
30func WithPLCDirectory(url string) Option {
31 return func(c *config) {
32 c.plcClient = plcclient.NewClient(url)
33 }
34}
35
36// WithVerifyOnLoad enables/disables hash verification when loading bundles
37func WithVerifyOnLoad(verify bool) Option {
38 return func(c *config) {
39 c.bundleConfig.VerifyOnLoad = verify
40 }
41}
42
43// WithLogger sets a custom logger
44func WithLogger(logger Logger) Option {
45 return func(c *config) {
46 c.bundleConfig.Logger = logger
47 }
48}
49
50// Logger interface
51type Logger interface {
52 Printf(format string, v ...interface{})
53 Println(v ...interface{})
54}