Skip to content

Commit 510a43d

Browse files
committed
refactor: change the function name to remove Gitlab from the function
1 parent c34b2a6 commit 510a43d

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func (b *Backend) getClient(ctx context.Context, s logical.Storage, name string)
181181

182182
var httpClient *http.Client
183183
httpClient, _ = HttpClientFromContext(ctx)
184-
if client, _ = GitlabClientFromContext(ctx); client == nil {
184+
if client, _ = ClientFromContext(ctx); client == nil {
185185
if client, err = NewGitlabClient(config, httpClient, b.Logger()); err == nil {
186186
b.SetClient(client, name)
187187
}

defs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ func HttpClientFromContext(ctx context.Context) (*http.Client, bool) {
5555
return u, ok
5656
}
5757

58-
func GitlabClientNewContext(ctx context.Context, client Client) context.Context {
58+
func ClientNewContext(ctx context.Context, client Client) context.Context {
5959
return context.WithValue(ctx, ctxKeyGitlabClient, client)
6060
}
6161

62-
func GitlabClientFromContext(ctx context.Context) (Client, bool) {
62+
func ClientFromContext(ctx context.Context) (Client, bool) {
6363
u, ok := ctx.Value(ctxKeyGitlabClient).(Client)
6464
if !ok {
6565
u = nil

defs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
func TestEmptyGitlabClientFromContext(t *testing.T) {
14-
c, ok := gitlab.GitlabClientFromContext(t.Context())
14+
c, ok := gitlab.ClientFromContext(t.Context())
1515
require.False(t, ok)
1616
require.Nil(t, c)
1717
}

path_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (b *Backend) updateConfigClientInfo(ctx context.Context, config *EntryConfi
156156
var httpClient *http.Client
157157
var client Client
158158
httpClient, _ = HttpClientFromContext(ctx)
159-
if client, _ = GitlabClientFromContext(ctx); client == nil {
159+
if client, _ = ClientFromContext(ctx); client == nil {
160160
if client, err = NewGitlabClient(config, httpClient, b.Logger()); err == nil {
161161
b.SetClient(client, config.Name)
162162
} else {

path_config_token_autorotate_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func TestPathConfig_AutoRotateToken(t *testing.T) {
157157
t.Run("no error when auto rotate is disabled and config is set", func(t *testing.T) {
158158
var client = newInMemoryClient(true)
159159
ctx, url := getCtxGitlabClientWithUrl(t, "unit")
160-
ctx = gitlab.GitlabClientNewContext(ctx, client)
160+
ctx = gitlab.ClientNewContext(ctx, client)
161161
b, l, err := getBackendWithConfig(ctx, map[string]any{
162162
"token": "glpat-secret-token",
163163
"base_url": url,
@@ -173,7 +173,7 @@ func TestPathConfig_AutoRotateToken(t *testing.T) {
173173
t.Run("call auto rotate the main token and rotate the token", func(t *testing.T) {
174174
var client = newInMemoryClient(true)
175175
ctx, url := getCtxGitlabClientWithUrl(t, "unit")
176-
ctx = gitlab.GitlabClientNewContext(ctx, newInMemoryClient(true))
176+
ctx = gitlab.ClientNewContext(ctx, newInMemoryClient(true))
177177
b, l, events, err := getBackendWithEventsAndConfig(ctx, map[string]any{
178178
"token": "token",
179179
"base_url": url,
@@ -224,7 +224,7 @@ func TestPathConfig_AutoRotateToken(t *testing.T) {
224224
t.Run("call auto rotate the main token but the token is still valid", func(t *testing.T) {
225225
var client = newInMemoryClient(true)
226226
ctx, url := getCtxGitlabClientWithUrl(t, "unit")
227-
ctx = gitlab.GitlabClientNewContext(ctx, newInMemoryClient(true))
227+
ctx = gitlab.ClientNewContext(ctx, newInMemoryClient(true))
228228
b, l, err := getBackendWithConfig(ctx, map[string]any{
229229
"token": "token",
230230
"base_url": url,

path_token_role_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestPathTokenRoles(t *testing.T) {
3939
t.Logf("token creation, token type: %s, level: %s, gitlab revokes token: %t", tokenType, level, gitlabRevokesToken)
4040
ctx := getCtxGitlabClient(t, "unit")
4141
client := newInMemoryClient(true)
42-
ctx = gitlab.GitlabClientNewContext(ctx, client)
42+
ctx = gitlab.ClientNewContext(ctx, client)
4343
var b, l, events, err = getBackendWithEvents(ctx)
4444
require.NoError(t, err)
4545
require.NoError(t, writeBackendConfig(ctx, b, l, defaultConfig))

0 commit comments

Comments
 (0)