Skip to content

Commit

Permalink
Set provider to use v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fabi200123 committed Sep 4, 2024
1 parent 619da3b commit d7fcc10
Show file tree
Hide file tree
Showing 78 changed files with 1,544 additions and 222 deletions.
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/aws/aws-sdk-go-v2/credentials v1.17.20
github.com/aws/aws-sdk-go-v2/service/ec2 v1.165.0
github.com/aws/smithy-go v1.20.2
github.com/cloudbase/garm-provider-common v0.1.3
github.com/cloudbase/garm-provider-common v0.1.4-0.20240904071738-0eb0ffc5da1e
github.com/stretchr/testify v1.9.0
github.com/xeipuuv/gojsonschema v1.2.0
)
Expand Down Expand Up @@ -39,8 +39,9 @@ require (
github.com/teris-io/shortid v0.0.0-20220617161101-71ec9f2aa569 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/sys v0.24.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.29.0 h1:dqW4XRwPE/poWSqVntpeXLHzpPK6
github.com/aws/aws-sdk-go-v2/service/sts v1.29.0/go.mod h1:j8+hrxlmLR8ZQo6ytTAls/JFrt5bVisuS6PD8gw2VBw=
github.com/aws/smithy-go v1.20.2 h1:tbp628ireGtzcHDDmLT/6ADHidqnwgF57XOXZe6tp4Q=
github.com/aws/smithy-go v1.20.2/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/cloudbase/garm-provider-common v0.1.3 h1:8pHSRs2ljwLHgtDrge68dZ7ILUW97VF5h2ZA2fQubGQ=
github.com/cloudbase/garm-provider-common v0.1.3/go.mod h1:VIJzbcg5iwyD4ac99tnnwcActfwibn/VOt2MYOFjf2c=
github.com/cloudbase/garm-provider-common v0.1.4-0.20240904071738-0eb0ffc5da1e h1:B8txhtyErCMSGX/l3DxjJowtfjSknCzbf4XGPeb0vFo=
github.com/cloudbase/garm-provider-common v0.1.4-0.20240904071738-0eb0ffc5da1e/go.mod h1:/N8rXH2iXCsqCcOODsI2DTR9afnijMhNp/vjR9wbzSg=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -66,11 +66,13 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
Expand Down
18 changes: 2 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,15 @@ import (
"syscall"

"github.com/cloudbase/garm-provider-aws/provider"
"github.com/cloudbase/garm-provider-common/execution"
execution "github.com/cloudbase/garm-provider-common/execution/v0.1.0"
)

var signals = []os.Signal{
os.Interrupt,
syscall.SIGTERM,
}

var (
// Version is the version of the application
Version = "v0.0.0-unknown"
)

func main() {
// This is an unofficial command. It will be added into future versions of the
// external provider interface. For now we manually hardcode it here. This is not
// used by GARM itself. It is informative for the user to be able to check the version
// of the provider.
garmCommand := os.Getenv("GARM_COMMAND")
if garmCommand == "GetVersion" {
fmt.Println(Version)
os.Exit(0)
}

ctx, stop := signal.NotifyContext(context.Background(), signals...)
defer stop()
Expand All @@ -55,7 +41,7 @@ func main() {
os.Exit(1)
}

prov, err := provider.NewAwsProvider(ctx, executionEnv.ProviderConfigFile, executionEnv.ControllerID)
prov, err := provider.NewAwsProvider(ctx, executionEnv.ProviderConfigFile, executionEnv.ControllerID, executionEnv.InterfaceVersion)
if err != nil {
fmt.Fprintf(os.Stderr, "Error creating provider: %q", err)
os.Exit(1)
Expand Down
18 changes: 12 additions & 6 deletions provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ import (
"github.com/cloudbase/garm-provider-aws/internal/spec"
"github.com/cloudbase/garm-provider-aws/internal/util"
garmErrors "github.com/cloudbase/garm-provider-common/errors"
"github.com/cloudbase/garm-provider-common/execution"
execution "github.com/cloudbase/garm-provider-common/execution/v0.1.0"
"github.com/cloudbase/garm-provider-common/params"
)

var _ execution.ExternalProvider = &AwsProvider{}

func NewAwsProvider(ctx context.Context, configPath, controllerID string) (execution.ExternalProvider, error) {
func NewAwsProvider(ctx context.Context, configPath, controllerID string, interfaceVersion string) (execution.ExternalProvider, error) {
conf, err := config.NewConfig(configPath)
if err != nil {
return nil, fmt.Errorf("error loading config: %w", err)
Expand All @@ -44,14 +44,16 @@ func NewAwsProvider(ctx context.Context, configPath, controllerID string) (execu
}

return &AwsProvider{
controllerID: controllerID,
awsCli: awsCli,
controllerID: controllerID,
interfaceVersion: interfaceVersion,
awsCli: awsCli,
}, nil
}

type AwsProvider struct {
controllerID string
awsCli *client.AwsCli
controllerID string
interfaceVersion string
awsCli *client.AwsCli
}

func (a *AwsProvider) CreateInstance(ctx context.Context, bootstrapParams params.BootstrapInstance) (params.ProviderInstance, error) {
Expand Down Expand Up @@ -159,3 +161,7 @@ func (a *AwsProvider) Start(ctx context.Context, instance string) error {
}
return a.awsCli.StartInstance(ctx, instance)
}

func (a *AwsProvider) GetVersion(ctx context.Context) string {
return a.interfaceVersion
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d7fcc10

Please sign in to comment.