From 74e995fce85d4925816c4c948870b3ba0a73a9b1 Mon Sep 17 00:00:00 2001 From: "devsy-app[bot]" <277138668+devsy-app[bot]@users.noreply.github.com> Date: Sat, 15 Aug 2026 13:03:42 +0000 Subject: [PATCH] fix: export SourceKind from pkg/provider ClassifyVersionSource is an exported function but returned the unexported sourceKind type (and its unexported constants), flagged by Codefactor (Maintainability: exported func returning unexported type). Export the type and constants as SourceKind/SourceUnknown/SourceGitHub/SourceManifestURL/SourceLocal so the API is usable by external callers. No behavior change; tests updated to the exported names. --- pkg/provider/versions.go | 26 +++++++++++++------------- pkg/provider/versions_test.go | 14 +++++++------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/pkg/provider/versions.go b/pkg/provider/versions.go index 4d7f9d412..8f4eb459b 100644 --- a/pkg/provider/versions.go +++ b/pkg/provider/versions.go @@ -17,17 +17,17 @@ type ProviderVersionCheckResult struct { Error string `json:"error,omitempty"` } -type sourceKind int +type SourceKind int const ( - sourceUnknown sourceKind = iota - sourceGitHub - sourceManifestURL - sourceLocal + SourceUnknown SourceKind = iota + SourceGitHub + SourceManifestURL + SourceLocal ) // ClassifyVersionSource categorises a canonical source string into its source kind. -func ClassifyVersionSource(canonical string) sourceKind { +func ClassifyVersionSource(canonical string) SourceKind { // Strip @version suffix if present; only the leftmost @ counts as a tag separator. bare := canonical if before, _, ok := strings.Cut(canonical, "@"); ok { @@ -35,30 +35,30 @@ func ClassifyVersionSource(canonical string) sourceKind { } switch { case strings.HasPrefix(bare, "github.com/"): - return sourceGitHub + return SourceGitHub case strings.HasPrefix(bare, "https://"), strings.HasPrefix(bare, "http://"): - return sourceManifestURL + return SourceManifestURL case strings.HasPrefix(bare, "/"), strings.HasPrefix(bare, "./"), strings.HasPrefix(bare, "../"): - return sourceLocal + return SourceLocal default: - return sourceUnknown + return SourceUnknown } } // ListVersionsForSource dispatches to the appropriate lister based on source shape. func ListVersionsForSource(source string, opts ListVersionsOptions) ([]ProviderVersion, error) { switch ClassifyVersionSource(source) { - case sourceGitHub: + case SourceGitHub: org, repo, ok := parseGitHubSourcePath(source) if !ok { return nil, fmt.Errorf("invalid github source: %s", source) } return ListGitHubReleases(GithubAPIBaseURL, org, repo, opts.IncludePrerelease) - case sourceManifestURL: + case SourceManifestURL: return ListManifestVersions(source, opts.IncludePrerelease) - case sourceLocal, sourceUnknown: + case SourceLocal, SourceUnknown: return nil, ErrVersionListUnsupported } return nil, ErrVersionListUnsupported diff --git a/pkg/provider/versions_test.go b/pkg/provider/versions_test.go index c65b9c750..b62568b59 100644 --- a/pkg/provider/versions_test.go +++ b/pkg/provider/versions_test.go @@ -26,14 +26,14 @@ func TestProviderVersionFields(t *testing.T) { func TestClassifyVersionSource(t *testing.T) { cases := []struct { in string - kind sourceKind + kind SourceKind }{ - {"github.com/devsy-org/devsy-provider-aws@v1.2.0", sourceGitHub}, - {"github.com/devsy-org/devsy-provider-aws", sourceGitHub}, - {"https://example.com/foo/provider.yaml", sourceManifestURL}, - {"https://example.com/foo/provider.yaml@v1.0.0", sourceManifestURL}, - {"/abs/path/provider.yaml", sourceLocal}, - {"./relative/provider.yaml", sourceLocal}, + {"github.com/devsy-org/devsy-provider-aws@v1.2.0", SourceGitHub}, + {"github.com/devsy-org/devsy-provider-aws", SourceGitHub}, + {"https://example.com/foo/provider.yaml", SourceManifestURL}, + {"https://example.com/foo/provider.yaml@v1.0.0", SourceManifestURL}, + {"/abs/path/provider.yaml", SourceLocal}, + {"./relative/provider.yaml", SourceLocal}, } for _, c := range cases { t.Run(c.in, func(t *testing.T) {