diff --git a/.gitignore b/.gitignore index 112066fb..a0df6f17 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ bin/* *.dll *.so *.dylib - .DS_Store # Vale will install modules in `.vale/style` and those should not be in version control @@ -30,3 +29,6 @@ vendor/ go.work dist/ +.tmp +.fabric +.fabric-lock.json \ No newline at end of file diff --git a/.golangci.yaml b/.golangci.yaml index 600588cd..8b7313a1 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -86,7 +86,9 @@ linters-settings: nolintlint: require-explanation: false # don't require an explanation for nolint directives require-specific: false # don't require nolint directives to be specific about which linter is being skipped - + # gosec: + # excludes: + # - G110 linters: disable-all: true enable: diff --git a/.mockery.yaml b/.mockery.yaml index 51c97f6d..753bde14 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -28,4 +28,8 @@ packages: github.com/blackstork-io/fabric/internal/splunk/client: config: interfaces: - Client: \ No newline at end of file + Client: + github.com/blackstork-io/fabric/plugin/resolver: + config: + interfaces: + Source: \ No newline at end of file diff --git a/buf.gen.yaml b/buf.gen.yaml index fb330997..f15052e0 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -9,7 +9,4 @@ plugins: opt: module=github.com/blackstork-io/fabric - plugin: buf.build/grpc/go out: . - opt: module=github.com/blackstork-io/fabric - # - plugin: buf.build/connectrpc/go - # out: . - # opt: module=github.com/knobz-io/knobz \ No newline at end of file + opt: module=github.com/blackstork-io/fabric \ No newline at end of file diff --git a/mocks/plugin/resolver/source.go b/mocks/plugin/resolver/source.go new file mode 100644 index 00000000..a1a9825e --- /dev/null +++ b/mocks/plugin/resolver/source.go @@ -0,0 +1,157 @@ +// Code generated by mockery v2.42.0. DO NOT EDIT. + +package resolver_mocks + +import ( + context "context" + + resolver "github.com/blackstork-io/fabric/plugin/resolver" + mock "github.com/stretchr/testify/mock" +) + +// Source is an autogenerated mock type for the Source type +type Source struct { + mock.Mock +} + +type Source_Expecter struct { + mock *mock.Mock +} + +func (_m *Source) EXPECT() *Source_Expecter { + return &Source_Expecter{mock: &_m.Mock} +} + +// Lookup provides a mock function with given fields: ctx, name +func (_m *Source) Lookup(ctx context.Context, name resolver.Name) ([]resolver.Version, error) { + ret := _m.Called(ctx, name) + + if len(ret) == 0 { + panic("no return value specified for Lookup") + } + + var r0 []resolver.Version + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, resolver.Name) ([]resolver.Version, error)); ok { + return rf(ctx, name) + } + if rf, ok := ret.Get(0).(func(context.Context, resolver.Name) []resolver.Version); ok { + r0 = rf(ctx, name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]resolver.Version) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, resolver.Name) error); ok { + r1 = rf(ctx, name) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Source_Lookup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Lookup' +type Source_Lookup_Call struct { + *mock.Call +} + +// Lookup is a helper method to define mock.On call +// - ctx context.Context +// - name resolver.Name +func (_e *Source_Expecter) Lookup(ctx interface{}, name interface{}) *Source_Lookup_Call { + return &Source_Lookup_Call{Call: _e.mock.On("Lookup", ctx, name)} +} + +func (_c *Source_Lookup_Call) Run(run func(ctx context.Context, name resolver.Name)) *Source_Lookup_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(resolver.Name)) + }) + return _c +} + +func (_c *Source_Lookup_Call) Return(_a0 []resolver.Version, _a1 error) *Source_Lookup_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Source_Lookup_Call) RunAndReturn(run func(context.Context, resolver.Name) ([]resolver.Version, error)) *Source_Lookup_Call { + _c.Call.Return(run) + return _c +} + +// Resolve provides a mock function with given fields: ctx, name, version, checksums +func (_m *Source) Resolve(ctx context.Context, name resolver.Name, version resolver.Version, checksums []resolver.Checksum) (*resolver.ResolvedPlugin, error) { + ret := _m.Called(ctx, name, version, checksums) + + if len(ret) == 0 { + panic("no return value specified for Resolve") + } + + var r0 *resolver.ResolvedPlugin + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, resolver.Name, resolver.Version, []resolver.Checksum) (*resolver.ResolvedPlugin, error)); ok { + return rf(ctx, name, version, checksums) + } + if rf, ok := ret.Get(0).(func(context.Context, resolver.Name, resolver.Version, []resolver.Checksum) *resolver.ResolvedPlugin); ok { + r0 = rf(ctx, name, version, checksums) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*resolver.ResolvedPlugin) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, resolver.Name, resolver.Version, []resolver.Checksum) error); ok { + r1 = rf(ctx, name, version, checksums) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Source_Resolve_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Resolve' +type Source_Resolve_Call struct { + *mock.Call +} + +// Resolve is a helper method to define mock.On call +// - ctx context.Context +// - name resolver.Name +// - version resolver.Version +// - checksums []resolver.Checksum +func (_e *Source_Expecter) Resolve(ctx interface{}, name interface{}, version interface{}, checksums interface{}) *Source_Resolve_Call { + return &Source_Resolve_Call{Call: _e.mock.On("Resolve", ctx, name, version, checksums)} +} + +func (_c *Source_Resolve_Call) Run(run func(ctx context.Context, name resolver.Name, version resolver.Version, checksums []resolver.Checksum)) *Source_Resolve_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(resolver.Name), args[2].(resolver.Version), args[3].([]resolver.Checksum)) + }) + return _c +} + +func (_c *Source_Resolve_Call) Return(_a0 *resolver.ResolvedPlugin, _a1 error) *Source_Resolve_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Source_Resolve_Call) RunAndReturn(run func(context.Context, resolver.Name, resolver.Version, []resolver.Checksum) (*resolver.ResolvedPlugin, error)) *Source_Resolve_Call { + _c.Call.Return(run) + return _c +} + +// NewSource creates a new instance of Source. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewSource(t interface { + mock.TestingT + Cleanup(func()) +}) *Source { + mock := &Source{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/plugin/registry/.gitkeep b/plugin/registry/.gitkeep deleted file mode 100644 index e69de29b..00000000