Skip to content
Merged
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: 1 addition & 1 deletion api/admin/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Use of this source code is governed by the LICENSE file in this repository.

// nolint: dupl // ignore similar code
//nolint:dupl // ignore similar code
package admin

import (
Expand Down
2 changes: 1 addition & 1 deletion api/admin/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Use of this source code is governed by the LICENSE file in this repository.

// nolint: dupl // ignore similar code
//nolint:dupl // ignore similar code
package admin

import (
Expand Down
2 changes: 1 addition & 1 deletion api/admin/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Use of this source code is governed by the LICENSE file in this repository.

// nolint: dupl // ignore similar code
//nolint:dupl // ignore similar code
package admin

import (
Expand Down
2 changes: 1 addition & 1 deletion api/admin/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Use of this source code is governed by the LICENSE file in this repository.

// nolint: dupl // ignore similar code
//nolint:dupl // ignore similar code
package admin

import (
Expand Down
2 changes: 1 addition & 1 deletion api/admin/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Use of this source code is governed by the LICENSE file in this repository.

// nolint: dupl // ignore similar code
//nolint:dupl // ignore similar code
package admin

import (
Expand Down
2 changes: 1 addition & 1 deletion api/admin/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Use of this source code is governed by the LICENSE file in this repository.

// nolint: dupl // ignore similar code
//nolint:dupl // ignore similar code
package admin

import (
Expand Down
2 changes: 1 addition & 1 deletion api/admin/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Use of this source code is governed by the LICENSE file in this repository.

// nolint: dupl // ignore similar code
//nolint:dupl // ignore similar code
package admin

import (
Expand Down
28 changes: 16 additions & 12 deletions api/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"strconv"
"strings"
Expand Down Expand Up @@ -85,7 +85,8 @@ import (
// "$ref": "#/definitions/Error"

// CreateBuild represents the API handler to create a build in the configured backend.
// nolint: funlen,gocyclo // ignore function length and cyclomatic complexity
//
//nolint:funlen,gocyclo // ignore function length and cyclomatic complexity
func CreateBuild(c *gin.Context) {
// capture middleware values
m := c.MustGet("metadata").(*types.Metadata)
Expand Down Expand Up @@ -307,7 +308,7 @@ func CreateBuild(c *gin.Context) {

// check if the pipeline did not already exist in the database
//
// nolint: dupl // ignore duplicate code
//nolint:dupl // ignore duplicate code
if pipeline == nil {
pipeline = compiled
pipeline.SetRepoID(r.GetID())
Expand All @@ -327,7 +328,7 @@ func CreateBuild(c *gin.Context) {
// send API call to capture the created pipeline
pipeline, err = database.FromContext(c).GetPipelineForRepo(pipeline.GetCommit(), r)
if err != nil {
// nolint: lll // ignore long line length due to error message
//nolint:lll // ignore long line length due to error message
retErr := fmt.Errorf("unable to create new build: failed to get new pipeline %s/%s: %w", r.GetFullName(), pipeline.GetCommit(), err)

util.HandleError(c, http.StatusInternalServerError, retErr)
Expand Down Expand Up @@ -380,7 +381,8 @@ func CreateBuild(c *gin.Context) {

// skipEmptyBuild checks if the build should be skipped due to it
// not containing any steps besides init or clone.
// nolint: goconst // ignore init and clone constants
//
//nolint:goconst // ignore init and clone constants
func skipEmptyBuild(p *pipeline.Build) string {
if len(p.Stages) == 1 {
if p.Stages[0].Name == "init" {
Expand Down Expand Up @@ -792,7 +794,7 @@ func GetOrgBuilds(c *gin.Context) {
}
// Only show public repos to non-admins
//
// nolint: goconst // ignore admin constant
//nolint:goconst // ignore admin constant
if perm != "admin" {
filters["visibility"] = constants.VisibilityPublic
}
Expand Down Expand Up @@ -922,7 +924,8 @@ func GetBuild(c *gin.Context) {
// "$ref": "#/definitions/Error"

// RestartBuild represents the API handler to restart an existing build in the configured backend.
// nolint: funlen // ignore statement count
//
//nolint:funlen // ignore statement count
func RestartBuild(c *gin.Context) {
// capture middleware values
m := c.MustGet("metadata").(*types.Metadata)
Expand Down Expand Up @@ -1134,7 +1137,7 @@ func RestartBuild(c *gin.Context) {

// check if the pipeline did not already exist in the database
//
// nolint: dupl // ignore duplicate code
//nolint:dupl // ignore duplicate code
if pipeline == nil {
pipeline = compiled
pipeline.SetRepoID(r.GetID())
Expand All @@ -1154,7 +1157,7 @@ func RestartBuild(c *gin.Context) {
// send API call to capture the created pipeline
pipeline, err = database.FromContext(c).GetPipelineForRepo(pipeline.GetCommit(), r)
if err != nil {
// nolint: lll // ignore long line length due to error message
//nolint:lll // ignore long line length due to error message
retErr := fmt.Errorf("unable to get new pipeline %s/%s: %w", r.GetFullName(), pipeline.GetCommit(), err)

util.HandleError(c, http.StatusInternalServerError, retErr)
Expand Down Expand Up @@ -1465,7 +1468,7 @@ func getPRNumberFromBuild(b *library.Build) (int, error) {
// execution. This creates all resources, like steps
// and services, for the build in the configured backend.
// TODO:
// - return build and error
// - return build and error.
func planBuild(database database.Service, p *pipeline.Build, b *library.Build, r *library.Repo) error {
// update fields in build object
b.SetCreated(time.Now().UTC().Unix())
Expand Down Expand Up @@ -1601,7 +1604,8 @@ func cleanBuild(database database.Service, b *library.Build, services []*library
// "$ref": "#/definitions/Error"

// CancelBuild represents the API handler to cancel a running build.
// nolint: funlen // ignore statement count
//
//nolint:funlen // ignore statement count
func CancelBuild(c *gin.Context) {
// capture middleware values
b := build.Retrieve(c)
Expand Down Expand Up @@ -1674,7 +1678,7 @@ func CancelBuild(c *gin.Context) {
defer resp.Body.Close()

// Read Response Body
respBody, err := ioutil.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)
if err != nil {
retErr := fmt.Errorf("unable to read response from %s: %w", u, err)
util.HandleError(c, http.StatusBadRequest, retErr)
Expand Down
8 changes: 4 additions & 4 deletions api/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func GetBuildLogs(c *gin.Context) {
// CreateServiceLog represents the API handler to create
// the logs for a service in the configured backend.
//
// nolint: dupl // ignore similar code with step
//nolint:dupl // ignore similar code with step
func CreateServiceLog(c *gin.Context) {
// capture middleware values
b := build.Retrieve(c)
Expand Down Expand Up @@ -445,7 +445,7 @@ func UpdateServiceLog(c *gin.Context) {
// DeleteServiceLog represents the API handler to remove
// the logs for a service from the configured backend.
//
// nolint: dupl // ignore similar code with step
//nolint:dupl // ignore similar code with step
func DeleteServiceLog(c *gin.Context) {
// capture middleware values
b := build.Retrieve(c)
Expand Down Expand Up @@ -535,7 +535,7 @@ func DeleteServiceLog(c *gin.Context) {
// CreateStepLog represents the API handler to create
// the logs for a step in the configured backend.
//
// nolint: dupl // ignore similar code with service
//nolint:dupl // ignore similar code with service
func CreateStepLog(c *gin.Context) {
// capture middleware values
b := build.Retrieve(c)
Expand Down Expand Up @@ -831,7 +831,7 @@ func UpdateStepLog(c *gin.Context) {
// DeleteStepLog represents the API handler to remove
// the logs for a step from the configured backend.
//
// nolint: dupl // ignore similar code with service
//nolint:dupl // ignore similar code with service
func DeleteStepLog(c *gin.Context) {
// capture middleware values
b := build.Retrieve(c)
Expand Down
3 changes: 2 additions & 1 deletion api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ func CustomMetrics(c *gin.Context) {
}

// helper function to get the totals of resource types.
// nolint: funlen,gocyclo // ignore function length and cyclomatic complexity
//
//nolint:funlen,gocyclo // ignore function length and cyclomatic complexity
func recordGauges(c *gin.Context) {
// variable to store query parameters
q := MetricsQueryParameters{}
Expand Down
2 changes: 1 addition & 1 deletion api/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (p *Pagination) TotalPages() int {
// resolveScheme is a helper to determine the protocol scheme
// c.Request.URL.Scheme does not seem to reliably provide this.
//
// nolint: goconst // ignore making constant for https
//nolint:goconst // ignore making constant for https
func resolveScheme(r *http.Request) string {
switch {
case r.Header.Get("X-Forwarded-Proto") == "https":
Expand Down
2 changes: 1 addition & 1 deletion api/pipeline/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Use of this source code is governed by the LICENSE file in this repository.

// nolint: dupl // ignore similar code with expand
//nolint:dupl // ignore similar code with expand
package pipeline

import (
Expand Down
2 changes: 1 addition & 1 deletion api/pipeline/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Use of this source code is governed by the LICENSE file in this repository.

// nolint: dupl // ignore similar code with compile
//nolint:dupl // ignore similar code with compile
package pipeline

import (
Expand Down
6 changes: 3 additions & 3 deletions api/pipeline/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func ListPipelines(c *gin.Context) {
// capture page query parameter if present
page, err := strconv.Atoi(c.DefaultQuery("page", "1"))
if err != nil {
// nolint: lll // ignore long line length due to error message
//nolint:lll // ignore long line length due to error message
retErr := fmt.Errorf("unable to convert page query parameter for repo %s: %w", r.GetFullName(), err)

util.HandleError(c, http.StatusBadRequest, retErr)
Expand All @@ -104,7 +104,7 @@ func ListPipelines(c *gin.Context) {
// capture per_page query parameter if present
perPage, err := strconv.Atoi(c.DefaultQuery("per_page", "10"))
if err != nil {
// nolint: lll // ignore long line length due to error message
//nolint:lll // ignore long line length due to error message
retErr := fmt.Errorf("unable to convert per_page query parameter for repo %s: %w", r.GetFullName(), err)

util.HandleError(c, http.StatusBadRequest, retErr)
Expand All @@ -114,7 +114,7 @@ func ListPipelines(c *gin.Context) {

// ensure per_page isn't above or below allowed values
//
// nolint: gomnd // ignore magic number
//nolint:gomnd // ignore magic number
perPage = util.MaxInt(1, util.MinInt(100, perPage))

p, t, err := database.FromContext(c).ListPipelinesForRepo(r, page, perPage)
Expand Down
5 changes: 3 additions & 2 deletions api/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import (
// CreateRepo represents the API handler to
// create a repo in the configured backend.
//
// nolint: funlen,gocyclo // ignore function length and cyclomatic complexity
//nolint:funlen,gocyclo // ignore function length and cyclomatic complexity
func CreateRepo(c *gin.Context) {
// capture middleware values
u := user.Retrieve(c)
Expand Down Expand Up @@ -634,7 +634,8 @@ func GetRepo(c *gin.Context) {

// UpdateRepo represents the API handler to update
// a repo in the configured backend.
// nolint: funlen // ignore line length
//
//nolint:funlen // ignore line length
func UpdateRepo(c *gin.Context) {
// capture middleware values
o := org.Retrieve(c)
Expand Down
4 changes: 2 additions & 2 deletions api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import (
// CreateService represents the API handler to create
// a service for a build in the configured backend.
//
// nolint: dupl // ignore similar code with step
//nolint:dupl // ignore similar code with step
func CreateService(c *gin.Context) {
// capture middleware values
b := build.Retrieve(c)
Expand Down Expand Up @@ -511,7 +511,7 @@ func UpdateService(c *gin.Context) {
// DeleteService represents the API handler to remove
// a service for a build from the configured backend.
//
// nolint: dupl // ignore similar code with step
//nolint:dupl // ignore similar code with step
func DeleteService(c *gin.Context) {
// capture middleware values
b := build.Retrieve(c)
Expand Down
4 changes: 2 additions & 2 deletions api/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import (
// CreateStep represents the API handler to create
// a step for a build in the configured backend.
//
// nolint: dupl // ignore similar code with service
//nolint:dupl // ignore similar code with service
func CreateStep(c *gin.Context) {
// capture middleware values
b := build.Retrieve(c)
Expand Down Expand Up @@ -512,7 +512,7 @@ func UpdateStep(c *gin.Context) {
// DeleteStep represents the API handler to remove
// a step for a build from the configured backend.
//
// nolint: dupl // ignore similar code with service
//nolint:dupl // ignore similar code with service
func DeleteStep(c *gin.Context) {
// capture middleware values
b := build.Retrieve(c)
Expand Down
6 changes: 4 additions & 2 deletions api/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ const logUpdateInterval = 1 * time.Second

// PostServiceStream represents the API handler that
// streams service logs to the database.
// nolint: dupl // separate service/step functions for consistency with API
//
//nolint:dupl // separate service/step functions for consistency with API
func PostServiceStream(c *gin.Context) {
// capture middleware values
b := build.Retrieve(c)
Expand Down Expand Up @@ -235,7 +236,8 @@ func PostServiceStream(c *gin.Context) {

// PostStepStream represents the API handler that
// streams service logs to the database.
// nolint: dupl // separate service/step functions for consistency with API
//
//nolint:dupl // separate service/step functions for consistency with API
func PostStepStream(c *gin.Context) {
// capture middleware values
b := build.Retrieve(c)
Expand Down
10 changes: 5 additions & 5 deletions api/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"
"time"
Expand Down Expand Up @@ -71,7 +71,7 @@ var baseErr = "unable to process webhook"
// a webhook from a source control provider and
// publish it to the configure queue.
//
// nolint: funlen,gocyclo // ignore function length and cyclomatic complexity
//nolint:funlen,gocyclo // ignore function length and cyclomatic complexity
func PostWebhook(c *gin.Context) {
logrus.Info("webhook received")

Expand Down Expand Up @@ -105,10 +105,10 @@ func PostWebhook(c *gin.Context) {
}

// add the request body to the original request
c.Request.Body = ioutil.NopCloser(&buf)
c.Request.Body = io.NopCloser(&buf)

// add the request body to the duplicate request
dupRequest.Body = ioutil.NopCloser(bytes.NewReader(buf.Bytes()))
dupRequest.Body = io.NopCloser(bytes.NewReader(buf.Bytes()))
//
// -------------------- End of TODO: --------------------

Expand Down Expand Up @@ -548,7 +548,7 @@ func PostWebhook(c *gin.Context) {
// send API call to capture the created pipeline
pipeline, err = database.FromContext(c).GetPipelineForRepo(pipeline.GetCommit(), r)
if err != nil {
// nolint: lll // ignore long line length due to error message
//nolint:lll // ignore long line length due to error message
retErr := fmt.Errorf("%s: failed to get new pipeline %s/%s: %w", baseErr, r.GetFullName(), pipeline.GetCommit(), err)
util.HandleError(c, http.StatusInternalServerError, retErr)

Expand Down
2 changes: 1 addition & 1 deletion cmd/vela-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
_ "github.com/joho/godotenv/autoload"
)

// nolint: funlen // ignore line length
//nolint:funlen // ignore line length
func main() {
// capture application version information
v := version.New()
Expand Down
Loading