Skip to content

Commit

Permalink
Use vanilla go-cty
Browse files Browse the repository at this point in the history
Drop support for `psy:` struct tags, no longer use the fork providing
FromCtyValueTagged
  • Loading branch information
gastrodon committed Sep 22, 2024
1 parent d658c55 commit 1f9906a
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 22 deletions.
12 changes: 3 additions & 9 deletions core/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ import (
"github.com/gastrodon/psyduck/stdlib"
)

func parser(config cty.Value) sdk.Parser {
return func(target interface{}) error {
return gocty.FromCtyValueTagged(config, target, "psy")
}
}

type library struct {
plugins []*sdk.Plugin
resources map[string]*sdk.Resource
Expand All @@ -33,7 +27,7 @@ func (l *library) Producer(name string, options cty.Value) (sdk.Producer, error)
}

return found.ProvideProducer(func(target interface{}) error {
return gocty.FromCtyValueTagged(options, target, "psy")
return gocty.FromCtyValue(options, target)
})
}

Expand All @@ -48,7 +42,7 @@ func (l *library) Consumer(name string, options cty.Value) (sdk.Consumer, error)
}

return found.ProvideConsumer(func(target interface{}) error {
return gocty.FromCtyValueTagged(options, target, "psy")
return gocty.FromCtyValue(options, target)
})
}

Expand All @@ -63,7 +57,7 @@ func (l *library) Transformer(name string, options cty.Value) (sdk.Transformer,
}

return found.ProvideTransformer(func(target interface{}) error {
return gocty.FromCtyValueTagged(options, target, "psy")
return gocty.FromCtyValue(options, target)
})
}

Expand Down
2 changes: 1 addition & 1 deletion core/library_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestLibrary(t *testing.T) {
},
ProvideProducer: func(parse sdk.Parser) (sdk.Producer, error) {
target := new(struct {
Count int `psy:"count"`
Count int `cty:"count"`
})

if err := parse(target); err != nil {
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,3 @@ require (
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/zclconf/go-cty => github.com/gastrodon/go-cty v1.15.0
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho=
github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk=
github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ=
github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI=
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8=
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
Expand Down
4 changes: 2 additions & 2 deletions stdlib/produce/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
)

type constant struct {
Value string `psy:"value"`
StopAfter int `psy:"stop-after"`
Value string `cty:"value"`
StopAfter int `cty:"stop-after"`
}

func Constant(parse sdk.Parser) (sdk.Producer, error) {
Expand Down
2 changes: 1 addition & 1 deletion stdlib/produce/increment.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/psyduck-etl/sdk"

func Increment(parse sdk.Parser) (sdk.Producer, error) {
config := new(struct {
StopAfter byte `psy:"stop-after"`
StopAfter byte `cty:"stop-after"`
})

if err := parse(config); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion stdlib/transform/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

type inspectConfig struct {
BeString bool `psy:"be-string"`
BeString bool `cty:"be-string"`
}

func Inspect(parse sdk.Parser) (sdk.Transformer, error) {
Expand Down
2 changes: 1 addition & 1 deletion stdlib/transform/snippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

type snippetConfig struct {
Fields []string `psy:"fields"`
Fields []string `cty:"fields"`
}

func Snippet(parse sdk.Parser) (sdk.Transformer, error) {
Expand Down
4 changes: 2 additions & 2 deletions stdlib/transform/sprintf.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
)

type sprintfConfig struct {
Format string `psy:"format"`
Encoding string `psy:"encoding"`
Format string `cty:"format"`
Encoding string `cty:"encoding"`
}

func Sprintf(parse sdk.Parser) (sdk.Transformer, error) {
Expand Down
2 changes: 1 addition & 1 deletion stdlib/transform/transpose.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

type transposeConfig struct {
Fields map[string][]string `psy:"fields"`
Fields map[string][]string `cty:"fields"`
}

func readField(data map[string]zoomTarget, field []string) ([]byte, error) {
Expand Down
2 changes: 1 addition & 1 deletion stdlib/transform/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func Wait(parse sdk.Parser) (sdk.Transformer, error) {
config := new(struct {
Ms int64 `psy:"milliseconds"`
Ms int64 `cty:"milliseconds"`
})

if err := parse(config); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion stdlib/transform/zoom.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

type zoomConfig struct {
Field string `psy:"field"`
Field string `cty:"field"`
}

type zoomTarget []byte
Expand Down

0 comments on commit 1f9906a

Please sign in to comment.