This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat/enterpriseportal: implement UpdateCodyGatewayAccess #63926
Merged
bobheadxi
merged 6 commits into
main
from
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
Aug 8, 2024
Merged
feat/enterpriseportal: implement UpdateCodyGatewayAccess #63926
bobheadxi
merged 6 commits into
main
from
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
Aug 8, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Jul 18, 2024
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_use_enterprise_portal_database_for_cody_gateway_access
branch
from
July 18, 2024 20:58
d7e4757
to
6529733
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
July 18, 2024 20:58
03604aa
to
e659c84
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
2 times, most recently
from
July 18, 2024 21:33
5097b92
to
2987359
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_use_enterprise_portal_database_for_cody_gateway_access
branch
from
July 18, 2024 21:34
3ce5453
to
0b64444
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
July 18, 2024 21:34
2987359
to
e81f272
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_use_enterprise_portal_database_for_cody_gateway_access
branch
from
July 18, 2024 22:39
0b64444
to
5a5d757
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
July 18, 2024 22:39
e81f272
to
a5c9edb
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
July 18, 2024 22:47
a5c9edb
to
e786e7a
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_use_enterprise_portal_database_for_cody_gateway_access
branch
from
July 19, 2024 18:16
ab95895
to
f9f0fa8
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
July 19, 2024 18:16
e786e7a
to
889233c
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_use_enterprise_portal_database_for_cody_gateway_access
branch
from
July 19, 2024 18:56
f9f0fa8
to
ad3dc7b
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
July 19, 2024 18:57
a42857f
to
6bb1bea
Compare
3 tasks
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_use_enterprise_portal_database_for_cody_gateway_access
branch
from
July 19, 2024 21:07
ad3dc7b
to
b125b3e
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
July 19, 2024 21:07
2fa6111
to
5726960
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
August 7, 2024 16:37
4ac0f1c
to
74b7746
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_use_enterprise_portal_database_for_cody_gateway_access
branch
from
August 7, 2024 18:18
3b1da16
to
c68cb07
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
August 7, 2024 18:19
74b7746
to
2990832
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_use_enterprise_portal_database_for_cody_gateway_access
branch
from
August 7, 2024 18:25
c68cb07
to
47163fe
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
August 7, 2024 18:25
2990832
to
225b19f
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_use_enterprise_portal_database_for_cody_gateway_access
branch
from
August 7, 2024 18:32
47163fe
to
f27525f
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
August 7, 2024 18:32
225b19f
to
d702c53
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_use_enterprise_portal_database_for_cody_gateway_access
branch
from
August 7, 2024 18:45
f27525f
to
8739a6f
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
August 7, 2024 18:45
d702c53
to
6731b8f
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_use_enterprise_portal_database_for_cody_gateway_access
branch
from
August 7, 2024 21:13
8739a6f
to
07dcdf6
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
August 7, 2024 21:13
6731b8f
to
cbfba83
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_use_enterprise_portal_database_for_cody_gateway_access
branch
from
August 7, 2024 23:16
07dcdf6
to
3bf020e
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
August 7, 2024 23:16
cbfba83
to
5cc880c
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_use_enterprise_portal_database_for_cody_gateway_access
branch
from
August 7, 2024 23:18
3bf020e
to
c8dd5d0
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
August 7, 2024 23:18
5cc880c
to
0e7192d
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_use_enterprise_portal_database_for_cody_gateway_access
branch
from
August 8, 2024 17:03
c8dd5d0
to
6211943
Compare
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
August 8, 2024 17:03
0e7192d
to
8e39464
Compare
Comment on lines
+152
to
+182
// 🚨 SECURITY: Require approrpiate M2M scope. | ||
requiredScope := samsm2m.EnterprisePortalScope( | ||
scopes.PermissionEnterprisePortalCodyAccess, scopes.ActionWrite) | ||
clientAttrs, err := samsm2m.RequireScope(ctx, logger, s.store, requiredScope, req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
logger = logger.With(clientAttrs...) | ||
|
||
subscriptionID := req.Msg.GetAccess().SubscriptionId | ||
if subscriptionID == "" { | ||
return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("subscription ID is required")) | ||
} | ||
|
||
var opts codyaccess.UpsertCodyGatewayAccessOptions | ||
|
||
update := req.Msg.GetAccess() | ||
fieldPaths := req.Msg.GetUpdateMask().GetPaths() | ||
// Empty field paths means update all non-empty fields. | ||
if len(fieldPaths) == 0 { | ||
if update.Enabled { | ||
opts.Enabled = pointers.Ptr(update.Enabled) | ||
} | ||
if update.GetChatCompletionsRateLimit().GetLimit() > 0 { | ||
opts.ChatCompletionsRateLimit = pointers.Ptr( | ||
int64(update.GetChatCompletionsRateLimit().Limit), | ||
) | ||
} | ||
if update.GetChatCompletionsRateLimit().GetIntervalDuration().GetSeconds() > 0 { | ||
opts.ChatCompletionsRateLimitIntervalSeconds = pointers.Ptr( | ||
int32(update.GetChatCompletionsRateLimit().GetIntervalDuration().Seconds), |
Check notice
Code scanning / Semgrep OSS
Semgrep Finding: security-semgrep-rules.semgrep-rules.generic.comment-tagging-rule Note
Code that highlight SECURITY in comment has changed. Please review the code for changes. The changes might be sensitive.
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
August 8, 2024 17:24
4a2c055
to
be61fc6
Compare
Base automatically changed from
07-18-feat_enterpriseportal_use_enterprise_portal_database_for_cody_gateway_access
to
main
August 8, 2024 17:39
bobheadxi
force-pushed
the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
from
August 8, 2024 17:39
be61fc6
to
6251655
Compare
bobheadxi
deleted the
07-18-feat_enterpriseportal_implement_updatecodygatewayaccess
branch
August 8, 2024 20:21
bobheadxi
referenced
this pull request
Aug 8, 2024
…tal (#64090) Upgrades the self-contained Cody Gateway modal to only depend on Enterprise Portal to read/write Cody Gateway access. I also made some minor tweaks to parsing empty form inputs, and also made the "Cody Gateway access token" collapsed by default, with warnings to discourage its use (opted not to remove entirely since it may be useful for dev/debugging) Depends on: - https://github.com/sourcegraph/sourcegraph/pull/63926 - https://github.com/sourcegraph/sourcegraph/pull/63925 - https://github.com/sourcegraph/sourcegraph/pull/63858 Closes https://linear.app/sourcegraph/issue/CORE-218 ## Test plan ``` sg start dotcom ``` Edit the Cody Gateway access stuff, toggling it up and down. Cross-reference with the `enterprise_portal_cody_gateway_access` table.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements the only Cody Access write API we have right now, the ability to apply overrides to Cody Gateway rate limits, which we'll have in Enterprise Portal with https://github.com/sourcegraph/sourcegraph/pull/63858
A lot of the diff is a new generated mock for the Cody Access store so that we can write some simple unit tests.
With this addition, all initially proposed Cody Gateway access APIs are implemented.
Part of https://linear.app/sourcegraph/issue/CORE-218
Closes https://linear.app/sourcegraph/issue/CORE-160
Test plan
Unit and existing integration tests