-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add theia-sf (Theia Snowflake) CLI to release assets #144
Merged
antoninbas
merged 1 commit into
antrea-io:main
from
antoninbas:add-theia-sf-cli-to-release-assets
Jan 28, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
creds | ||
*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2022 Antrea Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License 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 cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"antrea.io/theia/snowflake/pkg/version" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// versionCmd represents the version command | ||
var versionCmd = &cobra.Command{ | ||
Use: "version", | ||
Short: "Show CLI version", | ||
Long: `Show CLI version, which is the Theia version for which this CLI | ||
was built.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Println(version.GetFullVersionWithRuntimeInfo()) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(versionCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2022 Antrea Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License 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 | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
|
||
"github.com/blang/semver" | ||
) | ||
|
||
// These variables are set at build-time. | ||
var ( | ||
// Must follow the rules in https://semver.org/ | ||
// Does not include git / build information | ||
Version = "" | ||
// Empty if git not available | ||
GitSHA = "" | ||
// Can be "dirty", "clean" or empty (if git not available) | ||
GitTreeState = "" | ||
// Can be "unreleased" or "released"; if it is "unreleased" then we add build information to | ||
// the version in GetFullVersion | ||
ReleaseStatus = "unreleased" | ||
) | ||
|
||
func GetVersion() semver.Version { | ||
v, _ := semver.Parse(Version[1:]) | ||
return v | ||
} | ||
|
||
func GetGitSHA() string { | ||
return GitSHA | ||
} | ||
|
||
// GetFullVersion returns the version string to be displayed by executables. It will look like | ||
// "<major>.<minor>.<patch>" for released versions and "<major>.<minor>.<patch>-<SHA>[.dirty]" for | ||
// unreleased versions. | ||
func GetFullVersion() string { | ||
if Version == "" { | ||
return "UNKNOWN" | ||
} | ||
if ReleaseStatus == "released" { | ||
return Version | ||
} | ||
// add build information | ||
if GitSHA == "" { | ||
return fmt.Sprintf("%s-unknown", Version) | ||
} | ||
if GitTreeState == "dirty" { | ||
return fmt.Sprintf("%s-%s.dirty", Version, GitSHA) | ||
} | ||
return fmt.Sprintf("%s-%s", Version, GitSHA) | ||
} | ||
|
||
// GetFullVersionWithRuntimeInfo returns the same version string as GetFullVersion but appends | ||
// "<GOOS>/<GOARCH> <GOVERSION>", where GOOS is the running program's operating system target | ||
// (e.g. darwin, linux), GOARCH is the the running program's architecture target (e.g. amd64), and | ||
// GOVERSION is the Go version used to build the current binary. | ||
func GetFullVersionWithRuntimeInfo() string { | ||
return fmt.Sprintf("%s %s/%s %s", GetFullVersion(), runtime.GOOS, runtime.GOARCH, runtime.Version()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we put this pkg under
pkg/
instead ofsnowflake/pkg
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? is it needed for other Theia code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, given that
theia
andtheia/snowflake
are different Go modules, this is not straightforward and may not be a good idea.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was inspired by the version command you just added, our theia CLI doesn't have a version command so it might be useful to have one as well.
However, as you pointed out, it may not be advisable to do so across Go modules. Please disregard this comment. Thanks!