Skip to content

Commit 79c0e50

Browse files
committed
app,version: removing docker version from -version api
1 parent 1ca656c commit 79c0e50

File tree

6 files changed

+14
-26
lines changed

6 files changed

+14
-26
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#Changelog
22

3+
## Unreleased
4+
* Bug - Fixed a bug where -version fails due to its dependency on docker client. [#1118](https://github.com/aws/amazon-ecs-agent/pull/1118)
5+
36
## 1.16.0
47
* Feature - Support pulling from Amazon ECR with specified IAM role in task definition
58
* Feature - Enable support for task level CPU and memory constraints.

agent/app/agent.go

-9
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import (
4444
"github.com/aws/amazon-ecs-agent/agent/statemanager"
4545
"github.com/aws/amazon-ecs-agent/agent/tcs/handler"
4646
"github.com/aws/amazon-ecs-agent/agent/utils"
47-
"github.com/aws/amazon-ecs-agent/agent/version"
4847
"github.com/aws/aws-sdk-go/aws"
4948
"github.com/aws/aws-sdk-go/aws/awserr"
5049
aws_credentials "github.com/aws/aws-sdk-go/aws/credentials"
@@ -71,8 +70,6 @@ var (
7170
// object. Its purpose is to mostly demonstrate how to interact with the
7271
// ecsAgent type.
7372
type agent interface {
74-
// printVersion prints the Agent version string
75-
printVersion() int
7673
// printECSAttributes prints the Agent's capabilities based on
7774
// its environment
7875
printECSAttributes() int
@@ -170,12 +167,6 @@ func newAgent(
170167
}, nil
171168
}
172169

173-
// printVersion prints the ECS Agent version string
174-
func (agent *ecsAgent) printVersion() int {
175-
version.PrintVersion(agent.dockerClient)
176-
return exitcodes.ExitSuccess
177-
}
178-
179170
// printECSAttributes prints the Agent's ECS Attributes based on its
180171
// environment
181172
func (agent *ecsAgent) printECSAttributes() int {

agent/app/agent_integ_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestNewAgent(t *testing.T) {
3232
agent, err := newAgent(ctx, true, aws.Bool(true))
3333

3434
assert.NoError(t, err)
35-
// printVersion should ensure that agent's cfg is set with
35+
// printECSAttributes should ensure that agent's cfg is set with
3636
// valid values and not panic
37-
assert.Equal(t, exitcodes.ExitSuccess, agent.printVersion())
37+
assert.Equal(t, exitcodes.ExitSuccess, agent.printECSAttributes())
3838
}

agent/app/agent_windows_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func (m *mockAgent) start() int {
4040
func (m *mockAgent) setTerminationHandler(handler sighandlers.TerminationHandler) {
4141
m.terminationHandler = handler
4242
}
43-
func (m *mockAgent) printVersion() int { return 0 }
4443
func (m *mockAgent) printECSAttributes() int { return 0 }
4544
func (m *mockAgent) startWindowsService() int { return 0 }
4645

agent/app/run.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/aws/amazon-ecs-agent/agent/app/args"
2020
"github.com/aws/amazon-ecs-agent/agent/logger"
2121
"github.com/aws/amazon-ecs-agent/agent/sighandlers/exitcodes"
22+
"github.com/aws/amazon-ecs-agent/agent/version"
2223
"github.com/aws/aws-sdk-go/aws"
2324
log "github.com/cihub/seelog"
2425
)
@@ -35,6 +36,8 @@ func Run(arguments []string) int {
3536

3637
if *parsedArgs.License {
3738
return printLicense()
39+
} else if *parsedArgs.Version {
40+
return version.PrintVersion()
3841
}
3942

4043
logger.SetLevel(*parsedArgs.LogLevel)
@@ -50,9 +53,6 @@ func Run(arguments []string) int {
5053
}
5154

5255
switch {
53-
case *parsedArgs.Version:
54-
// Print Agent's version and exit
55-
return agent.printVersion()
5656
case *parsedArgs.ECSAttributes:
5757
// Print agent's ecs attributes based on its environment and exit
5858
return agent.printECSAttributes()

agent/version/formatting.go

+6-11
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
package version
1515

16-
import "fmt"
16+
import (
17+
"fmt"
1718

18-
type Versioner interface {
19-
Version() (string, error)
20-
}
19+
"github.com/aws/amazon-ecs-agent/agent/sighandlers/exitcodes"
20+
)
2121

2222
// PrintVersions prints the version information on stdout as a multi-line
2323
// string. The output will look similar to the following:
@@ -26,7 +26,7 @@ type Versioner interface {
2626
// Version: 0.0.3
2727
// Commit: 4bdc7fc
2828
// DockerVersion: 1.5.0
29-
func PrintVersion(extra ...Versioner) {
29+
func PrintVersion() int {
3030
cleanliness := ""
3131
if GitDirty {
3232
cleanliness = "\tDirty: true\n"
@@ -37,12 +37,7 @@ func PrintVersion(extra ...Versioner) {
3737
Commit: %v
3838
%v`, Version, GitShortHash, cleanliness)
3939

40-
for _, versioner := range extra {
41-
if str, err := versioner.Version(); err == nil {
42-
fmt.Printf("\t%v\n", str)
43-
}
44-
}
45-
40+
return exitcodes.ExitSuccess
4641
}
4742

4843
// String produces a human-readable string showing the agent version.

0 commit comments

Comments
 (0)