10000 chore: enable exhaustruct linter by johnstcn · Pull Request #8403 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore: enable exhaustruct linter #8403

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

Merged
merged 7 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make lint
  • Loading branch information
johnstcn committed Jul 11, 2023
commit 60139866b53ede0108a8513d93798bc357526edf
6 changes: 3 additions & 3 deletions coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func New(options *Options) *API {
RedirectToLogin: false,
DisableSessionExpiryRefresh: options.DeploymentValues.DisableSessionExpiryRefresh.Value(),
Optional: false,
SessionTokenFunc: nil, // Default behaviour
SessionTokenFunc: nil, // Default behavior
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to have the // Default behavior comment?

The comment on the field says: If nil, the default behavior is used.

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't need the comment, I was just being super explicit about what it means.

})
// Same as above but it redirects to the login page.
apiKeyMiddlewareRedirect := httpmw.ExtractAPIKeyMW(httpmw.ExtractAPIKeyConfig{
Expand All @@ -399,7 +399,7 @@ func New(options *Options) *API {
RedirectToLogin: true,
DisableSessionExpiryRefresh: options.DeploymentValues.DisableSessionExpiryRefresh.Value(),
Optional: false,
SessionTokenFunc: nil, // Default behaviour
SessionTokenFunc: nil, // Default behavior
})
// Same as the first but it's optional.
apiKeyMiddlewareOptional := httpmw.ExtractAPIKeyMW(httpmw.ExtractAPIKeyConfig{
Expand All @@ -408,7 +408,7 @@ func New(options *Options) *API {
RedirectToLogin: false,
DisableSessionExpiryRefresh: options.DeploymentValues.DisableSessionExpiryRefresh.Value(),
Optional: true,
SessionTokenFunc: nil, // Default behaviour
SessionTokenFunc: nil, // Default behavior
})

// API rate limit middleware. The counter is local and not shared between
Expand Down
5 changes: 4 additions & 1 deletion coderd/httpmw/realip.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ func ExtractRealIPAddress(config *RealIPConfig, req *http.Request) (net.IP, erro
// of each proxy header is set.
func FilterUntrustedOriginHeaders(config *RealIPConfig, req *http.Request) {
if config == nil {
config = &RealIPConfig{}
config = &RealIPConfig{
TrustedOrigins: []*net.IPNet{},
TrustedHeaders: []string{},
}
}

cf := isContainedIn(config.TrustedOrigins, getRemoteAddress(req.RemoteAddr))
Expand Down
4 changes: 2 additions & 2 deletions enterprise/coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
RedirectToLogin: false,
DisableSessionExpiryRefresh: options.DeploymentValues.DisableSessionExpiryRefresh.Value(),
Optional: false,
SessionTokenFunc: nil, // Default behaviour
SessionTokenFunc: nil, // Default behavior
})
apiKeyMiddlewareOptional := httpmw.ExtractAPIKeyMW(httpmw.ExtractAPIKeyConfig{
DB: options.Database,
OAuth2Configs: oauthConfigs,
RedirectToLogin: false,
DisableSessionExpiryRefresh: options.DeploymentValues.DisableSessionExpiryRefresh.Value(),
Optional: true,
SessionTokenFunc: nil, // Default behaviour
SessionTokenFunc: nil, // Default behavior
})

deploymentID, err := options.Database.GetDeploymentID(ctx)
Expand Down
2 changes: 2 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ distro() {

if [ -f /etc/os-release ]; then
(
# shellcheck disable=SC1091
Copy link
Member Author
@johnstcn johnstcn Jul 11, 2023

Choose a reason for hiding this comment

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

review: this was making lint fail locally on darwin

. /etc/os-release
if [ "${ID_LIKE-}" ]; then
for id_like in $ID_LIKE; do
Expand All @@ -553,6 +554,7 @@ distro_name() {

if [ -f /etc/os-release ]; then
(
# shellcheck disable=SC1091
. /etc/os-release
echo "$PRETTY_NAME"
)
Expand Down
0