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

fix: panic when getting envoy version #687

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion internal/cmd/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ func getVersionsCommand() *cobra.Command {

// versions shows the versions of the Envoy Gateway.
func versions(envOutput bool) error {
envoyVersion := strings.Split(ir.DefaultProxyImage, ":")[1]
parts := strings.Split(ir.DefaultProxyImage, ":")
Copy link
Contributor

Choose a reason for hiding this comment

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

curious when will we get here ? isn't DefaultProxyImage always a sane constant ?

Copy link
Member

Choose a reason for hiding this comment

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

I can understand the PR tries to check the slice lower bounds of the default proxy image. But honestly saying, this does not make more sence, because the default image is always naming with a : to sparate the image tag.

If we support custom proxy image, which is not a const but a string parsing from configs, this kind of checks will make more meaningful. But as for the default image, this is no needed for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's right. I agree with you completely.

if len(parts) < 2 {
return fmt.Errorf("could not decode string into envoy version: %v", ir.DefaultProxyImage)
}
envoyVersion := parts[1]

if envOutput {
fmt.Printf("ENVOY_VERSION=\"%s\"\n", envoyVersion)
Expand Down