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

refactor(pipeline): use server API types for pipeline and migrate compiler types #1200

Merged
merged 3 commits into from
Oct 11, 2024
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/build/auto_cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (
"github.com/sirupsen/logrus"

"github.com/go-vela/server/api/types"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/server/database"
"github.com/go-vela/server/internal/token"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/pipeline"
)

// AutoCancel is a helper function that checks to see if any pending or running
Expand Down
2 changes: 1 addition & 1 deletion api/build/auto_cancel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"testing"

"github.com/go-vela/server/api/types"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/pipeline"
)

func Test_isCancelable(t *testing.T) {
Expand Down
9 changes: 4 additions & 5 deletions api/build/compile_publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ import (

"github.com/go-vela/server/api/types"
"github.com/go-vela/server/compiler"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/server/database"
"github.com/go-vela/server/internal"
"github.com/go-vela/server/queue"
"github.com/go-vela/server/queue/models"
"github.com/go-vela/server/scm"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/library"
"github.com/go-vela/types/pipeline"
)

// CompileAndPublishConfig is a struct that contains information for the CompileAndPublish function.
Expand Down Expand Up @@ -181,7 +180,7 @@ func CompileAndPublish(
// variable to store executable pipeline
p *pipeline.Build
// variable to store pipeline configuration
pipeline *library.Pipeline
pipeline *types.Pipeline
// variable to store the pipeline type for the repository
pipelineType = r.GetPipelineType()
// variable to store updated repository record
Expand Down Expand Up @@ -257,7 +256,7 @@ func CompileAndPublish(
repo.SetPipelineType(pipeline.GetType())
}

var compiled *library.Pipeline
var compiled *types.Pipeline
// parse and compile the pipeline configuration file
p, compiled, err = compiler.
Duplicate().
Expand Down Expand Up @@ -311,7 +310,7 @@ func CompileAndPublish(
// check if the pipeline did not already exist in the database
if pipeline == nil {
pipeline = compiled
pipeline.SetRepoID(repo.GetID())
pipeline.SetRepo(repo)
pipeline.SetCommit(b.GetCommit())
pipeline.SetRef(b.GetRef())

Expand Down
2 changes: 1 addition & 1 deletion api/build/executable.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (
"github.com/sirupsen/logrus"

"github.com/go-vela/server/api/types"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/server/database"
"github.com/go-vela/server/router/middleware/build"
"github.com/go-vela/server/router/middleware/repo"
"github.com/go-vela/server/util"
"github.com/go-vela/types/library"
"github.com/go-vela/types/pipeline"
)

// swagger:operation GET /api/v1/repos/{org}/{repo}/builds/{build}/executable builds GetBuildExecutable
Expand Down
2 changes: 1 addition & 1 deletion api/build/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/sirupsen/logrus"

"github.com/go-vela/server/compiler"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/server/database"
"github.com/go-vela/server/internal"
"github.com/go-vela/server/router/middleware/build"
Expand All @@ -21,7 +22,6 @@ import (
"github.com/go-vela/server/util"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/library"
"github.com/go-vela/types/pipeline"
)

// Graph contains nodes, and relationships between nodes, or edges.
Expand Down
2 changes: 1 addition & 1 deletion api/build/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"github.com/go-vela/server/api/service"
"github.com/go-vela/server/api/step"
"github.com/go-vela/server/api/types"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/server/database"
"github.com/go-vela/server/scm"
"github.com/go-vela/types/pipeline"
)

// PlanBuild is a helper function to plan the build for
Expand Down
2 changes: 1 addition & 1 deletion api/build/skip.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package build

import (
"github.com/go-vela/types/pipeline"
"github.com/go-vela/server/compiler/types/pipeline"
)

// SkipEmptyBuild checks if the build should be skipped due to it
Expand Down
2 changes: 1 addition & 1 deletion api/build/skip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package build
import (
"testing"

"github.com/go-vela/types/pipeline"
"github.com/go-vela/server/compiler/types/pipeline"
)

func Test_SkipEmptyBuild(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/pipeline/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
"github.com/sirupsen/logrus"

"github.com/go-vela/server/compiler"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/server/internal"
pMiddleware "github.com/go-vela/server/router/middleware/pipeline"
"github.com/go-vela/server/router/middleware/repo"
"github.com/go-vela/server/router/middleware/user"
"github.com/go-vela/server/util"
"github.com/go-vela/types/pipeline"
)

// swagger:operation POST /api/v1/pipelines/{org}/{repo}/{pipeline}/compile pipelines CompilePipeline
Expand Down
2 changes: 1 addition & 1 deletion api/pipeline/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/google/go-cmp/cmp"

"github.com/go-vela/types/pipeline"
"github.com/go-vela/server/compiler/types/pipeline"
)

// TestPrepareRuleData tests the prepareRuleData function.
Expand Down
6 changes: 3 additions & 3 deletions api/pipeline/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"

"github.com/go-vela/server/api/types"
"github.com/go-vela/server/database"
"github.com/go-vela/server/router/middleware/repo"
"github.com/go-vela/server/util"
"github.com/go-vela/types/library"
)

// swagger:operation POST /api/v1/pipelines/{org}/{repo} pipelines CreatePipeline
Expand Down Expand Up @@ -75,7 +75,7 @@ func CreatePipeline(c *gin.Context) {
l.Debugf("creating new pipeline for repo %s", r.GetFullName())

// capture body from API request
input := new(library.Pipeline)
input := new(types.Pipeline)

err := c.Bind(input)
if err != nil {
Expand All @@ -87,7 +87,7 @@ func CreatePipeline(c *gin.Context) {
}

// update fields in pipeline object
input.SetRepoID(r.GetID())
input.SetRepo(r)

// send API call to create the pipeline
p, err := database.FromContext(c).CreatePipeline(ctx, input)
Expand Down
2 changes: 1 addition & 1 deletion api/pipeline/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/go-vela/server/compiler"
"github.com/go-vela/server/compiler/registry/github"
"github.com/go-vela/server/compiler/types/yaml"
"github.com/go-vela/server/internal"
"github.com/go-vela/server/router/middleware/org"
"github.com/go-vela/server/router/middleware/pipeline"
Expand All @@ -20,7 +21,6 @@ import (
"github.com/go-vela/server/scm"
"github.com/go-vela/server/util"
"github.com/go-vela/types/library"
"github.com/go-vela/types/yaml"
)

// swagger:operation GET /api/v1/pipelines/{org}/{repo}/{pipeline}/templates pipelines GetTemplates
Expand Down
4 changes: 2 additions & 2 deletions api/pipeline/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"

"github.com/go-vela/server/api/types"
"github.com/go-vela/server/database"
"github.com/go-vela/server/router/middleware/pipeline"
"github.com/go-vela/server/router/middleware/repo"
"github.com/go-vela/server/util"
"github.com/go-vela/types/library"
)

// swagger:operation PUT /api/v1/pipelines/{org}/{repo}/{pipeline} pipelines UpdatePipeline
Expand Down Expand Up @@ -83,7 +83,7 @@ func UpdatePipeline(c *gin.Context) {
l.Debugf("updating pipeline %s", entry)

// capture body from API request
input := new(library.Pipeline)
input := new(types.Pipeline)

err := c.Bind(input)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion api/service/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"github.com/sirupsen/logrus"

"github.com/go-vela/server/api/types"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/server/database"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/library"
"github.com/go-vela/types/pipeline"
)

// PlanServices is a helper function to plan all services
Expand Down
2 changes: 1 addition & 1 deletion api/step/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"github.com/sirupsen/logrus"

"github.com/go-vela/server/api/types"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/server/database"
"github.com/go-vela/server/scm"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/library"
"github.com/go-vela/types/pipeline"
)

// PlanSteps is a helper function to plan all steps
Expand Down
2 changes: 1 addition & 1 deletion api/types/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"strings"
"time"

"github.com/go-vela/server/compiler/types/raw"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/raw"
)

// Build is the API types representation of a build for a pipeline.
Expand Down
2 changes: 1 addition & 1 deletion api/types/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/google/go-cmp/cmp"

"github.com/go-vela/types/raw"
"github.com/go-vela/server/compiler/types/raw"
)

func TestTypes_Build_Duration(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/types/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package types
import (
"fmt"

"github.com/go-vela/types/raw"
"github.com/go-vela/server/compiler/types/raw"
)

// Deployment is the API representation of a deployment.
Expand Down
2 changes: 1 addition & 1 deletion api/types/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"strings"

"github.com/go-vela/types/pipeline"
"github.com/go-vela/server/compiler/types/pipeline"
)

// Executor is the API representation of an executor for a worker.
Expand Down
2 changes: 1 addition & 1 deletion api/types/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"testing"

"github.com/go-vela/types/pipeline"
"github.com/go-vela/server/compiler/types/pipeline"
)

func TestTypes_Executor_Getters(t *testing.T) {
Expand Down
Loading
Loading