Skip to content
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

fix: change receiver to pointer for listener and priorityQueue #1819

Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ linters-settings:
extra-rules: true
linters:
enable:
- recvcheck
- iface
- asasalint
- asciicheck
- bidichk
Expand Down
8 changes: 4 additions & 4 deletions pkg/adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (l *listener) Start(ctx context.Context) error {
return nil
}

func (l listener) handleEvent(ctx context.Context) http.HandlerFunc {
func (l *listener) handleEvent(ctx context.Context) http.HandlerFunc {
return func(response http.ResponseWriter, request *http.Request) {
if request.Method != http.MethodPost {
l.writeResponse(response, http.StatusOK, "ok")
Expand Down Expand Up @@ -206,7 +206,7 @@ func (l listener) handleEvent(ctx context.Context) http.HandlerFunc {
}
}

func (l listener) processRes(processEvent bool, provider provider.Interface, logger *zap.SugaredLogger, skipReason string, err error) (provider.Interface, *zap.SugaredLogger, error) {
func (l *listener) processRes(processEvent bool, provider provider.Interface, logger *zap.SugaredLogger, skipReason string, err error) (provider.Interface, *zap.SugaredLogger, error) {
if processEvent {
provider.SetLogger(logger)
return provider, logger, nil
Expand All @@ -223,7 +223,7 @@ func (l listener) processRes(processEvent bool, provider provider.Interface, log
return nil, logger, fmt.Errorf("skipping non supported event")
}

func (l listener) detectProvider(req *http.Request, reqBody string) (provider.Interface, *zap.SugaredLogger, error) {
func (l *listener) detectProvider(req *http.Request, reqBody string) (provider.Interface, *zap.SugaredLogger, error) {
log := *l.logger

// payload validation
Expand Down Expand Up @@ -267,7 +267,7 @@ func (l listener) detectProvider(req *http.Request, reqBody string) (provider.In
return l.processRes(false, nil, logger, "", fmt.Errorf("no supported Git provider has been detected"))
}

func (l listener) writeResponse(response http.ResponseWriter, statusCode int, message string) {
func (l *listener) writeResponse(response http.ResponseWriter, statusCode int, message string) {
response.WriteHeader(statusCode)
response.Header().Set("Content-Type", "application/json")
body := Response{
Expand Down
2 changes: 1 addition & 1 deletion pkg/adapter/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const tlsMountPath = "/etc/pipelines-as-code/tls"

// isTLSEnabled validates if tls secret exist and if the required fields are defined
// this is used to enable tls on the listener.
func (l listener) isTLSEnabled() (bool, string, string) {
func (l *listener) isTLSEnabled() (bool, string, string) {
tlsSecret := os.Getenv("TLS_SECRET_NAME")
tlsKey := os.Getenv("TLS_KEY")
tlsCert := os.Getenv("TLS_CERT")
Expand Down
6 changes: 3 additions & 3 deletions pkg/sync/priority_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ func (pq *priorityQueue) peek() *item {
return pq.items[0]
}

func (pq priorityQueue) Len() int { return len(pq.items) }
func (pq *priorityQueue) Len() int { return len(pq.items) }

func (pq priorityQueue) Less(i, j int) bool {
func (pq *priorityQueue) Less(i, j int) bool {
return pq.items[i].priority < pq.items[j].priority
}

func (pq priorityQueue) Swap(i, j int) {
func (pq *priorityQueue) Swap(i, j int) {
pq.items[i], pq.items[j] = pq.items[j], pq.items[i]
pq.items[i].index = i
pq.items[j].index = j
Expand Down
Loading