Skip to content

Version command doesn't show client version #86

@jcogilvie

Description

@jcogilvie

What happened?

The crossplane-diff version command was not reporting the correct version for the crossplane-diff binary.
Instead, it was attempting to report the version from the upstream github.com/crossplane/crossplane
dependency, which resulted in either an empty version string or the wrong version being displayed.

Root cause:

  • crossplane-diff was importing the version command directly from
    github.com/crossplane/crossplane/v2/cmd/crank/version
  • The Earthfile was attempting to inject version information into
    github.com/crossplane/crossplane/internal/version.version using ldflags
  • This approach doesn't work because you cannot inject ldflags into vendored/downloaded dependencies
  • The variable name CROSSPLANE_VERSION was overloaded - used both for the upstream Crossplane image tag (e.g.,
    release-1.20) and the crossplane-diff binary version, causing confusion

Expected behavior:
When running crossplane-diff version --client, it should display the actual version of the crossplane-diff
binary (e.g., v0.4.0 or v0.0.0-{timestamp}-{git-hash} for dev builds).

Actual behavior:
The version command displayed an empty string or incorrect version information.

How can we reproduce it?

Before the fix:

  1. Clone the crossplane-diff repository at a commit before the fix
  2. Build the binary: go build -o crossplane-diff ./cmd/diff
  3. Run: ./crossplane-diff version --client
  4. Observe that the version is empty or incorrect

Or using Earthly:

  1. Build with Earthly: earthly +build
  2. Run: ./_output/bin/darwin_arm64/crossplane-diff version --client (adjust path for your platform)
  3. Observe the version output is empty or incorrect

What environment did it happen in?

Crossplane version: n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions