Skip to content

Commit

Permalink
Add common execution Run
Browse files Browse the repository at this point in the history
  • Loading branch information
fabi200123 committed Aug 9, 2024
1 parent 75aeeee commit 5f6acef
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions execution/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package execution

import (
"context"
"fmt"
"os"

Expand All @@ -23,6 +24,11 @@ import (
executionv011 "github.com/cloudbase/garm-provider-common/execution/v0.1.1"
)

type ExternalProvider interface {
executionv010.ExternalProvider
executionv011.ExternalProvider
}

type Environment struct {
EnvironmentV010 executionv010.EnvironmentV010
EnvironmentV011 executionv011.EnvironmentV011
Expand Down Expand Up @@ -61,3 +67,14 @@ func GetEnvironment() (Environment, error) {
return Environment{}, fmt.Errorf("unsupported interface version: %s", interfaceVersion)
}
}

func Run(ctx context.Context, provider ExternalProvider, env Environment) (string, error) {
switch env.InterfaceVersion {
case common.Version010:
return executionv010.Run(ctx, provider, env.EnvironmentV010)
case common.Version011:
return executionv011.Run(ctx, provider, env.EnvironmentV011)
default:
return "", fmt.Errorf("unsupported interface version: %s", env.InterfaceVersion)
}
}

0 comments on commit 5f6acef

Please sign in to comment.