From 5f738735f50e1f71a8294445dd61173d7a5612a5 Mon Sep 17 00:00:00 2001 From: jaredoconnell Date: Thu, 22 Jun 2023 18:14:46 -0400 Subject: [PATCH 1/2] Added deployer selection to run-plugin --- cmd/run-plugin/run.go | 47 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/cmd/run-plugin/run.go b/cmd/run-plugin/run.go index 391237ac..543d1614 100644 --- a/cmd/run-plugin/run.go +++ b/cmd/run-plugin/run.go @@ -5,12 +5,15 @@ import ( "context" "flag" "fmt" + "go.flow.arcalot.io/deployer" + podman "go.flow.arcalot.io/podmandeployer" "os" "os/signal" log "go.arcalot.io/log/v2" docker "go.flow.arcalot.io/dockerdeployer" "go.flow.arcalot.io/pluginsdk/atp" + testdeployer "go.flow.arcalot.io/testdeployer" "gopkg.in/yaml.v3" ) @@ -18,18 +21,49 @@ func main() { var image string var file string var stepID string + var d deployer.AnyConnectorFactory + var defaultConfig any + var deployerID = "docker" flag.StringVar(&image, "image", image, "Docker image to run") flag.StringVar(&file, "file", file, "Input file") flag.StringVar(&stepID, "step", stepID, "Step name") + flag.StringVar(&deployerID, "deployer", stepID, "The name of the deployer") flag.Parse() - d := docker.NewFactory() - configSchema := d.ConfigurationSchema() - defaultConfig, err := configSchema.UnserializeType(map[string]any{}) - if err != nil { - panic(err) + switch deployerID { + case "docker": + dockerFactory := docker.NewFactory() + d = deployer.Any(dockerFactory) + + configSchema := dockerFactory.ConfigurationSchema() + var err error + defaultConfig, err = configSchema.UnserializeType(map[string]any{}) + if err != nil { + panic(err) + } + case "podman": + podmanFactory := podman.NewFactory() + d = deployer.Any(podmanFactory) + configSchema := podmanFactory.ConfigurationSchema() + var err error + defaultConfig, err = configSchema.UnserializeType(map[string]any{}) + if err != nil { + panic(err) + } + case "testimpl": + podmanFactory := testdeployer.NewFactory() + d = deployer.Any(podmanFactory) + configSchema := podmanFactory.ConfigurationSchema() + var err error + defaultConfig, err = configSchema.UnserializeType(map[string]any{}) + if err != nil { + panic(err) + } + default: + panic("No deployer selected. Options: docker, podman, testimpl. Select with -deployer") } + connector, err := d.Create(defaultConfig, log.New(log.Config{ Level: log.LevelDebug, Destination: log.DestinationStdout, @@ -52,6 +86,7 @@ func main() { } }() + fmt.Println("Deploying") plugin, err := connector.Deploy(ctx, image) if err != nil { panic(err) @@ -63,6 +98,7 @@ func main() { }() atpClient := atp.NewClient(plugin) + fmt.Println("Getting schema") pluginSchema, err := atpClient.ReadSchema() if err != nil { panic(err) @@ -83,6 +119,7 @@ func main() { if _, err := step.Input().Unserialize(input); err != nil { panic(err) } + fmt.Printf("Running step %s\n", stepID) outputID, outputData, err := atpClient.Execute(stepID, input) output := map[string]any{ "outputID": outputID, From 9c3e51b4340ced36c45c9db14e3a2a268afa6457 Mon Sep 17 00:00:00 2001 From: jaredoconnell Date: Wed, 28 Jun 2023 15:13:14 -0400 Subject: [PATCH 2/2] Improve message --- cmd/run-plugin/run.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/run-plugin/run.go b/cmd/run-plugin/run.go index 543d1614..be241dee 100644 --- a/cmd/run-plugin/run.go +++ b/cmd/run-plugin/run.go @@ -61,7 +61,7 @@ func main() { panic(err) } default: - panic("No deployer selected. Options: docker, podman, testimpl. Select with -deployer") + panic("No deployer or invalid deployer selected. Options: docker, podman, testimpl. Select with -deployer") } connector, err := d.Create(defaultConfig, log.New(log.Config{