diff --git a/go.mod b/go.mod index 162197c..89cd51c 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +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.10.0 - github.com/go-vela/server v0.25.1-0.20241018183530-cb37db9087c5 - github.com/go-vela/types v0.25.1 + github.com/go-vela/server v0.25.1-0.20241022141112-a2b0d9146d65 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/google/go-cmp v0.6.0 github.com/google/go-querystring v1.1.0 diff --git a/go.sum b/go.sum index 02abb50..c442299 100644 --- a/go.sum +++ b/go.sum @@ -37,10 +37,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.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA= github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= -github.com/go-vela/server v0.25.1-0.20241018183530-cb37db9087c5 h1:rj2IBy+Gy16ePQTsQYmpCfBsJyYaQFPiqmDv8EZMXE8= -github.com/go-vela/server v0.25.1-0.20241018183530-cb37db9087c5/go.mod h1:/DmGHNzsjsBOStLzlGDIDGCmNztUgCdvHiuWmyafFs8= -github.com/go-vela/types v0.25.1 h1:DCPHv1+ouqldjfsjfcVTcm/Yyd0OwazIfxYyR+GwpMo= -github.com/go-vela/types v0.25.1/go.mod h1:5+MHUI9ZSY2Uz1cTJa64FWUv8jKzzUUq96UQTokGJzs= +github.com/go-vela/server v0.25.1-0.20241022141112-a2b0d9146d65 h1:BepNezNRDLfookgMn81U9WB0/aMBxkqot9w8nLPWNhU= +github.com/go-vela/server v0.25.1-0.20241022141112-a2b0d9146d65/go.mod h1:hdVkyyxnRtk+Vjs7nCnKEkwWmd9yVQUV5Akpt7BY6wg= github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= diff --git a/vela/admin.go b/vela/admin.go index 70ecb01..9306fb1 100644 --- a/vela/admin.go +++ b/vela/admin.go @@ -9,8 +9,6 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/api/types/settings" - "github.com/go-vela/types" - "github.com/go-vela/types/library" ) type ( @@ -101,7 +99,7 @@ func (svc *AdminBuildService) Update(b *api.Build) (*api.Build, *Response, error // set the API endpoint path we send the request to u := "/api/v1/admin/build" - // library Build type we want to return + // API Build type we want to return v := new(api.Build) // send request using client @@ -111,7 +109,7 @@ func (svc *AdminBuildService) Update(b *api.Build) (*api.Build, *Response, error } // Clean sets build resources older than a specified time to a proper canceled / finished state with the provided message. -func (svc *AdminCleanService) Clean(e *types.Error, opt *CleanOptions) (*string, *Response, error) { +func (svc *AdminCleanService) Clean(e *api.Error, opt *CleanOptions) (*string, *Response, error) { // set the API endpoint path we send the request to u := "/api/v1/admin/clean" @@ -152,7 +150,7 @@ func (svc *AdminDeploymentService) Update(d *api.Deployment) (*api.Deployment, * // set the API endpoint path we send the request to u := "/api/v1/admin/deployment" - // library Deployment type we want to return + // API Deployment type we want to return v := new(api.Deployment) // send request using client @@ -166,7 +164,7 @@ func (svc *AdminHookService) Update(h *api.Hook) (*api.Hook, *Response, error) { // set the API endpoint path we send the request to u := "/api/v1/admin/hook" - // library Hook type we want to return + // API Hook type we want to return v := new(api.Hook) // send request using client @@ -180,7 +178,7 @@ func (svc *AdminRepoService) Update(r *api.Repo) (*api.Repo, *Response, error) { // set the API endpoint path we send the request to u := "/api/v1/admin/repo" - // library Repo type we want to return + // API Repo type we want to return v := new(api.Repo) // send request using client @@ -194,7 +192,7 @@ func (svc *AdminSecretService) Update(s *api.Secret) (*api.Secret, *Response, er // set the API endpoint path we send the request to u := "/api/v1/admin/secret" - // library Secret type we want to return + // API Secret type we want to return v := new(api.Secret) // send request using client @@ -208,7 +206,7 @@ func (svc *AdminSvcService) Update(s *api.Service) (*api.Service, *Response, err // set the API endpoint path we send the request to u := "/api/v1/admin/service" - // library Service type we want to return + // API Service type we want to return v := new(api.Service) // send request using client @@ -222,7 +220,7 @@ func (svc *AdminStepService) Update(s *api.Step) (*api.Step, *Response, error) { // set the API endpoint path we send the request to u := "/api/v1/admin/step" - // library Step type we want to return + // API Step type we want to return v := new(api.Step) // send request using client @@ -236,7 +234,7 @@ func (svc *AdminUserService) Update(u *api.User) (*api.User, *Response, error) { // set the API endpoint path we send the request to url := "/api/v1/admin/user" - // library User type we want to return + // API User type we want to return v := new(api.User) // send request using client @@ -289,7 +287,7 @@ func (svc *AdminSettingsService) Restore() (*settings.Platform, *Response, error } // RegisterToken generates a worker registration token with the provided details. -func (svc *AdminWorkerService) RegisterToken(hostname string) (*library.Token, *Response, error) { +func (svc *AdminWorkerService) RegisterToken(hostname string) (*api.Token, *Response, error) { // validate input if strings.EqualFold(hostname, "") { return nil, nil, errors.New("bad request, no hostname provided") @@ -298,8 +296,8 @@ func (svc *AdminWorkerService) RegisterToken(hostname string) (*library.Token, * // set the API endpoint path we send the request to url := fmt.Sprintf("/api/v1/admin/workers/%s/register", hostname) - // library Token type we want to return - t := new(library.Token) + // API Token type we want to return + t := new(api.Token) // send request using client resp, err := svc.client.Call("POST", url, nil, t) diff --git a/vela/admin_test.go b/vela/admin_test.go index 14a8ac4..9194f56 100644 --- a/vela/admin_test.go +++ b/vela/admin_test.go @@ -16,8 +16,6 @@ import ( "github.com/go-vela/server/api/types/actions" "github.com/go-vela/server/api/types/settings" "github.com/go-vela/server/mock/server" - "github.com/go-vela/types" - "github.com/go-vela/types/library" ) func TestAdmin_Build_Update_200(t *testing.T) { @@ -64,7 +62,7 @@ func TestAdmin_Clean_200(t *testing.T) { want := server.CleanResourcesResp - req := types.Error{ + req := api.Error{ Message: String("msg"), } @@ -91,7 +89,7 @@ func TestAdmin_Clean_Error(t *testing.T) { s := httptest.NewServer(server.FakeHandler()) c, _ := NewClient(s.URL, "", nil) - req := types.Error{ + req := api.Error{ Message: String("msg"), } @@ -421,7 +419,7 @@ func TestAdmin_Worker_RegistrationToken_201(t *testing.T) { data := []byte(server.RegisterTokenResp) - var want *library.Token + var want *api.Token err := json.Unmarshal(data, &want) if err != nil { diff --git a/vela/authentication.go b/vela/authentication.go index d5e5c81..4e06a74 100644 --- a/vela/authentication.go +++ b/vela/authentication.go @@ -8,8 +8,8 @@ import ( "fmt" "net/http" - "github.com/go-vela/types/constants" - "github.com/go-vela/types/library" + api "github.com/go-vela/server/api/types" + "github.com/go-vela/server/constants" ) type AuthenticationType int @@ -94,7 +94,7 @@ func (svc *AuthenticationService) RefreshAccessToken(refreshToken string) (*Resp // set the API endpoint path we send the request to u := "/token-refresh" - v := new(library.Token) + v := new(api.Token) // building a custom request - // we can't use svc.client.NewRequest because @@ -139,7 +139,7 @@ func (svc *AuthenticationService) AuthenticateWithToken(token string) (string, * } // will hold access token - v := new(library.Token) + v := new(api.Token) // building a custom request - // we can't use svc.client.NewRequest because @@ -172,7 +172,7 @@ func (svc *AuthenticationService) ExchangeTokens(opt *OAuthExchangeOptions) (str u := "/authenticate" // will hold access token - v := new(library.Token) + v := new(api.Token) // check required arguments if len(opt.Code) == 0 || len(opt.State) == 0 { diff --git a/vela/authentication_test.go b/vela/authentication_test.go index fba95dd..740ec7f 100644 --- a/vela/authentication_test.go +++ b/vela/authentication_test.go @@ -10,8 +10,8 @@ import ( "github.com/gin-gonic/gin" + api "github.com/go-vela/server/api/types" "github.com/go-vela/server/mock/server" - "github.com/go-vela/types/library" ) func TestVela_Authentication_SetTokenAuth(t *testing.T) { @@ -135,7 +135,7 @@ func TestVela_Authentication_RefreshAccessToken(t *testing.T) { data := []byte(server.TokenRefreshResp) - var want library.Token + var want api.Token _ = json.Unmarshal(data, &want) // run test @@ -163,7 +163,7 @@ func TestVela_Authentication_AuthenticateWithToken(t *testing.T) { data := []byte(server.TokenRefreshResp) - var want library.Token + var want api.Token _ = json.Unmarshal(data, &want) // run test @@ -214,7 +214,7 @@ func TestVela_Authentication_ExchangeTokens(t *testing.T) { data := []byte(server.TokenRefreshResp) - var want library.Token + var want api.Token _ = json.Unmarshal(data, &want) // create options diff --git a/vela/build.go b/vela/build.go index 761eb2d..b73c82f 100644 --- a/vela/build.go +++ b/vela/build.go @@ -6,7 +6,6 @@ import ( "fmt" api "github.com/go-vela/server/api/types" - "github.com/go-vela/types/library" ) // BuildService handles retrieving builds from @@ -44,7 +43,7 @@ func (svc *BuildService) Get(org, repo string, build int) (*api.Build, *Response // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d", org, repo, build) - // library Build type we want to return + // API Build type we want to return v := new(api.Build) // send request using client @@ -54,12 +53,12 @@ func (svc *BuildService) Get(org, repo string, build int) (*api.Build, *Response } // GetBuildExecutable returns the executable for the provided build. -func (svc *BuildService) GetBuildExecutable(org, repo string, build int) (*library.BuildExecutable, *Response, error) { +func (svc *BuildService) GetBuildExecutable(org, repo string, build int) (*api.BuildExecutable, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/executable", org, repo, build) - // library Build type we want to return - v := new(library.BuildExecutable) + // API Build type we want to return + v := new(api.BuildExecutable) // send request using client resp, err := svc.client.Call("GET", u, nil, v) @@ -78,7 +77,7 @@ func (svc *BuildService) GetAll(org, repo string, opt *BuildListOptions) (*[]api return nil, nil, err } - // slice library Build type we want to return + // slice API Build type we want to return v := new([]api.Build) // send request using client @@ -88,7 +87,7 @@ func (svc *BuildService) GetAll(org, repo string, opt *BuildListOptions) (*[]api } // GetLogs returns the provided build logs. -func (svc *BuildService) GetLogs(org, repo string, build int, opt *ListOptions) (*[]library.Log, *Response, error) { +func (svc *BuildService) GetLogs(org, repo string, build int, opt *ListOptions) (*[]api.Log, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/logs", org, repo, build) @@ -99,7 +98,7 @@ func (svc *BuildService) GetLogs(org, repo string, build int, opt *ListOptions) } // slice database Log type we want to return - v := new([]library.Log) + v := new([]api.Log) // send request using client resp, err := svc.client.Call("GET", u, nil, v) @@ -112,7 +111,7 @@ func (svc *BuildService) Add(b *api.Build) (*api.Build, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds", b.GetRepo().GetOrg(), b.GetRepo().GetName()) - // library Build type we want to return + // API Build type we want to return v := new(api.Build) // send request using client @@ -126,7 +125,7 @@ func (svc *BuildService) Update(b *api.Build) (*api.Build, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d", b.GetRepo().GetOrg(), b.GetRepo().GetName(), b.GetNumber()) - // library Build type we want to return + // API Build type we want to return v := new(api.Build) // send request using client @@ -154,7 +153,7 @@ func (svc *BuildService) Restart(org, repo string, build int) (*api.Build, *Resp // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d", org, repo, build) - // library Build type we want to return + // API Build type we want to return v := new(api.Build) // send request using client @@ -168,7 +167,7 @@ func (svc *BuildService) Cancel(org, repo string, build int) (*api.Build, *Respo // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/cancel", org, repo, build) - // library Build type we want to return + // API Build type we want to return v := new(api.Build) // send request using client @@ -186,12 +185,12 @@ func (svc *BuildService) Approve(org, repo string, build int) (*Response, error) } // GetBuildToken returns an auth token for updating build resources. -func (svc *BuildService) GetBuildToken(org, repo string, build int) (*library.Token, *Response, error) { +func (svc *BuildService) GetBuildToken(org, repo string, build int) (*api.Token, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/token", org, repo, build) - // library Token type we want to return - t := new(library.Token) + // API Token type we want to return + t := new(api.Token) // send request using client resp, err := svc.client.Call("GET", u, nil, t) @@ -200,7 +199,7 @@ func (svc *BuildService) GetBuildToken(org, repo string, build int) (*library.To } // GetIDRequestToken returns an id request token for integrating with build OIDC. -func (svc *BuildService) GetIDRequestToken(org, repo string, build int, opt *RequestTokenOptions) (*library.Token, *Response, error) { +func (svc *BuildService) GetIDRequestToken(org, repo string, build int, opt *RequestTokenOptions) (*api.Token, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/id_request_token", org, repo, build) @@ -210,8 +209,8 @@ func (svc *BuildService) GetIDRequestToken(org, repo string, build int, opt *Req return nil, nil, err } - // library Token type we want to return - t := new(library.Token) + // API Token type we want to return + t := new(api.Token) // send request using client resp, err := svc.client.Call("GET", u, nil, t) @@ -220,7 +219,7 @@ func (svc *BuildService) GetIDRequestToken(org, repo string, build int, opt *Req } // GetIDToken returns an ID token corresponding to the request token during a build. -func (svc *BuildService) GetIDToken(org, repo string, build int, opt *IDTokenOptions) (*library.Token, *Response, error) { +func (svc *BuildService) GetIDToken(org, repo string, build int, opt *IDTokenOptions) (*api.Token, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/id_token", org, repo, build) @@ -230,8 +229,8 @@ func (svc *BuildService) GetIDToken(org, repo string, build int, opt *IDTokenOpt return nil, nil, err } - // library Token type we want to return - t := new(library.Token) + // API Token type we want to return + t := new(api.Token) // send request using client resp, err := svc.client.Call("GET", u, nil, t) diff --git a/vela/build_test.go b/vela/build_test.go index 41e5ad0..40eddde 100644 --- a/vela/build_test.go +++ b/vela/build_test.go @@ -15,7 +15,6 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/mock/server" - "github.com/go-vela/types/library" ) func TestBuild_Get_200(t *testing.T) { @@ -80,7 +79,7 @@ func TestBuildExecutable_Get_200(t *testing.T) { data := []byte(server.BuildExecutableResp) - var want library.BuildExecutable + var want api.BuildExecutable _ = json.Unmarshal(data, &want) // run test @@ -106,7 +105,7 @@ func TestBuildExecutable_Get_500(t *testing.T) { s := httptest.NewServer(server.FakeHandler()) c, _ := NewClient(s.URL, "", nil) - want := library.BuildExecutable{} + want := api.BuildExecutable{} // run test got, resp, err := c.Build.GetBuildExecutable("github", "octocat", 0) @@ -161,7 +160,7 @@ func TestBuild_GetLogs_200(t *testing.T) { data := []byte(server.BuildLogsResp) - var want []library.Log + var want []api.Log _ = json.Unmarshal(data, &want) // run test @@ -187,7 +186,7 @@ func TestBuild_GetLogs_404(t *testing.T) { s := httptest.NewServer(server.FakeHandler()) c, _ := NewClient(s.URL, "", nil) - want := []library.Log{} + want := []api.Log{} // run test got, resp, err := c.Build.GetLogs("github", "octocat", 0, nil) @@ -516,7 +515,7 @@ func TestBuild_GetBuildToken_200(t *testing.T) { data := []byte(server.BuildTokenResp) - var want library.Token + var want api.Token _ = json.Unmarshal(data, &want) // run test @@ -542,7 +541,7 @@ func TestBuild_GetBuildToken_404(t *testing.T) { s := httptest.NewServer(server.FakeHandler()) c, _ := NewClient(s.URL, "", nil) - var want library.Token + var want api.Token // run test got, resp, err := c.Build.GetBuildToken("github", "octocat", 0) @@ -567,7 +566,7 @@ func TestBuild_GetBuildToken_400(t *testing.T) { s := httptest.NewServer(server.FakeHandler()) c, _ := NewClient(s.URL, "", nil) - var want library.Token + var want api.Token // run test got, resp, err := c.Build.GetBuildToken("github", "octocat", 2) @@ -594,7 +593,7 @@ func TestBuild_GetIDRequestToken_200(t *testing.T) { data := []byte(server.IDTokenRequestTokenResp) - var want library.Token + var want api.Token _ = json.Unmarshal(data, &want) // run test @@ -620,7 +619,7 @@ func TestBuild_GetIDRequestToken_400(t *testing.T) { s := httptest.NewServer(server.FakeHandler()) c, _ := NewClient(s.URL, "", nil) - var want library.Token + var want api.Token // run test got, resp, err := c.Build.GetIDRequestToken("github", "octocat", 0, nil) @@ -647,7 +646,7 @@ func TestBuild_GetIDToken_200(t *testing.T) { data := []byte(server.IDTokenResp) - var want library.Token + var want api.Token _ = json.Unmarshal(data, &want) // run test @@ -673,7 +672,7 @@ func TestBuild_GetIDToken_400(t *testing.T) { s := httptest.NewServer(server.FakeHandler()) c, _ := NewClient(s.URL, "", nil) - var want library.Token + var want api.Token // run test got, resp, err := c.Build.GetIDToken("github", "octocat", 0, nil) diff --git a/vela/client.go b/vela/client.go index 1bd5fa7..6c61a32 100644 --- a/vela/client.go +++ b/vela/client.go @@ -19,7 +19,7 @@ import ( "github.com/sirupsen/logrus" "github.com/go-vela/sdk-go/version" - "github.com/go-vela/types" + api "github.com/go-vela/server/api/types" ) const ( @@ -538,7 +538,7 @@ func CheckResponse(r *http.Response) error { } // custom response type - resp := types.Error{} + resp := api.Error{} // read all bytes from response body b, _ := io.ReadAll(r.Body) diff --git a/vela/dashboard.go b/vela/dashboard.go index bd26b94..5360146 100644 --- a/vela/dashboard.go +++ b/vela/dashboard.go @@ -31,7 +31,7 @@ func (svc *DashboardService) GetAllUser() (*[]api.DashCard, *Response, error) { // set the API endpoint path we send the request to u := "/api/v1/user/dashboards" - // slice library Dashboard type we want to return + // slice API Dashboard type we want to return v := new([]api.DashCard) // send request using client diff --git a/vela/deployment.go b/vela/deployment.go index 7ce2de6..dbd6156 100644 --- a/vela/deployment.go +++ b/vela/deployment.go @@ -17,7 +17,7 @@ func (svc *DeploymentService) Get(org, repo string, deployment int) (*api.Deploy // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/deployments/%s/%s/%d", org, repo, deployment) - // library Deployment type we want to return + // API Deployment type we want to return v := new(api.Deployment) // send request using client @@ -37,7 +37,7 @@ func (svc *DeploymentService) GetAll(org, repo string, opt *ListOptions) (*[]api return nil, nil, err } - // slice library Deployment type we want to return + // slice API Deployment type we want to return v := new([]api.Deployment) // send request using client @@ -51,7 +51,7 @@ func (svc *DeploymentService) Add(org, repo string, d *api.Deployment) (*api.Dep // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/deployments/%s/%s", org, repo) - // library Deployment type we want to return + // API Deployment type we want to return v := new(api.Deployment) // send request using client diff --git a/vela/hook.go b/vela/hook.go index 5cf1f1c..2f38d64 100644 --- a/vela/hook.go +++ b/vela/hook.go @@ -17,7 +17,7 @@ func (svc *HookService) Get(org, repo string, hook int) (*api.Hook, *Response, e // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/hooks/%s/%s/%d", org, repo, hook) - // library Hook type we want to return + // API Hook type we want to return v := new(api.Hook) // send request using client @@ -37,7 +37,7 @@ func (svc *HookService) GetAll(org, repo string, opt *ListOptions) (*[]api.Hook, return nil, nil, err } - // slice library Hook type we want to return + // slice API Hook type we want to return v := new([]api.Hook) // send request using client @@ -51,7 +51,7 @@ func (svc *HookService) Add(org, repo string, h *api.Hook) (*api.Hook, *Response // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/hooks/%s/%s", org, repo) - // library Hook type we want to return + // API Hook type we want to return v := new(api.Hook) // send request using client @@ -65,7 +65,7 @@ func (svc *HookService) Update(org, repo string, h *api.Hook) (*api.Hook, *Respo // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/hooks/%s/%s/%d", org, repo, h.GetNumber()) - // library Hook type we want to return + // API Hook type we want to return v := new(api.Hook) // send request using client diff --git a/vela/log.go b/vela/log.go index cd892f6..34a83a5 100644 --- a/vela/log.go +++ b/vela/log.go @@ -5,7 +5,7 @@ package vela import ( "fmt" - "github.com/go-vela/types/library" + api "github.com/go-vela/server/api/types" ) // LogService handles retrieving logs for builds @@ -13,12 +13,12 @@ import ( type LogService service // GetService returns the provided service log. -func (svc *LogService) GetService(org, repo string, build, service int) (*library.Log, *Response, error) { +func (svc *LogService) GetService(org, repo string, build, service int) (*api.Log, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services/%d/logs", org, repo, build, service) - // library Log type we want to return - v := new(library.Log) + // API Log type we want to return + v := new(api.Log) // send request using client resp, err := svc.client.Call("GET", u, nil, v) @@ -27,7 +27,7 @@ func (svc *LogService) GetService(org, repo string, build, service int) (*librar } // AddService constructs a service log with the provided details. -func (svc *LogService) AddService(org, repo string, build, service int, l *library.Log) (*Response, error) { +func (svc *LogService) AddService(org, repo string, build, service int, l *api.Log) (*Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services/%d/logs", org, repo, build, service) @@ -38,7 +38,7 @@ func (svc *LogService) AddService(org, repo string, build, service int, l *libra } // UpdateService modifies a service log with the provided details. -func (svc *LogService) UpdateService(org, repo string, build, service int, l *library.Log) (*Response, error) { +func (svc *LogService) UpdateService(org, repo string, build, service int, l *api.Log) (*Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services/%d/logs", org, repo, build, service) @@ -63,12 +63,12 @@ func (svc *LogService) RemoveService(org, repo string, build, service int) (*str } // GetStep returns the provided step log. -func (svc *LogService) GetStep(org, repo string, build, step int) (*library.Log, *Response, error) { +func (svc *LogService) GetStep(org, repo string, build, step int) (*api.Log, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps/%d/logs", org, repo, build, step) - // library Log type we want to return - v := new(library.Log) + // API Log type we want to return + v := new(api.Log) // send request using client resp, err := svc.client.Call("GET", u, nil, v) @@ -77,7 +77,7 @@ func (svc *LogService) GetStep(org, repo string, build, step int) (*library.Log, } // AddStep constructs a step log with the provided details. -func (svc *LogService) AddStep(org, repo string, build, step int, l *library.Log) (*Response, error) { +func (svc *LogService) AddStep(org, repo string, build, step int, l *api.Log) (*Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps/%d/logs", org, repo, build, step) @@ -88,7 +88,7 @@ func (svc *LogService) AddStep(org, repo string, build, step int, l *library.Log } // UpdateStep modifies a step log with the provided details. -func (svc *LogService) UpdateStep(org, repo string, build, step int, l *library.Log) (*Response, error) { +func (svc *LogService) UpdateStep(org, repo string, build, step int, l *api.Log) (*Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps/%d/logs", org, repo, build, step) diff --git a/vela/log_test.go b/vela/log_test.go index 972845b..9fe0f61 100644 --- a/vela/log_test.go +++ b/vela/log_test.go @@ -12,8 +12,8 @@ import ( "github.com/gin-gonic/gin" + api "github.com/go-vela/server/api/types" "github.com/go-vela/server/mock/server" - "github.com/go-vela/types/library" ) func TestLog_GetService_200(t *testing.T) { @@ -25,7 +25,7 @@ func TestLog_GetService_200(t *testing.T) { data := []byte(server.LogResp) - var want library.Log + var want api.Log _ = json.Unmarshal(data, &want) // run test @@ -51,7 +51,7 @@ func TestLog_GetService_404(t *testing.T) { s := httptest.NewServer(server.FakeHandler()) c, _ := NewClient(s.URL, "", nil) - want := library.Log{} + want := api.Log{} // run test got, resp, err := c.Log.GetService("github", "octocat", 1, 0) @@ -78,10 +78,10 @@ func TestLog_AddService_201(t *testing.T) { data := []byte(server.LogResp) - var want library.Log + var want api.Log _ = json.Unmarshal(data, &want) - req := library.Log{ + req := api.Log{ Data: Bytes([]byte("Hello, World")), } @@ -104,7 +104,7 @@ func TestLog_UpdateService_200(t *testing.T) { s := httptest.NewServer(server.FakeHandler()) c, _ := NewClient(s.URL, "", nil) - req := library.Log{ + req := api.Log{ Data: Bytes([]byte("Hello, World Manny")), } @@ -127,7 +127,7 @@ func TestLog_UpdateService_404(t *testing.T) { s := httptest.NewServer(server.FakeHandler()) c, _ := NewClient(s.URL, "", nil) - req := library.Log{ + req := api.Log{ Data: Bytes([]byte("Hello, World Manny")), } @@ -190,7 +190,7 @@ func TestLog_GetStep_200(t *testing.T) { data := []byte(server.LogResp) - var want library.Log + var want api.Log _ = json.Unmarshal(data, &want) // run test @@ -216,7 +216,7 @@ func TestLog_GetStep_404(t *testing.T) { s := httptest.NewServer(server.FakeHandler()) c, _ := NewClient(s.URL, "", nil) - want := library.Log{} + want := api.Log{} // run test got, resp, err := c.Log.GetStep("github", "octocat", 1, 0) @@ -243,10 +243,10 @@ func TestLog_AddStep_201(t *testing.T) { data := []byte(server.LogResp) - var want library.Log + var want api.Log _ = json.Unmarshal(data, &want) - req := library.Log{ + req := api.Log{ Data: Bytes([]byte("Hello, World")), } @@ -269,7 +269,7 @@ func TestLog_UpdateStep_200(t *testing.T) { s := httptest.NewServer(server.FakeHandler()) c, _ := NewClient(s.URL, "", nil) - req := library.Log{ + req := api.Log{ Data: Bytes([]byte("Hello, World Manny")), } @@ -292,7 +292,7 @@ func TestLog_UpdateStep_404(t *testing.T) { s := httptest.NewServer(server.FakeHandler()) c, _ := NewClient(s.URL, "", nil) - req := library.Log{ + req := api.Log{ Data: Bytes([]byte("Hello, World Manny")), } @@ -369,7 +369,7 @@ func ExampleLogService_AddService() { // Set new token in existing client c.Authentication.SetPersonalAccessTokenAuth("token") - req := library.Log{ + req := api.Log{ Data: Bytes([]byte("Hello World")), } @@ -389,7 +389,7 @@ func ExampleLogService_UpdateService() { // Set new token in existing client c.Authentication.SetPersonalAccessTokenAuth("token") - req := library.Log{ + req := api.Log{ Data: Bytes([]byte("Hello World")), } @@ -441,7 +441,7 @@ func ExampleLogService_AddStep() { // Set new token in existing client c.Authentication.SetPersonalAccessTokenAuth("token") - req := library.Log{ + req := api.Log{ Data: Bytes([]byte("Hello World")), } @@ -461,7 +461,7 @@ func ExampleLogService_UpdateStep() { // Set new token in existing client c.Authentication.SetPersonalAccessTokenAuth("token") - req := library.Log{ + req := api.Log{ Data: Bytes([]byte("Hello World")), } diff --git a/vela/pipeline.go b/vela/pipeline.go index 32c6816..5b43021 100644 --- a/vela/pipeline.go +++ b/vela/pipeline.go @@ -39,7 +39,7 @@ func (svc *PipelineService) Get(org, repo, ref string) (*api.Pipeline, *Response // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/pipelines/%s/%s/%s", org, repo, ref) - // library Pipeline type we want to return + // API Pipeline type we want to return v := new(api.Pipeline) // send request using client @@ -59,7 +59,7 @@ func (svc *PipelineService) GetAll(org, repo string, opt *ListOptions) (*[]api.P return nil, nil, err } - // slice library Pipeline type we want to return + // slice API Pipeline type we want to return v := new([]api.Pipeline) // send request using client @@ -73,7 +73,7 @@ func (svc *PipelineService) Add(org, repo string, h *api.Pipeline) (*api.Pipelin // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/pipelines/%s/%s", org, repo) - // library Pipeline type we want to return + // API Pipeline type we want to return v := new(api.Pipeline) // send request using client @@ -87,7 +87,7 @@ func (svc *PipelineService) Update(org, repo string, p *api.Pipeline) (*api.Pipe // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/pipelines/%s/%s/%s", org, repo, p.GetCommit()) - // library Pipeline type we want to return + // API Pipeline type we want to return v := new(api.Pipeline) // send request using client diff --git a/vela/queue.go b/vela/queue.go index 6c2c442..fdd8b95 100644 --- a/vela/queue.go +++ b/vela/queue.go @@ -2,19 +2,21 @@ package vela -import "github.com/go-vela/types/library" +import ( + api "github.com/go-vela/server/api/types" +) // QueueService handles retrieving queue info from // the server methods of the Vela API. type QueueService service // GetInfo fetches queue info, primarily used during worker onboarding. -func (qvc *QueueService) GetInfo() (*library.QueueInfo, *Response, error) { +func (qvc *QueueService) GetInfo() (*api.QueueInfo, *Response, error) { // set the API endpoint path we send the request to url := "/api/v1/queue/info" - // library QueueInfo type we want to return - t := new(library.QueueInfo) + // API QueueInfo type we want to return + t := new(api.QueueInfo) // send request using client resp, err := qvc.client.Call("GET", url, nil, t) diff --git a/vela/queue_test.go b/vela/queue_test.go index 689118b..73af553 100644 --- a/vela/queue_test.go +++ b/vela/queue_test.go @@ -11,8 +11,8 @@ import ( "github.com/gin-gonic/gin" "github.com/google/go-cmp/cmp" + api "github.com/go-vela/server/api/types" "github.com/go-vela/server/mock/server" - "github.com/go-vela/types/library" ) func TestQueue_GetInfo_200(t *testing.T) { @@ -23,7 +23,7 @@ func TestQueue_GetInfo_200(t *testing.T) { c.Authentication.SetPersonalAccessTokenAuth("token") data := []byte(server.QueueInfoResp) - var want *library.QueueInfo + var want *api.QueueInfo err := json.Unmarshal(data, &want) if err != nil { diff --git a/vela/repo.go b/vela/repo.go index f9d4a56..04162f3 100644 --- a/vela/repo.go +++ b/vela/repo.go @@ -17,7 +17,7 @@ func (svc *RepoService) Get(org, repo string) (*api.Repo, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s", org, repo) - // library Repo type we want to return + // API Repo type we want to return v := new(api.Repo) // send request using client @@ -37,7 +37,7 @@ func (svc *RepoService) GetAll(opt *ListOptions) (*[]api.Repo, *Response, error) return nil, nil, err } - // slice library Repo type we want to return + // slice API Repo type we want to return v := new([]api.Repo) // send request using client @@ -51,7 +51,7 @@ func (svc *RepoService) Add(r *api.Repo) (*api.Repo, *Response, error) { // set the API endpoint path we send the request to u := "/api/v1/repos" - // library Repo type we want to return + // API Repo type we want to return v := new(api.Repo) // send request using client @@ -65,7 +65,7 @@ func (svc *RepoService) Update(org, repo string, r *api.Repo) (*api.Repo, *Respo // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s", org, repo) - // library Repo type we want to return + // API Repo type we want to return v := new(api.Repo) // send request using client diff --git a/vela/schedule.go b/vela/schedule.go index ce6b01f..3851df9 100644 --- a/vela/schedule.go +++ b/vela/schedule.go @@ -16,7 +16,7 @@ func (svc *ScheduleService) Get(org, repo, schedule string) (*api.Schedule, *Res // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/schedules/%s/%s/%s", org, repo, schedule) - // library Schedule type we want to return + // API Schedule type we want to return v := new(api.Schedule) // send request using client @@ -36,7 +36,7 @@ func (svc *ScheduleService) GetAll(org, repo string, opt *ListOptions) (*[]api.S return nil, nil, err } - // slice library Schedule type we want to return + // slice API Schedule type we want to return v := new([]api.Schedule) // send request using client @@ -50,7 +50,7 @@ func (svc *ScheduleService) Add(org, repo string, s *api.Schedule) (*api.Schedul // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/schedules/%s/%s", org, repo) - // library Schedule type we want to return + // API Schedule type we want to return v := new(api.Schedule) // send request using client @@ -64,7 +64,7 @@ func (svc *ScheduleService) Update(org, repo string, s *api.Schedule) (*api.Sche // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/schedules/%s/%s/%s", org, repo, s.GetName()) - // library Schedule type we want to return + // API Schedule type we want to return v := new(api.Schedule) // send request using client diff --git a/vela/secret.go b/vela/secret.go index 77d8f4f..28c161e 100644 --- a/vela/secret.go +++ b/vela/secret.go @@ -17,7 +17,7 @@ func (svc *SecretService) Get(engine, sType, org, name, secret string) (*api.Sec // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/secrets/%s/%s/%s/%s/%s", engine, sType, org, name, secret) - // library Secret type we want to return + // API Secret type we want to return v := new(api.Secret) // send request using client @@ -37,7 +37,7 @@ func (svc *SecretService) GetAll(engine, sType, org, name string, opt *ListOptio return nil, nil, err } - // slice library Secret type we want to return + // slice API Secret type we want to return v := new([]api.Secret) // send request using client @@ -51,7 +51,7 @@ func (svc *SecretService) Add(engine, sType, org, name string, s *api.Secret) (* // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/secrets/%s/%s/%s/%s", engine, sType, org, name) - // library Secret type we want to return + // API Secret type we want to return v := new(api.Secret) // send request using client @@ -65,7 +65,7 @@ func (svc *SecretService) Update(engine, sType, org, name string, s *api.Secret) // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/secrets/%s/%s/%s/%s/%s", engine, sType, org, name, s.GetName()) - // library Secret type we want to return + // API Secret type we want to return v := new(api.Secret) // send request using client diff --git a/vela/service.go b/vela/service.go index fc57ed6..528af4b 100644 --- a/vela/service.go +++ b/vela/service.go @@ -18,7 +18,7 @@ func (svc *SvcService) Get(org, repo string, build, service int) (*api.Service, // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services/%d", org, repo, build, service) - // library Service type we want to return + // API Service type we want to return v := new(api.Service) // send request using client @@ -38,7 +38,7 @@ func (svc *SvcService) GetAll(org, repo string, build int, opt *ListOptions) (*[ return nil, nil, err } - // slice library Service type we want to return + // slice API Service type we want to return v := new([]api.Service) // send request using client @@ -52,7 +52,7 @@ func (svc *SvcService) Add(org, repo string, build int, s *api.Service) (*api.Se // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services", org, repo, build) - // library Service type we want to return + // API Service type we want to return v := new(api.Service) // send request using client @@ -66,7 +66,7 @@ func (svc *SvcService) Update(org, repo string, build int, s *api.Service) (*api // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services/%d", org, repo, build, s.GetNumber()) - // library Service type we want to return + // API Service type we want to return v := new(api.Service) // send request using client diff --git a/vela/step.go b/vela/step.go index 4a83e31..599bc99 100644 --- a/vela/step.go +++ b/vela/step.go @@ -18,7 +18,7 @@ func (svc *StepService) Get(org, repo string, build, step int) (*api.Step, *Resp // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps/%d", org, repo, build, step) - // library Step type we want to return + // API Step type we want to return v := new(api.Step) // send request using client @@ -38,7 +38,7 @@ func (svc *StepService) GetAll(org, repo string, build int, opt *ListOptions) (* return nil, nil, err } - // slice library Step type we want to return + // slice API Step type we want to return v := new([]api.Step) // send request using client @@ -52,7 +52,7 @@ func (svc *StepService) Add(org, repo string, build int, s *api.Step) (*api.Step // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps", org, repo, build) - // library Step type we want to return + // API Step type we want to return v := new(api.Step) // send request using client @@ -66,7 +66,7 @@ func (svc *StepService) Update(org, repo string, build int, s *api.Step) (*api.S // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps/%d", org, repo, build, s.GetNumber()) - // library Step type we want to return + // API Step type we want to return v := new(api.Step) // send request using client diff --git a/vela/worker.go b/vela/worker.go index 2350e38..96ac187 100644 --- a/vela/worker.go +++ b/vela/worker.go @@ -6,7 +6,6 @@ import ( "fmt" api "github.com/go-vela/server/api/types" - "github.com/go-vela/types/library" ) // WorkerService handles retrieving workers from @@ -46,7 +45,7 @@ func (svc *WorkerService) GetAll(opt *WorkerListOptions) (*[]api.Worker, *Respon return nil, nil, err } - // slice library Worker type we want to return + // slice API Worker type we want to return v := new([]api.Worker) // send request using client @@ -56,12 +55,12 @@ func (svc *WorkerService) GetAll(opt *WorkerListOptions) (*[]api.Worker, *Respon } // Add constructs a worker with the provided details. -func (svc *WorkerService) Add(w *api.Worker) (*library.Token, *Response, error) { +func (svc *WorkerService) Add(w *api.Worker) (*api.Token, *Response, error) { // set the API endpoint path we send the request to u := "/api/v1/workers" - // library Token type we want to return - v := new(library.Token) + // API Token type we want to return + v := new(api.Token) // send request using client resp, err := svc.client.Call("POST", u, w, v) @@ -70,12 +69,12 @@ func (svc *WorkerService) Add(w *api.Worker) (*library.Token, *Response, error) } // RefreshAuth exchanges a worker token for a new one. -func (svc *WorkerService) RefreshAuth(worker string) (*library.Token, *Response, error) { +func (svc *WorkerService) RefreshAuth(worker string) (*api.Token, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/workers/%s/refresh", worker) - // library Token type we want to return - v := new(library.Token) + // API Token type we want to return + v := new(api.Token) // send request using client resp, err := svc.client.Call("POST", u, nil, v) @@ -88,7 +87,7 @@ func (svc *WorkerService) Update(worker string, w *api.Worker) (*api.Worker, *Re // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/workers/%s", worker) - // library Worker type we want to return + // API Worker type we want to return v := new(api.Worker) // send request using client diff --git a/vela/worker_test.go b/vela/worker_test.go index f4d3169..c05cb3f 100644 --- a/vela/worker_test.go +++ b/vela/worker_test.go @@ -14,7 +14,6 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/mock/server" - "github.com/go-vela/types/library" ) func TestWorker_Get_200(t *testing.T) { @@ -107,7 +106,7 @@ func TestWorker_Add_201(t *testing.T) { data := []byte(server.AddWorkerResp) - var want library.Token + var want api.Token _ = json.Unmarshal(data, &want) req := api.Worker{ @@ -148,7 +147,7 @@ func TestWorker_RefreshAuth_200(t *testing.T) { data := []byte(server.AddWorkerResp) - var want library.Token + var want api.Token _ = json.Unmarshal(data, &want) worker := "worker_1"