From b71dfc9eafbe0268e8117b616db9259847f60ce6 Mon Sep 17 00:00:00 2001 From: Jordan Brockopp Date: Fri, 8 Nov 2019 22:08:56 -0600 Subject: [PATCH 1/4] rename service receivers (s -> svc) --- vela/authentication.go | 14 +++++++------- vela/build.go | 28 ++++++++++++++-------------- vela/log.go | 32 ++++++++++++++++---------------- vela/login.go | 4 ++-- vela/repo.go | 24 ++++++++++++------------ vela/secret.go | 20 ++++++++++---------- vela/service.go | 20 ++++++++++---------- vela/step.go | 20 ++++++++++---------- 8 files changed, 81 insertions(+), 81 deletions(-) diff --git a/vela/authentication.go b/vela/authentication.go index 66e6b95..e467d3e 100644 --- a/vela/authentication.go +++ b/vela/authentication.go @@ -19,17 +19,17 @@ type AuthenticationService struct { } // SetTokenAuth sets the authentication type as OAuth Token. -func (s *AuthenticationService) SetTokenAuth(token string) { - s.secret = String(token) - s.authType = AuthenticationToken +func (svc *AuthenticationService) SetTokenAuth(token string) { + svc.secret = String(token) + svc.authType = AuthenticationToken } // HasAuth checks if the authentication type is set. -func (s *AuthenticationService) HasAuth() bool { - return s.authType > 0 +func (svc *AuthenticationService) HasAuth() bool { + return svc.authType > 0 } // HasTokenAuth checks if the authentication type is OAuth Token. -func (s *AuthenticationService) HasTokenAuth() bool { - return s.authType == AuthenticationToken +func (svc *AuthenticationService) HasTokenAuth() bool { + return svc.authType == AuthenticationToken } diff --git a/vela/build.go b/vela/build.go index c46d7b2..d18b317 100644 --- a/vela/build.go +++ b/vela/build.go @@ -16,7 +16,7 @@ import ( type BuildService service // Get returns the provided build. -func (s *BuildService) Get(org, repo string, target int) (*library.Build, *Response, error) { +func (svc *BuildService) Get(org, repo string, target int) (*library.Build, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d", org, repo, target) @@ -24,12 +24,12 @@ func (s *BuildService) Get(org, repo string, target int) (*library.Build, *Respo v := new(library.Build) // send request using client - resp, err := s.client.Call("GET", u, nil, v) + resp, err := svc.client.Call("GET", u, nil, v) return v, resp, err } // GetAll returns a list of all builds. -func (s *BuildService) GetAll(org, repo string) (*[]library.Build, *Response, error) { +func (svc *BuildService) GetAll(org, repo string) (*[]library.Build, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds", org, repo) @@ -37,12 +37,12 @@ func (s *BuildService) GetAll(org, repo string) (*[]library.Build, *Response, er v := new([]library.Build) // send request using client - resp, err := s.client.Call("GET", u, nil, v) + resp, err := svc.client.Call("GET", u, nil, v) return v, resp, err } // GetLogs returns the provided build logs. -func (s *BuildService) GetLogs(org, repo string, target int) (*[]database.Log, *Response, error) { +func (svc *BuildService) GetLogs(org, repo string, target int) (*[]database.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, target) @@ -50,12 +50,12 @@ func (s *BuildService) GetLogs(org, repo string, target int) (*[]database.Log, * v := new([]database.Log) // send request using client - resp, err := s.client.Call("GET", u, nil, v) + resp, err := svc.client.Call("GET", u, nil, v) return v, resp, err } // Add constructs a build with the provided details. -func (s *BuildService) Add(org, repo string, target *library.Build) (*library.Build, *Response, error) { +func (svc *BuildService) Add(org, repo string, target *library.Build) (*library.Build, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds", org, repo) @@ -63,12 +63,12 @@ func (s *BuildService) Add(org, repo string, target *library.Build) (*library.Bu v := new(library.Build) // send request using client - resp, err := s.client.Call("POST", u, target, v) + resp, err := svc.client.Call("POST", u, target, v) return v, resp, err } // Update modifies a build with the provided details. -func (s *BuildService) Update(org, repo string, target *library.Build) (*library.Build, *Response, error) { +func (svc *BuildService) Update(org, repo string, target *library.Build) (*library.Build, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d", org, repo, *target.Number) @@ -76,12 +76,12 @@ func (s *BuildService) Update(org, repo string, target *library.Build) (*library v := new(library.Build) // send request using client - resp, err := s.client.Call("PUT", u, target, v) + resp, err := svc.client.Call("PUT", u, target, v) return v, resp, err } // Remove deletes the provided build. -func (s *BuildService) Remove(org, repo string, target int) (*string, *Response, error) { +func (svc *BuildService) Remove(org, repo string, target int) (*string, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d", org, repo, target) @@ -89,12 +89,12 @@ func (s *BuildService) Remove(org, repo string, target int) (*string, *Response, v := new(string) // send request using client - resp, err := s.client.Call("DELETE", u, nil, v) + resp, err := svc.client.Call("DELETE", u, nil, v) return v, resp, err } // Restart takes the build provided and restarts it -func (s *BuildService) Restart(org, repo string, target int) (*library.Build, *Response, error) { +func (svc *BuildService) Restart(org, repo string, target int) (*library.Build, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d", org, repo, target) @@ -102,6 +102,6 @@ func (s *BuildService) Restart(org, repo string, target int) (*library.Build, *R v := new(library.Build) // send request using client - resp, err := s.client.Call("POST", u, nil, v) + resp, err := svc.client.Call("POST", u, nil, v) return v, resp, err } diff --git a/vela/log.go b/vela/log.go index bcca6bd..a4c243b 100644 --- a/vela/log.go +++ b/vela/log.go @@ -15,7 +15,7 @@ import ( type LogService service // GetService returns the provided service log. -func (s *LogService) GetService(org, repo string, buildNum, serviceNum int) (*library.Log, *Response, error) { +func (svc *LogService) GetService(org, repo string, buildNum, serviceNum int) (*library.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, buildNum, serviceNum) @@ -23,12 +23,12 @@ func (s *LogService) GetService(org, repo string, buildNum, serviceNum int) (*li v := new(library.Log) // send request using client - resp, err := s.client.Call("GET", u, nil, v) + resp, err := svc.client.Call("GET", u, nil, v) return v, resp, err } // AddService constructs a service log with the provided details. -func (s *LogService) AddService(org, repo string, buildNum, serviceNum int, target *library.Log) (*library.Log, *Response, error) { +func (svc *LogService) AddService(org, repo string, buildNum, serviceNum int, target *library.Log) (*library.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, buildNum, serviceNum) @@ -36,12 +36,12 @@ func (s *LogService) AddService(org, repo string, buildNum, serviceNum int, targ v := new(library.Log) // send request using client - resp, err := s.client.Call("POST", u, target, v) + resp, err := svc.client.Call("POST", u, target, v) return v, resp, err } // UpdateService modifies a service log with the provided details. -func (s *LogService) UpdateService(org, repo string, buildNum, serviceNum int, target *library.Log) (*library.Log, *Response, error) { +func (svc *LogService) UpdateService(org, repo string, buildNum, serviceNum int, target *library.Log) (*library.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, buildNum, serviceNum) @@ -49,12 +49,12 @@ func (s *LogService) UpdateService(org, repo string, buildNum, serviceNum int, t v := new(library.Log) // send request using client - resp, err := s.client.Call("PUT", u, target, v) + resp, err := svc.client.Call("PUT", u, target, v) return v, resp, err } // RemoveService deletes the provided service log. -func (s *LogService) RemoveService(org, repo string, buildNum, serviceNum int) (*string, *Response, error) { +func (svc *LogService) RemoveService(org, repo string, buildNum, serviceNum int) (*string, *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, buildNum, serviceNum) @@ -62,12 +62,12 @@ func (s *LogService) RemoveService(org, repo string, buildNum, serviceNum int) ( v := new(string) // send request using client - resp, err := s.client.Call("DELETE", u, nil, v) + resp, err := svc.client.Call("DELETE", u, nil, v) return v, resp, err } // GetStep returns the provided step log. -func (s *LogService) GetStep(org, repo string, buildNum, stepNum int) (*library.Log, *Response, error) { +func (svc *LogService) GetStep(org, repo string, buildNum, stepNum int) (*library.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, buildNum, stepNum) @@ -75,12 +75,12 @@ func (s *LogService) GetStep(org, repo string, buildNum, stepNum int) (*library. v := new(library.Log) // send request using client - resp, err := s.client.Call("GET", u, nil, v) + resp, err := svc.client.Call("GET", u, nil, v) return v, resp, err } // AddStep constructs a step log with the provided details. -func (s *LogService) AddStep(org, repo string, buildNum, stepNum int, target *library.Log) (*library.Log, *Response, error) { +func (svc *LogService) AddStep(org, repo string, buildNum, stepNum int, target *library.Log) (*library.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, buildNum, stepNum) @@ -88,12 +88,12 @@ func (s *LogService) AddStep(org, repo string, buildNum, stepNum int, target *li v := new(library.Log) // send request using client - resp, err := s.client.Call("POST", u, target, v) + resp, err := svc.client.Call("POST", u, target, v) return v, resp, err } // UpdateStep modifies a step log with the provided details. -func (s *LogService) UpdateStep(org, repo string, buildNum, stepNum int, target *library.Log) (*library.Log, *Response, error) { +func (svc *LogService) UpdateStep(org, repo string, buildNum, stepNum int, target *library.Log) (*library.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, buildNum, stepNum) @@ -101,12 +101,12 @@ func (s *LogService) UpdateStep(org, repo string, buildNum, stepNum int, target v := new(library.Log) // send request using client - resp, err := s.client.Call("PUT", u, target, v) + resp, err := svc.client.Call("PUT", u, target, v) return v, resp, err } // RemoveStep deletes the provided step log. -func (s *LogService) RemoveStep(org, repo string, buildNum, stepNum int) (*string, *Response, error) { +func (svc *LogService) RemoveStep(org, repo string, buildNum, stepNum int) (*string, *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, buildNum, stepNum) @@ -114,6 +114,6 @@ func (s *LogService) RemoveStep(org, repo string, buildNum, stepNum int) (*strin v := new(string) // send request using client - resp, err := s.client.Call("DELETE", u, nil, v) + resp, err := svc.client.Call("DELETE", u, nil, v) return v, resp, err } diff --git a/vela/login.go b/vela/login.go index e9a0de2..47c99f2 100644 --- a/vela/login.go +++ b/vela/login.go @@ -11,7 +11,7 @@ import ( type AuthorizationService service // Login constructs a build with the provided details. -func (s *AuthorizationService) Login(target *library.Login) (*library.Login, *Response, error) { +func (svc *AuthorizationService) Login(target *library.Login) (*library.Login, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/login") @@ -19,6 +19,6 @@ func (s *AuthorizationService) Login(target *library.Login) (*library.Login, *Re v := new(library.Login) // send request using client - resp, err := s.client.Call("POST", u, target, v) + resp, err := svc.client.Call("POST", u, target, v) return v, resp, err } diff --git a/vela/repo.go b/vela/repo.go index 692106c..0ed69c4 100644 --- a/vela/repo.go +++ b/vela/repo.go @@ -15,7 +15,7 @@ import ( type RepoService service // Get returns the provided repo. -func (s *RepoService) Get(org, repo string) (*library.Repo, *Response, error) { +func (svc *RepoService) Get(org, repo string) (*library.Repo, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s", org, repo) @@ -23,12 +23,12 @@ func (s *RepoService) Get(org, repo string) (*library.Repo, *Response, error) { v := new(library.Repo) // send request using client - resp, err := s.client.Call("GET", u, nil, v) + resp, err := svc.client.Call("GET", u, nil, v) return v, resp, err } // GetAll returns a list of all repos. -func (s *RepoService) GetAll() (*[]library.Repo, *Response, error) { +func (svc *RepoService) GetAll() (*[]library.Repo, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos") @@ -36,12 +36,12 @@ func (s *RepoService) GetAll() (*[]library.Repo, *Response, error) { v := new([]library.Repo) // send request using client - resp, err := s.client.Call("GET", u, nil, v) + resp, err := svc.client.Call("GET", u, nil, v) return v, resp, err } // Add constructs a repo with the provided details. -func (s *RepoService) Add(target *library.Repo) (*library.Repo, *Response, error) { +func (svc *RepoService) Add(target *library.Repo) (*library.Repo, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos") @@ -49,12 +49,12 @@ func (s *RepoService) Add(target *library.Repo) (*library.Repo, *Response, error v := new(library.Repo) // send request using client - resp, err := s.client.Call("POST", u, target, v) + resp, err := svc.client.Call("POST", u, target, v) return v, resp, err } // Update modifies a repo with the provided details. -func (s *RepoService) Update(org, repo string, target *library.Repo) (*library.Repo, *Response, error) { +func (svc *RepoService) Update(org, repo string, target *library.Repo) (*library.Repo, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s", org, repo) @@ -62,12 +62,12 @@ func (s *RepoService) Update(org, repo string, target *library.Repo) (*library.R v := new(library.Repo) // send request using client - resp, err := s.client.Call("PUT", u, target, v) + resp, err := svc.client.Call("PUT", u, target, v) return v, resp, err } // Remove deletes the provided repo. -func (s *RepoService) Remove(org, repo string) (*string, *Response, error) { +func (svc *RepoService) Remove(org, repo string) (*string, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s", org, repo) @@ -75,7 +75,7 @@ func (s *RepoService) Remove(org, repo string) (*string, *Response, error) { v := new(string) // send request using client - resp, err := s.client.Call("DELETE", u, nil, v) + resp, err := svc.client.Call("DELETE", u, nil, v) return v, resp, err } @@ -93,7 +93,7 @@ func (s *RepoService) Repair(org, repo string) (*string, *Response, error) { } // Chown modifies the org of a repo. -func (s *RepoService) Chown(org, repo string) (*string, *Response, error) { +func (svc *RepoService) Chown(org, repo string) (*string, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/chown", org, repo) @@ -101,6 +101,6 @@ func (s *RepoService) Chown(org, repo string) (*string, *Response, error) { v := new(string) // send request using client - resp, err := s.client.Call("PATCH", u, nil, v) + resp, err := svc.client.Call("PATCH", u, nil, v) return v, resp, err } diff --git a/vela/secret.go b/vela/secret.go index 735cbb9..ec370af 100644 --- a/vela/secret.go +++ b/vela/secret.go @@ -15,7 +15,7 @@ import ( type SecretService service // Get returns the provided secret. -func (s *SecretService) Get(engine, sType, org, name string, target string) (*library.Secret, *Response, error) { +func (svc *SecretService) Get(engine, sType, org, name string, target string) (*library.Secret, *Response, error) { // 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, target) @@ -23,12 +23,12 @@ func (s *SecretService) Get(engine, sType, org, name string, target string) (*li v := new(library.Secret) // send request using client - resp, err := s.client.Call("GET", u, nil, v) + resp, err := svc.client.Call("GET", u, nil, v) return v, resp, err } // GetAll returns a list of all secrets. -func (s *SecretService) GetAll(engine, sType, org, name string) (*[]library.Secret, *Response, error) { +func (svc *SecretService) GetAll(engine, sType, org, name string) (*[]library.Secret, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/secrets/%s/%s/%s/%s", engine, sType, org, name) @@ -36,12 +36,12 @@ func (s *SecretService) GetAll(engine, sType, org, name string) (*[]library.Secr v := new([]library.Secret) // send request using client - resp, err := s.client.Call("GET", u, nil, v) + resp, err := svc.client.Call("GET", u, nil, v) return v, resp, err } // Add constructs a secret with the provided details. -func (s *SecretService) Add(engine, sType, org, name string, target *library.Secret) (*library.Secret, *Response, error) { +func (svc *SecretService) Add(engine, sType, org, name string, target *library.Secret) (*library.Secret, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/secrets/%s/%s/%s/%s", engine, sType, org, name) @@ -49,12 +49,12 @@ func (s *SecretService) Add(engine, sType, org, name string, target *library.Sec v := new(library.Secret) // send request using client - resp, err := s.client.Call("POST", u, target, v) + resp, err := svc.client.Call("POST", u, target, v) return v, resp, err } // Update modifies a secret with the provided details. -func (s *SecretService) Update(engine, sType, org, name string, target *library.Secret) (*library.Secret, *Response, error) { +func (svc *SecretService) Update(engine, sType, org, name string, target *library.Secret) (*library.Secret, *Response, error) { // 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, *target.Name) @@ -62,12 +62,12 @@ func (s *SecretService) Update(engine, sType, org, name string, target *library. v := new(library.Secret) // send request using client - resp, err := s.client.Call("PUT", u, target, v) + resp, err := svc.client.Call("PUT", u, target, v) return v, resp, err } // Remove deletes the provided secret. -func (s *SecretService) Remove(engine, sType, org, name string, target string) (*string, *Response, error) { +func (svc *SecretService) Remove(engine, sType, org, name string, target string) (*string, *Response, error) { // 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, target) @@ -75,6 +75,6 @@ func (s *SecretService) Remove(engine, sType, org, name string, target string) ( v := new(string) // send request using client - resp, err := s.client.Call("DELETE", u, nil, v) + resp, err := svc.client.Call("DELETE", u, nil, v) return v, resp, err } diff --git a/vela/service.go b/vela/service.go index 54145ea..6b2b51a 100644 --- a/vela/service.go +++ b/vela/service.go @@ -15,7 +15,7 @@ import ( type SvcService service // Get returns the provided service. -func (s *SvcService) Get(org, repo string, buildNum, target int) (*library.Service, *Response, error) { +func (svc *SvcService) Get(org, repo string, buildNum, target int) (*library.Service, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services/%d", org, repo, buildNum, target) @@ -23,12 +23,12 @@ func (s *SvcService) Get(org, repo string, buildNum, target int) (*library.Servi v := new(library.Service) // send request using client - resp, err := s.client.Call("GET", u, nil, v) + resp, err := svc.client.Call("GET", u, nil, v) return v, resp, err } // GetAll returns a list of all services. -func (s *SvcService) GetAll(org, repo string, buildNum int) (*[]library.Service, *Response, error) { +func (svc *SvcService) GetAll(org, repo string, buildNum int) (*[]library.Service, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services", org, repo, buildNum) @@ -36,12 +36,12 @@ func (s *SvcService) GetAll(org, repo string, buildNum int) (*[]library.Service, v := new([]library.Service) // send request using client - resp, err := s.client.Call("GET", u, nil, v) + resp, err := svc.client.Call("GET", u, nil, v) return v, resp, err } // Add constructs a service with the provided details. -func (s *SvcService) Add(org, repo string, buildNum int, target *library.Service) (*library.Service, *Response, error) { +func (svc *SvcService) Add(org, repo string, buildNum int, target *library.Service) (*library.Service, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services", org, repo, buildNum) @@ -49,12 +49,12 @@ func (s *SvcService) Add(org, repo string, buildNum int, target *library.Service v := new(library.Service) // send request using client - resp, err := s.client.Call("POST", u, target, v) + resp, err := svc.client.Call("POST", u, target, v) return v, resp, err } // Update modifies a service with the provided details. -func (s *SvcService) Update(org, repo string, buildNum int, target *library.Service) (*library.Service, *Response, error) { +func (svc *SvcService) Update(org, repo string, buildNum int, target *library.Service) (*library.Service, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services/%d", org, repo, buildNum, *target.Number) @@ -62,12 +62,12 @@ func (s *SvcService) Update(org, repo string, buildNum int, target *library.Serv v := new(library.Service) // send request using client - resp, err := s.client.Call("PUT", u, target, v) + resp, err := svc.client.Call("PUT", u, target, v) return v, resp, err } // Remove deletes the provided service. -func (s *SvcService) Remove(org, repo string, buildNum, target int) (*string, *Response, error) { +func (svc *SvcService) Remove(org, repo string, buildNum, target int) (*string, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services/%d", org, repo, buildNum, target) @@ -75,6 +75,6 @@ func (s *SvcService) Remove(org, repo string, buildNum, target int) (*string, *R v := new(string) // send request using client - resp, err := s.client.Call("DELETE", u, nil, v) + resp, err := svc.client.Call("DELETE", u, nil, v) return v, resp, err } diff --git a/vela/step.go b/vela/step.go index da8b1d5..ff27887 100644 --- a/vela/step.go +++ b/vela/step.go @@ -15,7 +15,7 @@ import ( type StepService service // Get returns the provided step. -func (s *StepService) Get(org, repo string, buildNum, target int) (*library.Step, *Response, error) { +func (svc *StepService) Get(org, repo string, buildNum, target int) (*library.Step, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps/%d", org, repo, buildNum, target) @@ -23,12 +23,12 @@ func (s *StepService) Get(org, repo string, buildNum, target int) (*library.Step v := new(library.Step) // send request using client - resp, err := s.client.Call("GET", u, nil, v) + resp, err := svc.client.Call("GET", u, nil, v) return v, resp, err } // GetAll returns a list of all steps. -func (s *StepService) GetAll(org, repo string, buildNum int) (*[]library.Step, *Response, error) { +func (svc *StepService) GetAll(org, repo string, buildNum int) (*[]library.Step, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps", org, repo, buildNum) @@ -36,12 +36,12 @@ func (s *StepService) GetAll(org, repo string, buildNum int) (*[]library.Step, * v := new([]library.Step) // send request using client - resp, err := s.client.Call("GET", u, nil, v) + resp, err := svc.client.Call("GET", u, nil, v) return v, resp, err } // Add constructs a step with the provided details. -func (s *StepService) Add(org, repo string, buildNum int, target *library.Step) (*library.Step, *Response, error) { +func (svc *StepService) Add(org, repo string, buildNum int, target *library.Step) (*library.Step, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps", org, repo, buildNum) @@ -49,12 +49,12 @@ func (s *StepService) Add(org, repo string, buildNum int, target *library.Step) v := new(library.Step) // send request using client - resp, err := s.client.Call("POST", u, target, v) + resp, err := svc.client.Call("POST", u, target, v) return v, resp, err } // Update modifies a step with the provided details. -func (s *StepService) Update(org, repo string, buildNum int, target *library.Step) (*library.Step, *Response, error) { +func (svc *StepService) Update(org, repo string, buildNum int, target *library.Step) (*library.Step, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps/%d", org, repo, buildNum, *target.Number) @@ -62,12 +62,12 @@ func (s *StepService) Update(org, repo string, buildNum int, target *library.Ste v := new(library.Step) // send request using client - resp, err := s.client.Call("PUT", u, target, v) + resp, err := svc.client.Call("PUT", u, target, v) return v, resp, err } // Remove deletes the provided step. -func (s *StepService) Remove(org, repo string, buildNum, target int) (*string, *Response, error) { +func (svc *StepService) Remove(org, repo string, buildNum, target int) (*string, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps/%d", org, repo, buildNum, target) @@ -75,6 +75,6 @@ func (s *StepService) Remove(org, repo string, buildNum, target int) (*string, * v := new(string) // send request using client - resp, err := s.client.Call("DELETE", u, nil, v) + resp, err := svc.client.Call("DELETE", u, nil, v) return v, resp, err } From 0382b03c45487f534f2eefa8961036025851e417 Mon Sep 17 00:00:00 2001 From: Jordan Brockopp Date: Fri, 8 Nov 2019 22:12:02 -0600 Subject: [PATCH 2/4] switch from database to library log type --- vela/build.go | 5 ++--- vela/build_test.go | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/vela/build.go b/vela/build.go index d18b317..80dd450 100644 --- a/vela/build.go +++ b/vela/build.go @@ -7,7 +7,6 @@ package vela import ( "fmt" - "github.com/go-vela/types/database" "github.com/go-vela/types/library" ) @@ -42,12 +41,12 @@ func (svc *BuildService) GetAll(org, repo string) (*[]library.Build, *Response, } // GetLogs returns the provided build logs. -func (svc *BuildService) GetLogs(org, repo string, target int) (*[]database.Log, *Response, error) { +func (svc *BuildService) GetLogs(org, repo string, target int) (*[]library.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, target) // slice database Log type we want to return - v := new([]database.Log) + v := new([]library.Log) // send request using client resp, err := svc.client.Call("GET", u, nil, v) diff --git a/vela/build_test.go b/vela/build_test.go index 561edff..9fe0a41 100644 --- a/vela/build_test.go +++ b/vela/build_test.go @@ -15,7 +15,6 @@ import ( "time" "github.com/go-vela/mock/server" - "github.com/go-vela/types/database" "github.com/go-vela/types/library" "github.com/gin-gonic/gin" @@ -104,7 +103,7 @@ func TestBuild_GetLogs_200(t *testing.T) { c, _ := NewClient(s.URL, nil) data := []byte(server.BuildLogsResp) - var want []database.Log + var want []library.Log _ = json.Unmarshal(data, &want) // run test @@ -129,7 +128,7 @@ func TestBuild_GetLogs_404(t *testing.T) { s := httptest.NewServer(server.FakeHandler()) c, _ := NewClient(s.URL, nil) - want := []database.Log{} + want := []library.Log{} // run test got, resp, err := c.Build.GetLogs("github", "octocat", 0) From 6aae4d80be13f8c06a9ee80e55ca735f6d529ca3 Mon Sep 17 00:00:00 2001 From: Jordan Brockopp Date: Fri, 8 Nov 2019 22:25:35 -0600 Subject: [PATCH 3/4] use getters for capturing struct fields --- vela/build.go | 2 +- vela/secret.go | 2 +- vela/service.go | 2 +- vela/step.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vela/build.go b/vela/build.go index 80dd450..eb4f30e 100644 --- a/vela/build.go +++ b/vela/build.go @@ -69,7 +69,7 @@ func (svc *BuildService) Add(org, repo string, target *library.Build) (*library. // Update modifies a build with the provided details. func (svc *BuildService) Update(org, repo string, target *library.Build) (*library.Build, *Response, error) { // set the API endpoint path we send the request to - u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d", org, repo, *target.Number) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d", org, repo, target.GetNumber()) // library Build type we want to return v := new(library.Build) diff --git a/vela/secret.go b/vela/secret.go index ec370af..b4b8ae7 100644 --- a/vela/secret.go +++ b/vela/secret.go @@ -56,7 +56,7 @@ func (svc *SecretService) Add(engine, sType, org, name string, target *library.S // Update modifies a secret with the provided details. func (svc *SecretService) Update(engine, sType, org, name string, target *library.Secret) (*library.Secret, *Response, error) { // 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, *target.Name) + u := fmt.Sprintf("/api/v1/secrets/%s/%s/%s/%s/%s", engine, sType, org, name, target.GetName()) // library Secret type we want to return v := new(library.Secret) diff --git a/vela/service.go b/vela/service.go index 6b2b51a..2137bcd 100644 --- a/vela/service.go +++ b/vela/service.go @@ -56,7 +56,7 @@ func (svc *SvcService) Add(org, repo string, buildNum int, target *library.Servi // Update modifies a service with the provided details. func (svc *SvcService) Update(org, repo string, buildNum int, target *library.Service) (*library.Service, *Response, error) { // set the API endpoint path we send the request to - u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services/%d", org, repo, buildNum, *target.Number) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services/%d", org, repo, buildNum, target.GetNumber()) // library Service type we want to return v := new(library.Service) diff --git a/vela/step.go b/vela/step.go index ff27887..c550a2a 100644 --- a/vela/step.go +++ b/vela/step.go @@ -56,7 +56,7 @@ func (svc *StepService) Add(org, repo string, buildNum int, target *library.Step // Update modifies a step with the provided details. func (svc *StepService) Update(org, repo string, buildNum int, target *library.Step) (*library.Step, *Response, error) { // set the API endpoint path we send the request to - u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps/%d", org, repo, buildNum, *target.Number) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps/%d", org, repo, buildNum, target.GetNumber()) // library Step type we want to return v := new(library.Step) From dab3eceb01f49796d21821a1eb03833ad9f86f40 Mon Sep 17 00:00:00 2001 From: Jordan Brockopp Date: Fri, 8 Nov 2019 22:49:14 -0600 Subject: [PATCH 4/4] rename variables for consistency --- vela/build.go | 26 +++++++++++++------------- vela/log.go | 40 ++++++++++++++++++++-------------------- vela/login.go | 4 ++-- vela/repo.go | 12 ++++++------ vela/secret.go | 18 +++++++++--------- vela/service.go | 24 ++++++++++++------------ vela/step.go | 24 ++++++++++++------------ 7 files changed, 74 insertions(+), 74 deletions(-) diff --git a/vela/build.go b/vela/build.go index eb4f30e..00a9295 100644 --- a/vela/build.go +++ b/vela/build.go @@ -15,9 +15,9 @@ import ( type BuildService service // Get returns the provided build. -func (svc *BuildService) Get(org, repo string, target int) (*library.Build, *Response, error) { +func (svc *BuildService) Get(org, repo string, build int) (*library.Build, *Response, error) { // set the API endpoint path we send the request to - u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d", org, repo, target) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d", org, repo, build) // library Build type we want to return v := new(library.Build) @@ -41,9 +41,9 @@ func (svc *BuildService) GetAll(org, repo string) (*[]library.Build, *Response, } // GetLogs returns the provided build logs. -func (svc *BuildService) GetLogs(org, repo string, target int) (*[]library.Log, *Response, error) { +func (svc *BuildService) GetLogs(org, repo string, build int) (*[]library.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, target) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/logs", org, repo, build) // slice database Log type we want to return v := new([]library.Log) @@ -54,7 +54,7 @@ func (svc *BuildService) GetLogs(org, repo string, target int) (*[]library.Log, } // Add constructs a build with the provided details. -func (svc *BuildService) Add(org, repo string, target *library.Build) (*library.Build, *Response, error) { +func (svc *BuildService) Add(org, repo string, b *library.Build) (*library.Build, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/builds", org, repo) @@ -62,27 +62,27 @@ func (svc *BuildService) Add(org, repo string, target *library.Build) (*library. v := new(library.Build) // send request using client - resp, err := svc.client.Call("POST", u, target, v) + resp, err := svc.client.Call("POST", u, b, v) return v, resp, err } // Update modifies a build with the provided details. -func (svc *BuildService) Update(org, repo string, target *library.Build) (*library.Build, *Response, error) { +func (svc *BuildService) Update(org, repo string, b *library.Build) (*library.Build, *Response, error) { // set the API endpoint path we send the request to - u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d", org, repo, target.GetNumber()) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d", org, repo, b.GetNumber()) // library Build type we want to return v := new(library.Build) // send request using client - resp, err := svc.client.Call("PUT", u, target, v) + resp, err := svc.client.Call("PUT", u, b, v) return v, resp, err } // Remove deletes the provided build. -func (svc *BuildService) Remove(org, repo string, target int) (*string, *Response, error) { +func (svc *BuildService) Remove(org, repo string, build int) (*string, *Response, error) { // set the API endpoint path we send the request to - u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d", org, repo, target) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d", org, repo, build) // string type we want to return v := new(string) @@ -93,9 +93,9 @@ func (svc *BuildService) Remove(org, repo string, target int) (*string, *Respons } // Restart takes the build provided and restarts it -func (svc *BuildService) Restart(org, repo string, target int) (*library.Build, *Response, error) { +func (svc *BuildService) Restart(org, repo string, build int) (*library.Build, *Response, error) { // set the API endpoint path we send the request to - u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d", org, repo, target) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d", org, repo, build) // library Build type we want to return v := new(library.Build) diff --git a/vela/log.go b/vela/log.go index a4c243b..acd861e 100644 --- a/vela/log.go +++ b/vela/log.go @@ -15,9 +15,9 @@ import ( type LogService service // GetService returns the provided service log. -func (svc *LogService) GetService(org, repo string, buildNum, serviceNum int) (*library.Log, *Response, error) { +func (svc *LogService) GetService(org, repo string, build, service int) (*library.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, buildNum, serviceNum) + 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) @@ -28,35 +28,35 @@ func (svc *LogService) GetService(org, repo string, buildNum, serviceNum int) (* } // AddService constructs a service log with the provided details. -func (svc *LogService) AddService(org, repo string, buildNum, serviceNum int, target *library.Log) (*library.Log, *Response, error) { +func (svc *LogService) AddService(org, repo string, build, service int, l *library.Log) (*library.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, buildNum, serviceNum) + 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) // send request using client - resp, err := svc.client.Call("POST", u, target, v) + resp, err := svc.client.Call("POST", u, l, v) return v, resp, err } // UpdateService modifies a service log with the provided details. -func (svc *LogService) UpdateService(org, repo string, buildNum, serviceNum int, target *library.Log) (*library.Log, *Response, error) { +func (svc *LogService) UpdateService(org, repo string, build, service int, l *library.Log) (*library.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, buildNum, serviceNum) + 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) // send request using client - resp, err := svc.client.Call("PUT", u, target, v) + resp, err := svc.client.Call("PUT", u, l, v) return v, resp, err } // RemoveService deletes the provided service log. -func (svc *LogService) RemoveService(org, repo string, buildNum, serviceNum int) (*string, *Response, error) { +func (svc *LogService) RemoveService(org, repo string, build, service int) (*string, *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, buildNum, serviceNum) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services/%d/logs", org, repo, build, service) // string type we want to return v := new(string) @@ -67,9 +67,9 @@ func (svc *LogService) RemoveService(org, repo string, buildNum, serviceNum int) } // GetStep returns the provided step log. -func (svc *LogService) GetStep(org, repo string, buildNum, stepNum int) (*library.Log, *Response, error) { +func (svc *LogService) GetStep(org, repo string, build, step int) (*library.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, buildNum, stepNum) + 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) @@ -80,35 +80,35 @@ func (svc *LogService) GetStep(org, repo string, buildNum, stepNum int) (*librar } // AddStep constructs a step log with the provided details. -func (svc *LogService) AddStep(org, repo string, buildNum, stepNum int, target *library.Log) (*library.Log, *Response, error) { +func (svc *LogService) AddStep(org, repo string, build, step int, l *library.Log) (*library.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, buildNum, stepNum) + 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) // send request using client - resp, err := svc.client.Call("POST", u, target, v) + resp, err := svc.client.Call("POST", u, l, v) return v, resp, err } // UpdateStep modifies a step log with the provided details. -func (svc *LogService) UpdateStep(org, repo string, buildNum, stepNum int, target *library.Log) (*library.Log, *Response, error) { +func (svc *LogService) UpdateStep(org, repo string, build, step int, l *library.Log) (*library.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, buildNum, stepNum) + 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) // send request using client - resp, err := svc.client.Call("PUT", u, target, v) + resp, err := svc.client.Call("PUT", u, l, v) return v, resp, err } // RemoveStep deletes the provided step log. -func (svc *LogService) RemoveStep(org, repo string, buildNum, stepNum int) (*string, *Response, error) { +func (svc *LogService) RemoveStep(org, repo string, build, step int) (*string, *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, buildNum, stepNum) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps/%d/logs", org, repo, build, step) // string type we want to return v := new(string) diff --git a/vela/login.go b/vela/login.go index 47c99f2..23106a2 100644 --- a/vela/login.go +++ b/vela/login.go @@ -11,7 +11,7 @@ import ( type AuthorizationService service // Login constructs a build with the provided details. -func (svc *AuthorizationService) Login(target *library.Login) (*library.Login, *Response, error) { +func (svc *AuthorizationService) Login(l *library.Login) (*library.Login, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/login") @@ -19,6 +19,6 @@ func (svc *AuthorizationService) Login(target *library.Login) (*library.Login, * v := new(library.Login) // send request using client - resp, err := svc.client.Call("POST", u, target, v) + resp, err := svc.client.Call("POST", u, l, v) return v, resp, err } diff --git a/vela/repo.go b/vela/repo.go index 0ed69c4..abb6a67 100644 --- a/vela/repo.go +++ b/vela/repo.go @@ -41,7 +41,7 @@ func (svc *RepoService) GetAll() (*[]library.Repo, *Response, error) { } // Add constructs a repo with the provided details. -func (svc *RepoService) Add(target *library.Repo) (*library.Repo, *Response, error) { +func (svc *RepoService) Add(r *library.Repo) (*library.Repo, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos") @@ -49,12 +49,12 @@ func (svc *RepoService) Add(target *library.Repo) (*library.Repo, *Response, err v := new(library.Repo) // send request using client - resp, err := svc.client.Call("POST", u, target, v) + resp, err := svc.client.Call("POST", u, r, v) return v, resp, err } // Update modifies a repo with the provided details. -func (svc *RepoService) Update(org, repo string, target *library.Repo) (*library.Repo, *Response, error) { +func (svc *RepoService) Update(org, repo string, r *library.Repo) (*library.Repo, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s", org, repo) @@ -62,7 +62,7 @@ func (svc *RepoService) Update(org, repo string, target *library.Repo) (*library v := new(library.Repo) // send request using client - resp, err := svc.client.Call("PUT", u, target, v) + resp, err := svc.client.Call("PUT", u, r, v) return v, resp, err } @@ -80,7 +80,7 @@ func (svc *RepoService) Remove(org, repo string) (*string, *Response, error) { } // Repair modifies a damaged repo webhook. -func (s *RepoService) Repair(org, repo string) (*string, *Response, error) { +func (svc *RepoService) Repair(org, repo string) (*string, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/repos/%s/%s/repair", org, repo) @@ -88,7 +88,7 @@ func (s *RepoService) Repair(org, repo string) (*string, *Response, error) { v := new(string) // send request using client - resp, err := s.client.Call("PATCH", u, nil, v) + resp, err := svc.client.Call("PATCH", u, nil, v) return v, resp, err } diff --git a/vela/secret.go b/vela/secret.go index b4b8ae7..cba0a53 100644 --- a/vela/secret.go +++ b/vela/secret.go @@ -15,9 +15,9 @@ import ( type SecretService service // Get returns the provided secret. -func (svc *SecretService) Get(engine, sType, org, name string, target string) (*library.Secret, *Response, error) { +func (svc *SecretService) Get(engine, sType, org, name, secret string) (*library.Secret, *Response, error) { // 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, target) + u := fmt.Sprintf("/api/v1/secrets/%s/%s/%s/%s/%s", engine, sType, org, name, secret) // library Secret type we want to return v := new(library.Secret) @@ -41,7 +41,7 @@ func (svc *SecretService) GetAll(engine, sType, org, name string) (*[]library.Se } // Add constructs a secret with the provided details. -func (svc *SecretService) Add(engine, sType, org, name string, target *library.Secret) (*library.Secret, *Response, error) { +func (svc *SecretService) Add(engine, sType, org, name string, s *library.Secret) (*library.Secret, *Response, error) { // set the API endpoint path we send the request to u := fmt.Sprintf("/api/v1/secrets/%s/%s/%s/%s", engine, sType, org, name) @@ -49,27 +49,27 @@ func (svc *SecretService) Add(engine, sType, org, name string, target *library.S v := new(library.Secret) // send request using client - resp, err := svc.client.Call("POST", u, target, v) + resp, err := svc.client.Call("POST", u, s, v) return v, resp, err } // Update modifies a secret with the provided details. -func (svc *SecretService) Update(engine, sType, org, name string, target *library.Secret) (*library.Secret, *Response, error) { +func (svc *SecretService) Update(engine, sType, org, name string, s *library.Secret) (*library.Secret, *Response, error) { // 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, target.GetName()) + u := fmt.Sprintf("/api/v1/secrets/%s/%s/%s/%s/%s", engine, sType, org, name, s.GetName()) // library Secret type we want to return v := new(library.Secret) // send request using client - resp, err := svc.client.Call("PUT", u, target, v) + resp, err := svc.client.Call("PUT", u, s, v) return v, resp, err } // Remove deletes the provided secret. -func (svc *SecretService) Remove(engine, sType, org, name string, target string) (*string, *Response, error) { +func (svc *SecretService) Remove(engine, sType, org, name, secret string) (*string, *Response, error) { // 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, target) + u := fmt.Sprintf("/api/v1/secrets/%s/%s/%s/%s/%s", engine, sType, org, name, secret) // string type we want to return v := new(string) diff --git a/vela/service.go b/vela/service.go index 2137bcd..803ef54 100644 --- a/vela/service.go +++ b/vela/service.go @@ -15,9 +15,9 @@ import ( type SvcService service // Get returns the provided service. -func (svc *SvcService) Get(org, repo string, buildNum, target int) (*library.Service, *Response, error) { +func (svc *SvcService) Get(org, repo string, build, service int) (*library.Service, *Response, error) { // set the API endpoint path we send the request to - u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services/%d", org, repo, buildNum, target) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services/%d", org, repo, build, service) // library Service type we want to return v := new(library.Service) @@ -28,9 +28,9 @@ func (svc *SvcService) Get(org, repo string, buildNum, target int) (*library.Ser } // GetAll returns a list of all services. -func (svc *SvcService) GetAll(org, repo string, buildNum int) (*[]library.Service, *Response, error) { +func (svc *SvcService) GetAll(org, repo string, build int) (*[]library.Service, *Response, error) { // set the API endpoint path we send the request to - u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services", org, repo, buildNum) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services", org, repo, build) // slice library Service type we want to return v := new([]library.Service) @@ -41,35 +41,35 @@ func (svc *SvcService) GetAll(org, repo string, buildNum int) (*[]library.Servic } // Add constructs a service with the provided details. -func (svc *SvcService) Add(org, repo string, buildNum int, target *library.Service) (*library.Service, *Response, error) { +func (svc *SvcService) Add(org, repo string, build int, s *library.Service) (*library.Service, *Response, error) { // set the API endpoint path we send the request to - u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services", org, repo, buildNum) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services", org, repo, build) // library Service type we want to return v := new(library.Service) // send request using client - resp, err := svc.client.Call("POST", u, target, v) + resp, err := svc.client.Call("POST", u, s, v) return v, resp, err } // Update modifies a service with the provided details. -func (svc *SvcService) Update(org, repo string, buildNum int, target *library.Service) (*library.Service, *Response, error) { +func (svc *SvcService) Update(org, repo string, build int, s *library.Service) (*library.Service, *Response, error) { // set the API endpoint path we send the request to - u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services/%d", org, repo, buildNum, target.GetNumber()) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services/%d", org, repo, build, s.GetNumber()) // library Service type we want to return v := new(library.Service) // send request using client - resp, err := svc.client.Call("PUT", u, target, v) + resp, err := svc.client.Call("PUT", u, s, v) return v, resp, err } // Remove deletes the provided service. -func (svc *SvcService) Remove(org, repo string, buildNum, target int) (*string, *Response, error) { +func (svc *SvcService) Remove(org, repo string, build, service int) (*string, *Response, error) { // set the API endpoint path we send the request to - u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services/%d", org, repo, buildNum, target) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/services/%d", org, repo, build, service) // string type we want to return v := new(string) diff --git a/vela/step.go b/vela/step.go index c550a2a..1882593 100644 --- a/vela/step.go +++ b/vela/step.go @@ -15,9 +15,9 @@ import ( type StepService service // Get returns the provided step. -func (svc *StepService) Get(org, repo string, buildNum, target int) (*library.Step, *Response, error) { +func (svc *StepService) Get(org, repo string, build, step int) (*library.Step, *Response, error) { // set the API endpoint path we send the request to - u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps/%d", org, repo, buildNum, target) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps/%d", org, repo, build, step) // library Step type we want to return v := new(library.Step) @@ -28,9 +28,9 @@ func (svc *StepService) Get(org, repo string, buildNum, target int) (*library.St } // GetAll returns a list of all steps. -func (svc *StepService) GetAll(org, repo string, buildNum int) (*[]library.Step, *Response, error) { +func (svc *StepService) GetAll(org, repo string, build int) (*[]library.Step, *Response, error) { // set the API endpoint path we send the request to - u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps", org, repo, buildNum) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps", org, repo, build) // slice library Step type we want to return v := new([]library.Step) @@ -41,35 +41,35 @@ func (svc *StepService) GetAll(org, repo string, buildNum int) (*[]library.Step, } // Add constructs a step with the provided details. -func (svc *StepService) Add(org, repo string, buildNum int, target *library.Step) (*library.Step, *Response, error) { +func (svc *StepService) Add(org, repo string, build int, s *library.Step) (*library.Step, *Response, error) { // set the API endpoint path we send the request to - u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps", org, repo, buildNum) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps", org, repo, build) // library Step type we want to return v := new(library.Step) // send request using client - resp, err := svc.client.Call("POST", u, target, v) + resp, err := svc.client.Call("POST", u, s, v) return v, resp, err } // Update modifies a step with the provided details. -func (svc *StepService) Update(org, repo string, buildNum int, target *library.Step) (*library.Step, *Response, error) { +func (svc *StepService) Update(org, repo string, build int, s *library.Step) (*library.Step, *Response, error) { // set the API endpoint path we send the request to - u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps/%d", org, repo, buildNum, target.GetNumber()) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps/%d", org, repo, build, s.GetNumber()) // library Step type we want to return v := new(library.Step) // send request using client - resp, err := svc.client.Call("PUT", u, target, v) + resp, err := svc.client.Call("PUT", u, s, v) return v, resp, err } // Remove deletes the provided step. -func (svc *StepService) Remove(org, repo string, buildNum, target int) (*string, *Response, error) { +func (svc *StepService) Remove(org, repo string, build, step int) (*string, *Response, error) { // set the API endpoint path we send the request to - u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps/%d", org, repo, buildNum, target) + u := fmt.Sprintf("/api/v1/repos/%s/%s/builds/%d/steps/%d", org, repo, build, step) // string type we want to return v := new(string)