@@ -39,28 +39,27 @@ const versiongoTemplate = `// This is an autogenerated file and should not be ed
39
39
// permissions and limitations under the License.
40
40
41
41
// Package version contains constants to indicate the current version of the
42
- // {{.Package}} . It is autogenerated
42
+ // agent . It is autogenerated
43
43
package version
44
44
45
45
// Please DO NOT commit any changes to this file (specifically the hash) except
46
- // for those created by running 'go run scripts/version-gen.go' at the root of the
46
+ // for those created by running ./ scripts/update-version at the root of the
47
47
// repository. Only the 'Version' const should change in checked-in source code
48
48
49
- // Version is the version of {{.Package}}
49
+ // Version is the version of the Agent
50
50
const Version = "{{.Version}}"
51
51
52
- // GitDirty indicates the cleanliness of the git repo when this {{.Package}} was built
52
+ // GitDirty indicates the cleanliness of the git repo when this agent was built
53
53
const GitDirty = {{.Dirty}}
54
54
55
- // GitShortHash is the short hash of this {{.Package}} build
55
+ // GitShortHash is the short hash of this agent build
56
56
const GitShortHash = "{{.Hash}}"
57
57
`
58
58
59
59
type versionInfo struct {
60
60
Version string
61
61
Dirty bool
62
62
Hash string
63
- Package string
64
63
}
65
64
66
65
func gitDirty () bool {
@@ -83,7 +82,7 @@ func gitHash() string {
83
82
}
84
83
85
84
func releaseCommitGitHash () (string , error ) {
86
- fullHash , err := os .ReadFile (filepath .Join (".." , "RELEASE_COMMIT" ))
85
+ fullHash , err := os .ReadFile (filepath .Join (".." , ".." , " RELEASE_COMMIT" ))
87
86
if err != nil {
88
87
return "" , fmt .Errorf ("unable to read RELEASE_COMMIT file, err: %v" , err )
89
88
}
@@ -105,10 +104,12 @@ func selectGitHash() string {
105
104
return hash
106
105
}
107
106
108
- // version-gen is a simple program that generates version files in the agent and ecs-init go modules.
109
- // It contains information about the agent's version, commit hash, and repository cleanliness.
107
+ // version-gen is a simple program that generates the agent's version file,
108
+ // containing information about the agent's version, commit hash, and repository
109
+ // cleanliness.
110
110
func main () {
111
- versionStr , _ := os .ReadFile ("VERSION" )
111
+
112
+ versionStr , _ := os .ReadFile (filepath .Join (".." , ".." , "VERSION" ))
112
113
113
114
// default values
114
115
info := versionInfo {
@@ -130,18 +131,14 @@ func main() {
130
131
info .Hash = selectGitHash ()
131
132
}
132
133
133
- for _ , dir := range []string {"agent" , "ecs-init" } {
134
- info .Package = dir
135
-
136
- outFile , err := os .Create (filepath .Join (dir , "version" , "version.go" ))
137
- if err != nil {
138
- log .Fatalf ("Unable to create output version file: %v" , err )
139
- }
140
- t := template .Must (template .New ("version" ).Parse (versiongoTemplate ))
134
+ outFile , err := os .Create ("version.go" )
135
+ if err != nil {
136
+ log .Fatalf ("Unable to create output version file: %v" , err )
137
+ }
138
+ t := template .Must (template .New ("version" ).Parse (versiongoTemplate ))
141
139
142
- err = t .Execute (outFile , info )
143
- if err != nil {
144
- log .Fatalf ("Error applying template: %v" , err )
145
- }
140
+ err = t .Execute (outFile , info )
141
+ if err != nil {
142
+ log .Fatalf ("Error applying template: %v" , err )
146
143
}
147
144
}
0 commit comments