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

enhance(pipeline): add ruledata options to various pipeline calls #301

Merged
merged 1 commit into from
Apr 8, 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 go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/buildkite/yaml v0.0.0-20230306222819-0e4e032d4835
github.com/coreos/go-semver v0.3.1
github.com/gin-gonic/gin v1.9.1
github.com/go-vela/server v0.23.4-0.20240401175144-f591935d2fc9
github.com/go-vela/server v0.23.4-0.20240405160933-fb31ea5a6e96
github.com/go-vela/types v0.23.4-0.20240402153726-f16c3e4cb5fb
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/google/go-cmp v0.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js=
github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-vela/server v0.23.4-0.20240401175144-f591935d2fc9 h1:R3TxguOk3JsIRoZn0oQBTLZRDIj4Xpeon+L/YJOF2Vw=
github.com/go-vela/server v0.23.4-0.20240401175144-f591935d2fc9/go.mod h1:Rbe6vgYe3gao8sBcALlhrM2YH4yu2cxJAFpWdDUbdZY=
github.com/go-vela/server v0.23.4-0.20240405160933-fb31ea5a6e96 h1:MI0NwjyqvRBXaTY8mlE5EeDTZ4k3zeaL6hJJBxgE7TA=
github.com/go-vela/server v0.23.4-0.20240405160933-fb31ea5a6e96/go.mod h1:Rbe6vgYe3gao8sBcALlhrM2YH4yu2cxJAFpWdDUbdZY=
github.com/go-vela/types v0.23.4-0.20240402153726-f16c3e4cb5fb h1:jHao/NNRswInMLEb0m1OJ84d1m/LGWMCmaeRqSDnWQY=
github.com/go-vela/types v0.23.4-0.20240402153726-f16c3e4cb5fb/go.mod h1:mEF9dLkk00rUXf/t39n2WvXZgJbxnPEEWy+DHqIlRUo=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
Expand Down
10 changes: 10 additions & 0 deletions vela/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ type PipelineOptions struct {
//
// Default: yaml
Output string `url:"output,omitempty"`

// Ruledata options
Branch string `url:"branch,omitempty"`
Comment string `url:"comment,omitempty"`
Event string `url:"event,omitempty"`
Repo string `url:"repo,omitempty"`
Status string `url:"status,omitempty"`
Tag string `url:"tag,omitempty"`
Target string `url:"target,omitempty"`
Path []string `url:"path,omitempty"`
}

// Get returns the provided pipeline.
Expand Down
86 changes: 85 additions & 1 deletion vela/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ func ExamplePipelineService_Compile() {
// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// create options for pipeline call
// create default options for pipeline call
opts := &PipelineOptions{
Output: "yaml", // default
}
Expand All @@ -543,6 +543,27 @@ func ExamplePipelineService_Compile() {
}

fmt.Printf("Received response code %d, for pipeline %+v", resp.StatusCode, pipeline)

// create ruledata options for pipeline call
opts = &PipelineOptions{
Output: "yaml", // default
Branch: "main",
Comment: "comment",
Event: "push",
Repo: "octocat",
Status: "success",
Tag: "v1.0.0",
Target: "production",
Path: []string{"path/to/file", "README.md"},
}

// compile a pipeline from a repo from the server
pipeline, resp, err = c.Pipeline.Compile("github", "octocat", "48afb5bdc41ad69bf22588491333f7cf71135163", opts)
if err != nil {
fmt.Println(err)
}

fmt.Printf("Received response code %d, for pipeline %+v", resp.StatusCode, pipeline)
}

func ExamplePipelineService_Expand() {
Expand All @@ -564,6 +585,27 @@ func ExamplePipelineService_Expand() {
}

fmt.Printf("Received response code %d, for pipeline %+v", resp.StatusCode, pipeline)

// create ruledata options for pipeline call
opts = &PipelineOptions{
Output: "yaml", // default
Branch: "main",
Comment: "comment",
Event: "push",
Repo: "octocat",
Status: "success",
Tag: "v1.0.0",
Target: "production",
Path: []string{"path/to/file", "README.md"},
}

// compile a pipeline from a repo from the server
pipeline, resp, err = c.Pipeline.Expand("github", "octocat", "48afb5bdc41ad69bf22588491333f7cf71135163", opts)
if err != nil {
fmt.Println(err)
}

fmt.Printf("Received response code %d, for pipeline %+v", resp.StatusCode, pipeline)
}

func ExamplePipelineService_Templates() {
Expand All @@ -585,6 +627,27 @@ func ExamplePipelineService_Templates() {
}

fmt.Printf("Received response code %d, for pipeline %+v", resp.StatusCode, pipeline)

// create ruledata options for pipeline call
opts = &PipelineOptions{
Output: "yaml", // default
Branch: "main",
Comment: "comment",
Event: "push",
Repo: "octocat",
Status: "success",
Tag: "v1.0.0",
Target: "production",
Path: []string{"path/to/file", "README.md"},
}

// compile a pipeline from a repo from the server
pipeline, resp, err = c.Pipeline.Templates("github", "octocat", "48afb5bdc41ad69bf22588491333f7cf71135163", opts)
if err != nil {
fmt.Println(err)
}

fmt.Printf("Received response code %d, for pipeline %+v", resp.StatusCode, pipeline)
}

func ExamplePipelineService_Validate() {
Expand All @@ -606,4 +669,25 @@ func ExamplePipelineService_Validate() {
}

fmt.Printf("Received response code %d, for pipeline %+v", resp.StatusCode, pipeline)

// create ruledata options for pipeline call
opts = &PipelineOptions{
Output: "yaml", // default
Branch: "main",
Comment: "comment",
Event: "push",
Repo: "octocat",
Status: "success",
Tag: "v1.0.0",
Target: "production",
Path: []string{"path/to/file", "README.md"},
}

// compile a pipeline from a repo from the server
pipeline, resp, err = c.Pipeline.Validate("github", "octocat", "48afb5bdc41ad69bf22588491333f7cf71135163", opts)
if err != nil {
fmt.Println(err)
}

fmt.Printf("Received response code %d, for pipeline %+v", resp.StatusCode, pipeline)
}
Loading