Skip to content

Reuse injectproxy package#66

Merged
bwplotka merged 2 commits intoprometheus-community:masterfrom
Abhishek357:import-injectProxy
May 17, 2021
Merged

Reuse injectproxy package#66
bwplotka merged 2 commits intoprometheus-community:masterfrom
Abhishek357:import-injectProxy

Conversation

@Abhishek357
Copy link
Copy Markdown
Contributor

Signed-off-by: Abhishek357 abhisheksinghchauhan357@gmail.com

We would like to reuse the injectproxy package in thanos. Related to PR

Signed-off-by: Abhishek357 <abhisheksinghchauhan357@gmail.com>
Copy link
Copy Markdown
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Amazing, small nits, otherwise LGTM! (:

return nil
}

func (ms Enforcer) enforceMatchers(targets []*labels.Matcher) []*labels.Matcher {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you mind adding quick commentary what this public method does (Public methods should be commented always with comment started as // EnforceMatchers ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sure!

)

type Enforcer struct {
labelMatchers map[string]*labels.Matcher
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why we need access to this? It looks like code smell, as it leaks the enforcer internal logic. Aren't its methods enough? Are you missing some functionality that could be added as method?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We need to access this because enforceMatchers is a method of enforcer and to access it first we need to create an enforcer(in our use case in Thanos this enforcer contains the information about the tenant label name we want to replace and tenant access a user has as specified in the header)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yea, but this method has access to this because it's a method on Enforcer itself, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hmm, I think we can use NewEnforcer to create a new enforcer.
Let me try it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Well. I think we even have to! That's why we do constructors in Go (:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ahh just refreshed those concepts thanks! definitely make sense.

Signed-off-by: Abhishek357 <abhisheksinghchauhan357@gmail.com>
Copy link
Copy Markdown
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

}

func (ms Enforcer) enforceMatchers(targets []*labels.Matcher) []*labels.Matcher {
// EnforceMatchers replaces similar matcher present in
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would be specific what "similar" means, but it's good enough (:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will keep that in mind.

@bwplotka bwplotka merged commit 08d3f30 into prometheus-community:master May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants