Skip to content

Commit 4d4edb1

Browse files
committed
Add License file to the executable
1 parent b88570a commit 4d4edb1

7 files changed

Lines changed: 1057 additions & 2 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ $(LOCAL_BINARY): $(SOURCES)
3030

3131
.PHONY: test
3232
test:
33-
. ./scripts/shared_env && env -i PATH=$$PATH GOPATH=$$GOPATH GOROOT=$$GOROOT go test -timeout=120s -v -cover ./ecs-cli/modules/...
33+
. ./scripts/shared_env && env -i PATH=$$PATH GOPATH=$$GOPATH GOROOT=$$GOROOT go test -timeout=120s -v -cover ./ecs-cli/license/... ./ecs-cli/modules/...
3434

3535
.PHONY: generate
3636
generate: $(SOURCES)
37-
. ./scripts/shared_env && go generate ./ecs-cli/modules/...
37+
. ./scripts/shared_env && go generate ./ecs-cli/license/... ./ecs-cli/modules/...
3838

3939
.PHONY: generate-deps
4040
generate-deps:
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"). You may
4+
// not use this file except in compliance with the License. A copy of the
5+
// License is located at
6+
//
7+
// http://aws.amazon.com/apache2.0/
8+
//
9+
// or in the "license" file accompanying this file. This file is distributed
10+
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
// express or implied. See the License for the specific language governing
12+
// permissions and limitations under the License.
13+
14+
package license
15+
16+
//go:generate license.sh license.go

ecs-cli/license/license.go

Lines changed: 927 additions & 0 deletions
Large diffs are not rendered by default.

ecs-cli/license/license_command.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"). You may
4+
// not use this file except in compliance with the License. A copy of the
5+
// License is located at
6+
//
7+
// http://aws.amazon.com/apache2.0/
8+
//
9+
// or in the "license" file accompanying this file. This file is distributed
10+
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
// express or implied. See the License for the specific language governing
12+
// permissions and limitations under the License.
13+
14+
package license
15+
16+
import (
17+
"os"
18+
19+
"github.com/codegangsta/cli"
20+
)
21+
22+
func LicenseCommand() cli.Command {
23+
return cli.Command{
24+
Name: "license",
25+
Usage: "Print the LICENSE files",
26+
Action: printLicense,
27+
}
28+
}
29+
30+
func printLicense(c *cli.Context) {
31+
os.Stdout.WriteString(License)
32+
}

ecs-cli/license/license_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"). You may
4+
// not use this file except in compliance with the License. A copy of the
5+
// License is located at
6+
//
7+
// http://aws.amazon.com/apache2.0/
8+
//
9+
// or in the "license" file accompanying this file. This file is distributed
10+
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
// express or implied. See the License for the specific language governing
12+
// permissions and limitations under the License.
13+
14+
package license
15+
16+
import (
17+
"io/ioutil"
18+
"testing"
19+
)
20+
21+
func TestVendorDirectoryStructure(t *testing.T) {
22+
directories, _ := ioutil.ReadDir("./../vendor/src")
23+
if len(directories) != 1 {
24+
t.Errorf("Should have exactly 1 directory under vendor/src. Found [%s] directories", len(directories))
25+
}
26+
dir := directories[0]
27+
if !dir.IsDir() {
28+
t.Error("Expected only contents of vendor/src to be a directory")
29+
}
30+
if "github.com" != dir.Name() {
31+
t.Errorf("directory name : Expected=github.com, Found=[%s]", dir.Name())
32+
}
33+
}

ecs-cli/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package main
1616
import (
1717
"os"
1818

19+
"github.com/aws/amazon-ecs-cli/ecs-cli/license"
1920
"github.com/aws/amazon-ecs-cli/ecs-cli/modules/command"
2021
ecscompose "github.com/aws/amazon-ecs-cli/ecs-cli/modules/compose/cli/ecs/app"
2122
"github.com/aws/amazon-ecs-cli/ecs-cli/modules/version"
@@ -38,6 +39,7 @@ func main() {
3839
command.DownCommand(),
3940
command.ScaleCommand(),
4041
command.PsCommand(),
42+
license.LicenseCommand(),
4143
ecscompose.ComposeCommand(composeFactory),
4244
}
4345
app.Run(os.Args)

scripts/license.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License"). You may
5+
# not use this file except in compliance with the License. A copy of the
6+
# License is located at
7+
#
8+
# http://aws.amazon.com/apache2.0/
9+
#
10+
# or in the "license" file accompanying this file. This file is distributed
11+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
# express or implied. See the License for the specific language governing
13+
# permissions and limitations under the License.
14+
#
15+
# This script generates a file in go with the license contents as a constant
16+
17+
set -e
18+
outputfile=${1?Must provide an output file}
19+
inputfile="$(<../../LICENSE)"
20+
21+
for user in ./../vendor/src/github.com/*; do
22+
for repo in $user/*; do
23+
inputfile+=$'\n'"***"$'\n'"$repo"$'\n\n'
24+
inputfile+="$(<$repo/LICENSE*)"$'\n'
25+
done;
26+
done;
27+
28+
cat << EOF > "${outputfile}"
29+
// Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
30+
//
31+
// Licensed under the Apache License, Version 2.0 (the "License"). You may
32+
// not use this file except in compliance with the License. A copy of the
33+
// License is located at
34+
//
35+
// http://aws.amazon.com/apache2.0/
36+
//
37+
// or in the "license" file accompanying this file. This file is distributed
38+
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
39+
// express or implied. See the License for the specific language governing
40+
// permissions and limitations under the License.
41+
42+
package license
43+
44+
const License = \`$inputfile\`
45+
EOF

0 commit comments

Comments
 (0)