mukan-ignite/ignite/internal/plugin/testdata/execute_ok/main.go
Mukan Erkin Törük c32551b6f7
Some checks failed
Docs Deploy / build_and_deploy (push) Has been cancelled
Generate Docs / cli (push) Has been cancelled
Generate Config Doc / cli (push) Has been cancelled
Go formatting / go-formatting (push) Has been cancelled
Check links / markdown-link-check (push) Has been cancelled
Integration / pre-test (push) Has been cancelled
Integration / test on (push) Has been cancelled
Integration / status (push) Has been cancelled
Lint / Lint Go code (push) Has been cancelled
Test / test (ubuntu-latest) (push) Has been cancelled
refactor: replace all github.com upstream refs with git.cw.tr/mukan-network
2026-05-11 03:36:24 +03:00

64 lines
1.7 KiB
Go

package main
import (
"context"
"fmt"
hplugin "github.com/hashicorp/go-plugin"
"git.cw.tr/mukan-network/mukan-ignite/ignite/pkg/errors"
"git.cw.tr/mukan-network/mukan-ignite/ignite/services/plugin"
)
type app struct{}
func (app) Manifest(context.Context) (*plugin.Manifest, error) {
return &plugin.Manifest{
Name: "execute_ok",
}, nil
}
func (app) Execute(ctx context.Context, cmd *plugin.ExecutedCommand, api plugin.ClientAPI) error {
c, err := api.GetChainInfo(ctx)
fmt.Printf(
"ok args=%s chainid=%s appPath=%s configPath=%s home=%s rpcAddress=%s\n",
cmd.Args, c.ChainId, c.AppPath, c.ConfigPath, c.Home, c.RpcAddress,
)
if err != nil {
return errors.Errorf("failed to get chain info: %w", err)
}
i, err := api.GetIgniteInfo(ctx)
fmt.Printf(
"ok args=%s cliVersion=%s goVersion=%s sdkVersion=%s bufVersion=%s buildDate=%s "+
"sourceHash=%s configVersion=%s os=%s arch=%s buildFromSource=%t\n",
cmd.Args, i.CliVersion, i.GoVersion, i.SdkVersion, i.BufVersion, i.BuildDate, i.SourceHash, i.ConfigVersion,
i.Os, i.Arch, i.BuildFromSource,
)
if err != nil {
return errors.Errorf("failed to get ignite info: %w", err)
}
return nil
}
func (app) ExecuteHookPre(context.Context, *plugin.ExecutedHook, plugin.ClientAPI) error {
return nil
}
func (app) ExecuteHookPost(context.Context, *plugin.ExecutedHook, plugin.ClientAPI) error {
return nil
}
func (app) ExecuteHookCleanUp(context.Context, *plugin.ExecutedHook, plugin.ClientAPI) error {
return nil
}
func main() {
hplugin.Serve(&hplugin.ServeConfig{
HandshakeConfig: plugin.HandshakeConfig(),
Plugins: map[string]hplugin.Plugin{
"execute_ok": plugin.NewGRPC(&app{}),
},
GRPCServer: hplugin.DefaultGRPCServer,
})
}