Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hdacloud
dex
Commits
d521051e
Unverified
Commit
d521051e
authored
4 months ago
by
Nicholas Wiersma
Committed by
GitHub
4 months ago
Browse files
Options
Downloads
Patches
Plain Diff
feat: set resource revision for connectors (#3868)
Signed-off-by:
Nicholas Wiersma
<
nick@wiersma.co.za
>
parent
61101499
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/api.go
+19
-5
19 additions, 5 deletions
server/api.go
with
19 additions
and
5 deletions
server/api.go
+
19
−
5
View file @
d521051e
...
...
@@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"log/slog"
"strconv"
"golang.org/x/crypto/bcrypt"
...
...
@@ -430,10 +431,11 @@ func (d dexAPI) CreateConnector(ctx context.Context, req *api.CreateConnectorReq
}
c
:=
storage
.
Connector
{
ID
:
req
.
Connector
.
Id
,
Name
:
req
.
Connector
.
Name
,
Type
:
req
.
Connector
.
Type
,
Config
:
req
.
Connector
.
Config
,
ID
:
req
.
Connector
.
Id
,
Name
:
req
.
Connector
.
Name
,
Type
:
req
.
Connector
.
Type
,
ResourceVersion
:
"1"
,
Config
:
req
.
Connector
.
Config
,
}
if
err
:=
d
.
s
.
CreateConnector
(
ctx
,
c
);
err
!=
nil
{
if
err
==
storage
.
ErrAlreadyExists
{
...
...
@@ -446,7 +448,7 @@ func (d dexAPI) CreateConnector(ctx context.Context, req *api.CreateConnectorReq
return
&
api
.
CreateConnectorResp
{},
nil
}
func
(
d
dexAPI
)
UpdateConnector
(
ctx
context
.
Context
,
req
*
api
.
UpdateConnectorReq
)
(
*
api
.
UpdateConnectorResp
,
error
)
{
func
(
d
dexAPI
)
UpdateConnector
(
_
context
.
Context
,
req
*
api
.
UpdateConnectorReq
)
(
*
api
.
UpdateConnectorResp
,
error
)
{
if
!
featureflags
.
APIConnectorsCRUD
.
Enabled
()
{
return
nil
,
fmt
.
Errorf
(
"%s feature flag is not enabled"
,
featureflags
.
APIConnectorsCRUD
.
Name
)
}
...
...
@@ -476,6 +478,10 @@ func (d dexAPI) UpdateConnector(ctx context.Context, req *api.UpdateConnectorReq
old
.
Config
=
req
.
NewConfig
}
if
rev
,
err
:=
strconv
.
Atoi
(
defaultTo
(
old
.
ResourceVersion
,
"0"
));
err
==
nil
{
old
.
ResourceVersion
=
strconv
.
Itoa
(
rev
+
1
)
}
return
old
,
nil
}
...
...
@@ -536,3 +542,11 @@ func (d dexAPI) ListConnectors(ctx context.Context, req *api.ListConnectorReq) (
Connectors
:
connectors
,
},
nil
}
func
defaultTo
[
T
comparable
](
v
,
def
T
)
T
{
var
zeroT
T
if
v
==
zeroT
{
return
def
}
return
v
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment