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

Version checker errors when consumed as library #465

Closed
jorgemoralespou opened this issue Mar 8, 2024 · 0 comments · Fixed by #466
Closed

Version checker errors when consumed as library #465

jorgemoralespou opened this issue Mar 8, 2024 · 0 comments · Fixed by #466
Labels
bug This issue describes a defect or unexpected behavior carvel accepted This issue should be considered for future work and that the triage process has been completed

Comments

@jorgemoralespou
Copy link

What steps did you take:
I have used kbld as a library and kbld is detected as develop so if you have a minimumVersionRequired specified in kbld config.

What happened:
it failed with:

Validating config/ (kbld.k14s.io/v1alpha1) cluster: Parsing version constraint: Malformed version: develop

What did you expect:
To work fine.

Anything else you would like to add:
Chatting with @joaopapereira we made a change in vendored file vendor/carvel.dev/kbld/pkg/kbld/version.go with this code and worked as expected:

package version

import (
	"runtime/debug"
)

var (
	// Version can be set via:
	// -ldflags="-X 'carvel.dev/kbld/pkg/kbld/version.Version=$TAG'"
	Version    = "develop"
	moduleName = "carvel.dev/kbld"
)

func init() {
	Version = version()
}

func version() string {
	if Version != "develop" {
		// Version was set via ldflags, just return it.
		return Version
	}

	info, ok := debug.ReadBuildInfo()
	if !ok {
		return "develop"
	}

	// Anything else.
	for _, dep := range info.Deps {
		if dep.Path == moduleName {
			return dep.Version
		}
	}

	return "develop"
}

Environment:

  • kbld version (use kbld --version): 0.41.0

Vote on this request

This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.

👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"

We are also happy to receive and review Pull Requests if you want to help working on this issue.

@jorgemoralespou jorgemoralespou added bug This issue describes a defect or unexpected behavior carvel triage This issue has not yet been reviewed for validity labels Mar 8, 2024
@carvel-bot carvel-bot added this to Carvel Mar 8, 2024
@joaopapereira joaopapereira added carvel accepted This issue should be considered for future work and that the triage process has been completed and removed carvel triage This issue has not yet been reviewed for validity labels Mar 8, 2024
@github-project-automation github-project-automation bot moved this to Closed in Carvel Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue describes a defect or unexpected behavior carvel accepted This issue should be considered for future work and that the triage process has been completed
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants