Skip to content

Version checker errors when consumed as library #465

@jorgemoralespou

Description

@jorgemoralespou

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue describes a defect or unexpected behaviorcarvel acceptedThis issue should be considered for future work and that the triage process has been completed

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions