mirror of
https://github.com/docker/compose.git
synced 2025-07-27 15:44:08 +02:00
Customize SDK requests to AWS API with user-agent
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
2917251f5f
commit
324443deb6
@ -8,8 +8,8 @@ endif
|
|||||||
|
|
||||||
STATIC_FLAGS=CGO_ENABLED=0
|
STATIC_FLAGS=CGO_ENABLED=0
|
||||||
LDFLAGS := "-s -w \
|
LDFLAGS := "-s -w \
|
||||||
-X github.com/docker/ecs-plugin/cmd/commands.GitCommit=$(COMMIT) \
|
-X github.com/docker/ecs-plugin/internal.GitCommit=$(COMMIT) \
|
||||||
-X github.com/docker/ecs-plugin/cmd/commands.Version=$(TAG)"
|
-X github.com/docker/ecs-plugin/internal.Version=$(TAG)"
|
||||||
GO_BUILD=$(STATIC_FLAGS) go build -trimpath -ldflags=$(LDFLAGS)
|
GO_BUILD=$(STATIC_FLAGS) go build -trimpath -ldflags=$(LDFLAGS)
|
||||||
|
|
||||||
BINARY=dist/docker-ecs
|
BINARY=dist/docker-ecs
|
||||||
|
@ -3,14 +3,9 @@ package commands
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/docker/ecs-plugin/internal"
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
"github.com/spf13/cobra"
|
||||||
// Version is the git tag that this was built from.
|
|
||||||
Version = "unknown"
|
|
||||||
// GitCommit is the commit that this was built from.
|
|
||||||
GitCommit = "unknown"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func VersionCommand() *cobra.Command {
|
func VersionCommand() *cobra.Command {
|
||||||
@ -18,7 +13,7 @@ func VersionCommand() *cobra.Command {
|
|||||||
Use: "version",
|
Use: "version",
|
||||||
Short: "Show version.",
|
Short: "Show version.",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
fmt.Fprintf(cmd.OutOrStdout(), "Docker ECS plugin %s (%s)\n", Version, GitCommit)
|
fmt.Fprintf(cmd.OutOrStdout(), "Docker ECS plugin %s (%s)\n", internal.Version, internal.GitCommit)
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/docker/ecs-plugin/internal"
|
||||||
|
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,5 +16,5 @@ func TestVersion(t *testing.T) {
|
|||||||
root.SetOut(&out)
|
root.SetOut(&out)
|
||||||
root.SetArgs([]string{"version"})
|
root.SetArgs([]string{"version"})
|
||||||
root.Execute()
|
root.Execute()
|
||||||
assert.Check(t, strings.Contains(out.String(), Version))
|
assert.Check(t, strings.Contains(out.String(), internal.Version))
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/docker/ecs-plugin/cmd/commands"
|
"github.com/docker/ecs-plugin/cmd/commands"
|
||||||
|
"github.com/docker/ecs-plugin/internal"
|
||||||
|
|
||||||
"github.com/docker/cli/cli-plugins/manager"
|
"github.com/docker/cli/cli-plugins/manager"
|
||||||
"github.com/docker/cli/cli-plugins/plugin"
|
"github.com/docker/cli/cli-plugins/plugin"
|
||||||
@ -16,7 +17,7 @@ func main() {
|
|||||||
}, manager.Metadata{
|
}, manager.Metadata{
|
||||||
SchemaVersion: "0.1.0",
|
SchemaVersion: "0.1.0",
|
||||||
Vendor: "Docker Inc.",
|
Vendor: "Docker Inc.",
|
||||||
Version: commands.Version,
|
Version: internal.Version,
|
||||||
Experimental: true,
|
Experimental: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
8
ecs/internal/version.go
Normal file
8
ecs/internal/version.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package internal
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Version is the git tag that this was built from.
|
||||||
|
Version = "unknown"
|
||||||
|
// GitCommit is the commit that this was built from.
|
||||||
|
GitCommit = "unknown"
|
||||||
|
)
|
@ -6,6 +6,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/docker/ecs-plugin/internal"
|
||||||
|
|
||||||
|
"github.com/aws/aws-sdk-go/aws/request"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
"github.com/aws/aws-sdk-go/aws/session"
|
"github.com/aws/aws-sdk-go/aws/session"
|
||||||
"github.com/aws/aws-sdk-go/service/cloudformation"
|
"github.com/aws/aws-sdk-go/service/cloudformation"
|
||||||
@ -39,6 +43,9 @@ type sdk struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewAPI(sess *session.Session) API {
|
func NewAPI(sess *session.Session) API {
|
||||||
|
sess.Handlers.Build.PushBack(func(r *request.Request) {
|
||||||
|
request.AddToUserAgent(r, fmt.Sprintf("Docker CLI %s", internal.Version))
|
||||||
|
})
|
||||||
return sdk{
|
return sdk{
|
||||||
ECS: ecs.New(sess),
|
ECS: ecs.New(sess),
|
||||||
EC2: ec2.New(sess),
|
EC2: ec2.New(sess),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user