diff --git a/sourceaddrs/source_registry.go b/sourceaddrs/source_registry.go index 976d371..20509fc 100644 --- a/sourceaddrs/source_registry.go +++ b/sourceaddrs/source_registry.go @@ -29,12 +29,6 @@ type RegistrySource struct { subPath string } -type RegistryVersionDeprecation struct { - Version string - Reason string - Link string -} - // sourceSigil implements Source func (s RegistrySource) sourceSigil() {} diff --git a/sourcebundle/builder.go b/sourcebundle/builder.go index 1fce624..e2c421d 100644 --- a/sourcebundle/builder.go +++ b/sourcebundle/builder.go @@ -73,7 +73,7 @@ type Builder struct { // selected version of each module registry package. resolvedRegistry map[registryPackageVersion]sourceaddrs.RemoteSource - resolvedRegistryVersionDeprecations map[registryPackageVersion]*sourceaddrs.RegistryVersionDeprecation + resolvedRegistryVersionDeprecations map[registryPackageVersion]*RegistryVersionDeprecation // registryPackageVersions caches responses from module registry calls to // look up the available versions for a particular module package. Although @@ -109,7 +109,7 @@ func NewBuilder(targetDir string, fetcher PackageFetcher, registryClient Registr remotePackageDirs: make(map[sourceaddrs.RemotePackage]string), remotePackageMeta: make(map[sourceaddrs.RemotePackage]*PackageMeta), resolvedRegistry: make(map[registryPackageVersion]sourceaddrs.RemoteSource), - resolvedRegistryVersionDeprecations: make(map[registryPackageVersion]*sourceaddrs.RegistryVersionDeprecation), + resolvedRegistryVersionDeprecations: make(map[registryPackageVersion]*RegistryVersionDeprecation), registryPackageVersions: make(map[regaddr.ModulePackage][]ModulePackageInfo), }, nil } @@ -407,11 +407,11 @@ func (b *Builder) findRegistryPackageSource(ctx context.Context, sourceAddr sour realSourceAddr = resp.SourceAddr b.resolvedRegistry[pkgVer] = realSourceAddr - var deprecation *sourceaddrs.RegistryVersionDeprecation + var deprecation *RegistryVersionDeprecation versionDeprecations := extractVersionDeprecationsFromResponse(availablePackageInfos) versionDeprecation := versionDeprecations[selectedVersion] if versionDeprecation != nil { - deprecation = &sourceaddrs.RegistryVersionDeprecation{ + deprecation = &RegistryVersionDeprecation{ Version: selectedVersion.String(), Reason: versionDeprecation.Reason, Link: versionDeprecation.Link, diff --git a/sourcebundle/builder_test.go b/sourcebundle/builder_test.go index e812f9c..5149a9b 100644 --- a/sourcebundle/builder_test.go +++ b/sourcebundle/builder_test.go @@ -318,9 +318,9 @@ func TestBuilderRegistryVersionDeprecation(t *testing.T) { version, _ := versions.ParseVersion("1.0.0") pkgAddr, _ := sourceaddrs.ParseRegistryPackage("example.com/foo/bar/baz") - wantDeprecations := map[regaddr.ModulePackage]map[versions.Version]*sourceaddrs.RegistryVersionDeprecation{ + wantDeprecations := map[regaddr.ModulePackage]map[versions.Version]*RegistryVersionDeprecation{ pkgAddr: { - version: &sourceaddrs.RegistryVersionDeprecation{ + version: &RegistryVersionDeprecation{ Version: "1.0.0", Reason: "test reason", Link: "test link", diff --git a/sourcebundle/bundle.go b/sourcebundle/bundle.go index 8324088..8ff08fd 100644 --- a/sourcebundle/bundle.go +++ b/sourcebundle/bundle.go @@ -33,7 +33,7 @@ type Bundle struct { remotePackageMeta map[sourceaddrs.RemotePackage]*PackageMeta registryPackageSources map[regaddr.ModulePackage]map[versions.Version]sourceaddrs.RemoteSource - registryPackageVersionDeprecations map[regaddr.ModulePackage]map[versions.Version]*sourceaddrs.RegistryVersionDeprecation + registryPackageVersionDeprecations map[regaddr.ModulePackage]map[versions.Version]*RegistryVersionDeprecation } // OpenDir opens a bundle rooted at the given base directory. @@ -56,7 +56,7 @@ func OpenDir(baseDir string) (*Bundle, error) { remotePackageDirs: make(map[sourceaddrs.RemotePackage]string), remotePackageMeta: make(map[sourceaddrs.RemotePackage]*PackageMeta), registryPackageSources: make(map[regaddr.ModulePackage]map[versions.Version]sourceaddrs.RemoteSource), - registryPackageVersionDeprecations: make(map[regaddr.ModulePackage]map[versions.Version]*sourceaddrs.RegistryVersionDeprecation), + registryPackageVersionDeprecations: make(map[regaddr.ModulePackage]map[versions.Version]*RegistryVersionDeprecation), } manifestSrc, err := os.ReadFile(filepath.Join(rootDir, manifestFilename)) @@ -112,7 +112,7 @@ func OpenDir(baseDir string) (*Bundle, error) { } deprecations := ret.registryPackageVersionDeprecations[pkgAddr] if deprecations == nil { - deprecations = make(map[versions.Version]*sourceaddrs.RegistryVersionDeprecation) + deprecations = make(map[versions.Version]*RegistryVersionDeprecation) ret.registryPackageVersionDeprecations[pkgAddr] = deprecations } for versionStr, mv := range rpm.Versions { @@ -362,7 +362,7 @@ func (b *Bundle) RegistryPackageVersions(pkgAddr regaddr.ModulePackage) versions return ret } -func (b *Bundle) RegistryPackageVersionDeprecation(pkgAddr regaddr.ModulePackage, version versions.Version) *sourceaddrs.RegistryVersionDeprecation { +func (b *Bundle) RegistryPackageVersionDeprecation(pkgAddr regaddr.ModulePackage, version versions.Version) *RegistryVersionDeprecation { deprecation := b.registryPackageVersionDeprecations[pkgAddr][version] return deprecation } diff --git a/sourcebundle/manifest_json.go b/sourcebundle/manifest_json.go index e65d057..a97b395 100644 --- a/sourcebundle/manifest_json.go +++ b/sourcebundle/manifest_json.go @@ -3,8 +3,6 @@ package sourcebundle -import "github.com/hashicorp/go-slug/sourceaddrs" - // This file contains some internal-only types used to help with marshalling // and unmarshalling our manifest file format. The manifest format is not // itself a public interface, so these should stay unexported and any caller @@ -45,8 +43,8 @@ type manifestRegistryVersion struct { // This SourceAddr is a full source address, so it might potentially // have a sub-path portion. If it does then it must be combined with // any sub-path included in the user's registry module source address. - SourceAddr string `json:"source"` - Deprecation *sourceaddrs.RegistryVersionDeprecation `json:"deprecation"` + SourceAddr string `json:"source"` + Deprecation *RegistryVersionDeprecation `json:"deprecation"` } type manifestPackageMeta struct { diff --git a/sourcebundle/package_meta.go b/sourcebundle/package_meta.go index 993c302..a184db9 100644 --- a/sourcebundle/package_meta.go +++ b/sourcebundle/package_meta.go @@ -20,6 +20,12 @@ type PackageMeta struct { gitCommitMessage string } +type RegistryVersionDeprecation struct { + Version string + Reason string + Link string +} + // PackageMetaWithGitMetadata returns a [PackageMeta] object with a Git Commit // ID and message tracked. //