Skip to content

Consolidate application-name and version utilities into a single source of truth #120

Backlog

Description

@tommartensen

Summary

The knowledge of the Konflux application naming convention (acs-<major>-<minor>) and of version parsing is encoded in several places. Today (while reviewing get-merge-window/list-merge-windows, PR #70) we added yet another encoding, which prompted this issue: the convention should have a single home.

Current state

The same concepts exist as parallel types and parsers:

Concept Location Notes
Application (name helpers) pkg/utils/application.go WithVersion(tag) builds acs-4-8 from a tag; GetVersion() parses an application name back into a version; GetResourceWithVersion, GetPipelineRunURL
Version (major/minor/patch) pkg/utils/version.go NewVersion parses semver strings; convertToVersion; RenderTags
ProductStream (major/minor) pkg/client/konflux/models.go NewProductStream parses "4.6" strings
Application-name pattern pkg/client/konflux/applications.go applicationNamePattern (^acs-(\d+)-(\d+)$) filters/parses application names into product streams
Application prefix pkg/config/config.go KonfluxApplicationPrefix = "acs"

Concretely, the name → version direction alone is implemented twice with slightly different semantics:

  • utils.Application.GetVersion() — splits on -, accepts any 3-part name (collector-4-6 parses fine), returns utils.Version with Patch: 0
  • konflux/applications.go — regex anchored to the acs prefix, returns konflux.ProductStream

And the version → name direction (WithVersion) lives only in utils, while ProductStream has no way to render its application name (the merge-window code builds release-<major>.<minor> branch names instead, in pkg/github/github.go).

Problem

  • The convention can drift: a change to how application names are built or parsed must be replicated in pkg/utils and pkg/client/konflux.
  • Two overlapping version types (utils.Version vs konflux.ProductStream) force conversions and make it unclear which to use in new code.
  • Prefix knowledge (acs) is sometimes hardcoded in logic and sometimes read from config.KonfluxApplicationPrefix.

Proposal

Consolidate the naming convention and version types into one place, e.g. on the konflux package's domain types (import direction already works: pkg/client/konflux imports pkg/utils today, and pkg/utils does not import pkg/client/konflux):

  • conversion methods between ProductStream, utils.Version, and application names (e.g. ProductStream.ApplicationName(), NewProductStreamFromVersion, ProductStreamFromApplicationName)
  • one anchored application-name pattern used by both enumeration (GetActiveProductStreams) and parsing
  • utils.Application/utils.Version either delegate to the consolidated implementation or are absorbed into it, with callers updated (pkg/konflux, pkg/client/konflux, cmd/relacs/konflux)

Acceptance criteria

  • A single implementation knows how to build/parse acs-<major>-<minor> application names
  • A single version-ish type hierarchy (or explicit conversion) instead of parallel utils.Version / konflux.ProductStream parsers
  • The acs prefix comes from config.KonfluxApplicationPrefix everywhere
  • Existing behavior of tag-driven commands (get-custom-snapshot, releases, conforma, etc.) is unchanged, covered by the existing tests in pkg/utils and tests/

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions