Skip to content

Commit

Permalink
Updated ModulePackageVersionsResponse to include deprecation data
Browse files Browse the repository at this point in the history
  • Loading branch information
Maed223 committed May 14, 2024
1 parent 9c4d904 commit 808e5dd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
7 changes: 6 additions & 1 deletion sourcebundle/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,12 @@ func (b *Builder) findRegistryPackageSource(ctx context.Context, sourceAddr sour
}
return sourceaddrs.RemoteSource{}, fmt.Errorf("failed to query available versions for %s: %w", pkgAddr, err)
}
vs := resp.Versions

modPackageVersions := resp.Versions
vs := make(versions.List, len(modPackageVersions))
for _, v := range modPackageVersions {
vs = append(vs, v.Version)
}
vs.Sort()
availableVersions = vs
b.registryPackageVersions[pkgAddr] = availableVersions
Expand Down
6 changes: 4 additions & 2 deletions sourcebundle/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,11 @@ func testingBuilder(t *testing.T, targetDir string, remotePackages map[string]st
if pkg.pkgAddr != pkgAddr {
continue
}
ret.Versions = make(versions.List, len(pkg.versions))
ret.Versions = make([]ModulePackageVersion, len(pkg.versions))
for version := range pkg.versions {
ret.Versions = append(ret.Versions, version)
ret.Versions = append(ret.Versions, ModulePackageVersion{
Version: version,
})
}
return ret, nil
}
Expand Down
12 changes: 11 additions & 1 deletion sourcebundle/registry_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ type RegistryClient interface {
// of the package versions client operation. This type may grow to add more
// functionality over time in later minor releases.
type ModulePackageVersionsResponse struct {
Versions versions.List
Versions []ModulePackageVersion `json:"versions"`
}

type ModulePackageVersion struct {
Version versions.Version
Deprecation Deprecation `json:"deprecation"`
}

type Deprecation struct {
Reason string `json:"reason"`
Link string `json:"link"`
}

// ModulePackageSourceAddrResponse is an opaque type which represents the
Expand Down

0 comments on commit 808e5dd

Please sign in to comment.