-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose deprecation data in Bundle #59
Conversation
b8e6fc8
to
ef8c8ac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got a couple concerns with this, but they are minor. We should find a way to create a meaningful test
…le, use index to append elements to slice with known length and capacity
sourceaddrs/source_registry.go
Outdated
@@ -29,6 +29,12 @@ type RegistrySource struct { | |||
subPath string | |||
} | |||
|
|||
type RegistryVersionDeprecation struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type may be in the wrong package, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the way you un-nested the thing previously called "RemoteSourceInfo"!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah gotcha. Just to clarify your thinking, would you consider it out of place since it's only used in sourcebundle
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in any case any suggestions where it might be a better fit? No file in particular pops out at me in the package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ended up moving it to package_meta.go
in the sourcebundle package, seems to be the best fit.
Included here: 3914531
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for walking me through a demo of the changes. To recap, you'll adjust the "more information" section to include a url that can actually be clicked.
The changes we smoked tested today were through the agent, which is good. But I'd also recommend that you smoke test by building the binary for stacks, running some of their commands in the CLI, and just confirming that nothing is broken over there.
I took a look at your code changes yesterday, and again today. I really like that after you addressed Brandon's comment, the scope of your changes has reduced and simplified, in a good way!
While I am absent, please, continue with Brandon, and if possible with someone from the Stacks project to get their blessing on these changes 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really basic feedback. I didn't smoke test but looks safe
@@ -73,12 +73,14 @@ type Builder struct { | |||
// selected version of each module registry package. | |||
resolvedRegistry map[registryPackageVersion]sourceaddrs.RemoteSource | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a code comment
// resolvedRegistryVersionDeprecations tracks potential deprecations for | |
// each package version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Included 👍 ea8f696
sourcebundle/builder.go
Outdated
remotePackageDirs: make(map[sourceaddrs.RemotePackage]string), | ||
remotePackageMeta: make(map[sourceaddrs.RemotePackage]*PackageMeta), | ||
resolvedRegistry: make(map[registryPackageVersion]sourceaddrs.RemoteSource), | ||
resolvedRegistryVersionDeprecations: make(map[registryPackageVersion]*RegistryVersionDeprecation), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slightly verbose-- plus 'resolved' may refer to the RemoteSource values...
resolvedRegistryVersionDeprecations: make(map[registryPackageVersion]*RegistryVersionDeprecation), | |
versionDeprecations: make(map[registryPackageVersion]*RegistryVersionDeprecation), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we meet in the middle with packageVersionDeprecations
?
Included here: ea8f696
sourcebundle/bundle.go
Outdated
deprecation := b.registryPackageVersionDeprecations[pkgAddr][version] | ||
return deprecation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this could panic, but it wont! Neat. No need for a local, though
deprecation := b.registryPackageVersionDeprecations[pkgAddr][version] | |
return deprecation | |
return b.registryPackageVersionDeprecations[pkgAddr][version] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Included 👍 ea8f696
sourcebundle/builder_test.go
Outdated
if registryDeprecations[pkgAddr.Namespace] == nil { | ||
registryDeprecations[pkgAddr.Namespace] = make(map[versions.Version]*ModulePackageVersionDeprecation) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to reallocate this nested map: https://go.dev/play/p/dmUQYnvF7y_H
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I thought initially as well, but I'm otherwise getting nil pointer exceptions. Any idea why that could be the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually nevermind that 😅, didn't initially catch that you were assigning a map at the index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Included 👍 ea8f696
@@ -108,11 +110,17 @@ func OpenDir(baseDir string) (*Bundle, error) { | |||
vs = make(map[versions.Version]sourceaddrs.RemoteSource) | |||
ret.registryPackageSources[pkgAddr] = vs | |||
} | |||
deprecations := ret.registryPackageVersionDeprecations[pkgAddr] | |||
if deprecations == nil { | |||
deprecations = make(map[versions.Version]*RegistryVersionDeprecation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary reallocation I think (see previous comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose that similar to the above we could just assign the nested map at the index of pkgAddr
but I figured to was best to stick with the style of how registryPackageSources
is handled above for consistencies sake.
vs := ret.registryPackageSources[pkgAddr]
if vs == nil {
vs = make(map[versions.Version]sourceaddrs.RemoteSource)
ret.registryPackageSources[pkgAddr] = vs
}
…s, remove unneed map reallocation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor go-specific thoughts. From a stacks technical point of view, this looks fine to me!
@@ -73,12 +73,16 @@ type Builder struct { | |||
// selected version of each module registry package. | |||
resolvedRegistry map[registryPackageVersion]sourceaddrs.RemoteSource | |||
|
|||
// resolvedRegistryVersionDeprecations tracks potential deprecations for | |||
// each package version | |||
packageVersionDeprecations map[registryPackageVersion]*RegistryVersionDeprecation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why this is a map of pointer-to-RegistryVersionDeprecation
. Later on we store nil
in this map if a registry package version has no deprecation information, rather than having no entry in the map at all. Is that important?
Having a pointer here means we need to be diligent about nil checks, or we'll panic. Would there be a disadvantage to this being map[registryPackageVersion]RegistryVersionDeprecation
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comes from the approach we've taken with how we denote deprecated versions. In essence, when there are no deprecations, the registry api doesn't include it in the Module Version response. So in this waynil
denotes an un-deprecated module.
sourcebundle/builder.go
Outdated
@@ -73,12 +73,16 @@ type Builder struct { | |||
// selected version of each module registry package. | |||
resolvedRegistry map[registryPackageVersion]sourceaddrs.RemoteSource | |||
|
|||
// resolvedRegistryVersionDeprecations tracks potential deprecations for | |||
// each package version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is currently just restating the variable name, and some more detail would be helpful. Example future readers' questions you may want to proactively answer (or not! whatever you think is pertinent):
- Where is the data gathered from?
- What consumes this data?
- What's a "potential" deprecation?
While we're here, the field in the comment doesn't match the field name in the struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Included 👍 be5d907
// resolvedRegistryVersionDeprecations tracks potential deprecations for | ||
// each package version | ||
packageVersionDeprecations map[registryPackageVersion]*RegistryVersionDeprecation | ||
|
||
// registryPackageVersions caches responses from module registry calls to | ||
// look up the available versions for a particular module package. Although | ||
// these could potentially change while we're running, we assume that the | ||
// lifetime of a particular Builder is short enough for that not to | ||
// matter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth noting here that this cache includes the deprecation data, as well as the package versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Included 👍 be5d907
sourcebundle/builder.go
Outdated
return vs | ||
} | ||
|
||
func extractVersionDeprecationsFromResponse(modPackageInfos []ModulePackageInfo) map[versions.Version]*ModulePackageVersionDeprecation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is very simple and only called from one site. I think it's more typical go style to inline this instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Included 👍 be5d907
Updates sourceBundle’s
ModulePackageVersionsResponse
type to include registry module deprecation data in the response. This deprecation data is then propagated to the Bundle, where it will be then used within a relatedtfc-agent
PR to add diagnostic warnings about deprecated module versions for stacks .Related Items
tfc-agent
PR