From 25e4cfa498e04a3313d2337c6406ad1788bdb106 Mon Sep 17 00:00:00 2001 From: Patrick Rice Date: Fri, 4 Aug 2023 02:24:41 +0000 Subject: [PATCH] Update the response and options based on new API documentation and examples --- users.go | 37 ++++++++++++++----------------------- users_test.go | 6 ++++-- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/users.go b/users.go index 249d2ca93..b4745522a 100644 --- a/users.go +++ b/users.go @@ -1415,16 +1415,17 @@ func (s *UsersService) DisableTwoFactor(user int, options ...RequestOptionFunc) // GitLab API docs: // https://docs.gitlab.com/ee/api/users.html#create-a-runner type CreateUserRunnerOptions struct { - RunnerType string `json:"runner_type"` - GroupID int `json:"group_id"` - ProjectID int `json:"project_id"` - Description string `json:"description"` - Paused bool `json:"paused"` - Locked bool `json:"locked"` - RunUntagged bool `json:"run_untagged"` - TagList []string `json:"tag_list"` - AccessLevel string `json:"access_level"` - MaximumTimeout int `json:"maximum_timeout"` + RunnerType string `json:"runner_type"` + GroupID int `json:"group_id"` + ProjectID int `json:"project_id"` + Description string `json:"description"` + Paused bool `json:"paused"` + Locked bool `json:"locked"` + RunUntagged bool `json:"run_untagged"` + TagList []string `json:"tag_list"` + AccessLevel string `json:"access_level"` + MaximumTimeout int `json:"maximum_timeout"` + MaintenanceNote string `json:"maintenance_note"` } // UserRunner represents the a GitLab runner instance created using the user-based flow @@ -1432,19 +1433,9 @@ type CreateUserRunnerOptions struct { // GitLab API docs: // https://docs.gitlab.com/ee/api/users.html#create-a-runner type UserRunner struct { - ID int `json:"id"` - Token string `json:"token"` - TokenExpiresAt string `json:"token_expires_at"` - RunnerType string `json:"runner_type"` - GroupID int `json:"group_id"` - ProjectID int `json:"project_id"` - Description string `json:"description"` - Paused bool `json:"paused"` - Locked bool `json:"locked"` - RunUntagged bool `json:"run_untagged"` - TagList []string `json:"tag_list"` - AccessLevel string `json:"access_level"` - MaximumTimeout int `json:"maximum_timeout"` + ID int `json:"id"` + Token string `json:"token"` + TokenExpiresAt string `json:"token_expires_at"` } // CreateUserRunner creates a new runner using the user-based flow and returns the authentication diff --git a/users_test.go b/users_test.go index ae65ac2d6..7eb44a8fa 100644 --- a/users_test.go +++ b/users_test.go @@ -661,7 +661,7 @@ func TestCreateUserRunner(t *testing.T) { mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusCreated) - w.Write([]byte(`{"id": 1234, "runner_type": "project_type"}`)) + w.Write([]byte(`{"id": 1234, "token": "glrt-1234567890ABCD", "token_expires_at":null}`)) }) createRunnerOpts := &CreateUserRunnerOptions{ @@ -674,5 +674,7 @@ func TestCreateUserRunner(t *testing.T) { t.Errorf("Users.CreateUserRunner returned an error: %v", err) } - require.Equal(t, "project_type", response.RunnerType) + require.Equal(t, 1234, response.ID) + require.Equal(t, "glrt-1234567890ABCD", response.Token) + require.Equal(t, "", response.TokenExpiresAt) }