Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: track terraform module source type in telemetry#15590

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hugodutka merged 3 commits intomainfromhugodutka/module-source-type
Nov 20, 2024

Conversation

hugodutka
Copy link
Contributor

@hugodutkahugodutka marked this pull request as ready for reviewNovember 19, 2024 11:38
ModuleSourceTypeUnknownModuleSourceType="unknown"
)

funcGetModuleSourceType(sourcestring)ModuleSourceType {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It might be good for future readers to add a doc comment to this function along with a link tohttps://developer.hashicorp.com/terraform/language/modules/sources, as they may have some similar questions to me before reading:

  • Wait, these aren't just URLS?! Nope.
  • There's difference between how relative and absolute local paths are handled? yup
  • Wait, you can have "localterraform.com" as a generic "local" hostname? yup
  • Wait, you can just use an un-prefixed GitHub registry as a module source? yup
  • etc...

hugodutka reacted with eyes emoji
Comment on lines 742 to 744
if!strings.Contains(source,"://")&&!strings.Contains(source,".")&&strings.Contains(source,"/") {
returnModuleSourceTypePublicRegistry
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should we tighten this condition up a bit and assert that it follows the formnamespace/name/provider? And maybe move it up slightly?

hugodutka reacted with thumbs up emoji
@hugodutka
Copy link
ContributorAuthor

@johnstcn I made changes according to your feedback. Thanks!

Comment on lines +757 to +765
ifstrings.Contains(source,"registry.terraform.io") {
returnModuleSourceTypePublicRegistry
}
ifstrings.Contains(source,"app.terraform.io")||strings.Contains(source,"localterraform.com") {
returnModuleSourceTypePrivateRegistry
}
ifstrings.Contains(source,"registry.coder.com") {
returnModuleSourceTypeCoderRegistry
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What aboutregistry.coder.com.mydomain.foo.bar? Should we instead usestrings.HasPrefix here too?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@johnstcn I wasn't aware that people could access the coder registry that way. How does this work? Can people self-host our registry?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

As I write this, I realise that prefix-checking won't even help here unless we attempt to parse the module as an URL and extract only the hostname.

In any case, I don't see any reason that someone sufficiently motiviated couldn't do this if they controlled the domainmydomain.foo.bar and used something like outsiders/citizen to self-host a registry.

It's more of a contrived hypothetical though and I'm not going to block on this!

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think it's acceptable to misclassify a small percentage of modules. With telemetry, we’re more focused on aggregates, and cases like this are unlikely to affect the overall picture.

johnstcn reacted with thumbs up emoji
require.Equal(t,modules[1].Version,"1.0.0")
require.Equal(t,modules[1].SourceType,telemetry.ModuleSourceTypeCoderRegistry)
})
t.Run("ModuleSourceType",func(t*testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

praise: nice test coverage!

Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

One last comment but I don't need to re-review.

@hugodutkahugodutka merged commit97ce44a intomainNov 20, 2024
26 checks passed
@hugodutkahugodutka deleted the hugodutka/module-source-type branchNovember 20, 2024 10:03
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

Assignees

@hugodutkahugodutka

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@hugodutka@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp