Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read git hash from RELEASE_COMMIT file if possible #3508

Merged
merged 1 commit into from
Dec 7, 2022

Conversation

danehlim
Copy link
Contributor

@danehlim danehlim commented Dec 7, 2022

Summary

Read git hash from RELEASE_COMMIT file if possible

Implementation details

  • Prior to executing gitHash() function in version-gen.go, try to read hash from RELEASE_COMMIT file instead using new releaseCommitGitHash() function
  • Log relevant information in gitHash() and releaseCommitGitHash() functions in version-gen.go
  • Add RELEASE_COMMIT file to amazon-linux-sources.tgz in Makefile
  • Use os.ReadFile instead of ioutil.ReadFile in version-gen.go since ioutil package is deprecated as of Go 1.16

Testing

In the repo root, create a test RELEASE_COMMIT file, run version-gen.go, and verify that the correct hash is obtained.

$ echo "1a2b3c4d5e6f78901a2b3c4d5e6f78901a2b" > RELEASE_COMMIT
$ cd agent/version 
$ GO111MODULE=off go run gen/version-gen.go
2022/12/07 10:31:04 Successfully retrieved full hash value from RELEASE_COMMIT file, fullHashStr: 1a2b3c4d5e6f78901a2b3c4d5e6f78901a2b
$ cat version.go
// This is an autogenerated file and should not be edited.

// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
// License is located at
//
//      http://aws.amazon.com/apache2.0/
//
// or in the "license" file accompanying this file. This file is distributed
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.

// Package version contains constants to indicate the current version of the
// agent. It is autogenerated
package version

// Please DO NOT commit any changes to this file (specifically the hash) except
// for those created by running ./scripts/update-version at the root of the
// repository. Only the 'Version' const should change in checked-in source code

// Version is the version of the Agent
const Version = "1.67.0"

// GitDirty indicates the cleanliness of the git repo when this agent was built
const GitDirty = true

// GitShortHash is the short hash of this agent build
const GitShortHash = "1a2b3c4d"

New tests cover the changes: no

Description for the changelog

Read git hash from RELEASE_COMMIT file if possible

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@danehlim danehlim changed the title [WIP] Read git hash from RELEASE_COMMIT file if possible Read git hash from RELEASE_COMMIT file if possible Dec 7, 2022
@danehlim danehlim marked this pull request as ready for review December 7, 2022 17:21
@danehlim danehlim requested a review from a team as a code owner December 7, 2022 17:21
@sparrc
Copy link
Contributor

sparrc commented Dec 7, 2022

When and how is the RELEASE_COMMIT file generated?

Copy link
Contributor

@YashdalfTheGray YashdalfTheGray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@danehlim danehlim merged commit 9fc6bdb into aws:dev Dec 7, 2022
@danehlim danehlim mentioned this pull request Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants