diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 03d09d8..e9e5eb1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,10 +33,10 @@ jobs: run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 + uses: goreleaser/goreleaser-action@v5 with: version: latest - args: release --rm-dist --debug + args: release --clean --debug env: # create personal access token: https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line GITHUB_TOKEN: ${{ secrets.GH_PAT }} diff --git a/internal/auth/token-provider.go b/internal/auth/token-provider.go index 89695ed..b3b2af5 100644 --- a/internal/auth/token-provider.go +++ b/internal/auth/token-provider.go @@ -2,7 +2,7 @@ package auth import ( "github.com/IBM/sarama" - "github.com/deviceinsight/kafkactl/v5/pkg/plugins" + "github.com/deviceinsight/kafkactl/v5/internal/util" "github.com/deviceinsight/kafkactl/v5/pkg/plugins/auth" ) @@ -22,7 +22,7 @@ func LoadTokenProviderPlugin(pluginName string, options map[string]any, brokers loadedPlugin, ok := loadedPlugins[pluginName] if !ok { var err error - loadedPlugin, err = plugins.LoadPlugin(pluginName, auth.TokenProviderPluginSpec) + loadedPlugin, err = util.LoadPlugin(pluginName, auth.TokenProviderPluginSpec) if err != nil { return nil, err } diff --git a/pkg/plugins/plugin.go b/internal/util/plugin.go similarity index 84% rename from pkg/plugins/plugin.go rename to internal/util/plugin.go index 009048d..b8ac14e 100644 --- a/pkg/plugins/plugin.go +++ b/internal/util/plugin.go @@ -1,4 +1,4 @@ -package plugins +package util import ( "fmt" @@ -9,25 +9,13 @@ import ( "github.com/deviceinsight/kafkactl/v5/internal/global" "github.com/deviceinsight/kafkactl/v5/internal/output" + "github.com/deviceinsight/kafkactl/v5/pkg/plugins" "github.com/hashicorp/go-hclog" "github.com/hashicorp/go-plugin" "github.com/pkg/errors" ) -const GenericInterfaceIdentifier = "generic" - -type PluginSpec[P plugin.Plugin, I any] struct { - PluginImpl P - Handshake plugin.HandshakeConfig -} - -func (s *PluginSpec[P, I]) GetMap() map[string]plugin.Plugin { - return map[string]plugin.Plugin{ - GenericInterfaceIdentifier: s.PluginImpl, - } -} - -func LoadPlugin[P plugin.Plugin, I any](pluginName string, pluginSpec PluginSpec[P, I]) (impl I, err error) { +func LoadPlugin[P plugin.Plugin, I any](pluginName string, pluginSpec plugins.PluginSpec[P, I]) (impl I, err error) { pluginPath, err := resolvePluginPath(pluginName) if err != nil { @@ -59,7 +47,7 @@ func LoadPlugin[P plugin.Plugin, I any](pluginName string, pluginSpec PluginSpec } // Request the plugin - raw, err := rpcClient.Dispense(GenericInterfaceIdentifier) + raw, err := rpcClient.Dispense(pluginSpec.InterfaceIdentifier) if err != nil { client.Kill() return impl, err diff --git a/pkg/plugins/auth/interface.go b/pkg/plugins/auth/interface.go index ccd781f..1cea0f6 100644 --- a/pkg/plugins/auth/interface.go +++ b/pkg/plugins/auth/interface.go @@ -11,7 +11,8 @@ type AccessTokenProvider interface { } var TokenProviderPluginSpec = plugins.PluginSpec[*TokenProviderPlugin, AccessTokenProvider]{ - PluginImpl: &TokenProviderPlugin{}, + PluginImpl: &TokenProviderPlugin{}, + InterfaceIdentifier: "tokenProvider", Handshake: plugin.HandshakeConfig{ ProtocolVersion: 1, MagicCookieKey: "KAFKACTL_PLUGIN", diff --git a/pkg/plugins/plugins.go b/pkg/plugins/plugins.go new file mode 100644 index 0000000..752f570 --- /dev/null +++ b/pkg/plugins/plugins.go @@ -0,0 +1,15 @@ +package plugins + +import "github.com/hashicorp/go-plugin" + +type PluginSpec[P plugin.Plugin, I any] struct { + PluginImpl P + InterfaceIdentifier string + Handshake plugin.HandshakeConfig +} + +func (s *PluginSpec[P, I]) GetMap() map[string]plugin.Plugin { + return map[string]plugin.Plugin{ + s.InterfaceIdentifier: s.PluginImpl, + } +}