Skip to content

Commit 18add26

Browse files
thquadrichard-cox
authored andcommitted
Rename overwriteEndpoints in createUserEndpoint (#4876)
Signed-off-by: Thomas Quandt <[email protected]>
1 parent baa0bfc commit 18add26

File tree

11 files changed

+38
-38
lines changed

11 files changed

+38
-38
lines changed

src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ <h1 class="create-endpoint__section-title">{{endpoint.definition.label}} Informa
1414
<mat-error *ngIf="registerForm.controls.urlField.errors?.pattern">Invalid API URL</mat-error>
1515
<mat-error *ngIf="registerForm.controls.urlField.errors?.appUnique">URL is not unique</mat-error>
1616
</mat-form-field>
17-
<mat-checkbox matInput *ngIf="userEndpointsAndIsAdmin | async" name="overwriteEndpoints"
18-
formControlName="overwriteEndpointsField" (change)="toggleOverwriteEndpoints()"
19-
[ngClass]="{'hide': fixedUrl, 'show': !fixedUrl}">Automatically overwrite user endpoints
17+
<mat-checkbox matInput *ngIf="userEndpointsAndIsAdmin | async" name="createUserEndpoint"
18+
formControlName="createUserEndpointField" (change)="toggleCreateUserEndpoint()"
19+
[ngClass]="{'hide': fixedUrl, 'show': !fixedUrl}">Create a user endpoint (only visible to you and other admins)
2020
</mat-checkbox>
2121
<mat-checkbox matInput name="skipSll" formControlName="skipSllField"
2222
[ngClass]="{'hide': fixedUrl, 'show': !fixedUrl}">Skip SSL validation for the

src/frontend/packages/core/src/features/endpoints/create-endpoint/create-endpoint-cf-step-1/create-endpoint-cf-step-1.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class CreateEndpointCfStep1Component extends CreateEndpointHelperComponen
7575
// Optional Client ID and Client Secret
7676
clientIDField: ['', []],
7777
clientSecretField: ['', []],
78-
overwriteEndpointsField: [false, []],
78+
createUserEndpointField: [false, []],
7979
});
8080

8181
const epType = getIdFromRoute(activatedRoute, 'type');
@@ -98,7 +98,7 @@ export class CreateEndpointCfStep1Component extends CreateEndpointHelperComponen
9898
this.registerForm.value.clientIDField,
9999
this.registerForm.value.clientSecretField,
100100
this.registerForm.value.ssoAllowedField,
101-
this.registerForm.value.overwriteEndpointsField,
101+
this.registerForm.value.createUserEndpointField,
102102
).pipe(
103103
pairwise(),
104104
filter(([oldVal, newVal]) => (oldVal.busy && !newVal.busy)),
@@ -149,7 +149,7 @@ export class CreateEndpointCfStep1Component extends CreateEndpointHelperComponen
149149
this.showAdvancedOptions = !this.showAdvancedOptions;
150150
}
151151

152-
toggleOverwriteEndpoints() {
152+
toggleCreateUserEndpoint() {
153153
// wait a tick for validators to adjust to new data in the directive
154154
setTimeout(() => {
155155
this.registerForm.controls.nameField.updateValueAndValidity();

src/frontend/packages/git/src/shared/components/git-registration/git-registration.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ <h3>Select the type of {{gitTypes[epSubType].label}} to register</h3>
3131
<mat-error *ngIf="registerForm.controls.urlField.errors?.pattern">Invalid API URL</mat-error>
3232
<mat-error *ngIf="registerForm.controls.urlField.errors?.appUnique">URL is not unique</mat-error>
3333
</mat-form-field>
34-
<mat-checkbox matInput *ngIf="userEndpointsAndIsAdmin | async" name="overwriteEndpoints"
35-
formControlName="overwriteEndpointsField" (change)="toggleOverwriteEndpoints()"
36-
[ngClass]="{'hide': fixedUrl, 'show': !fixedUrl}">Automatically overwrite user endpoints
34+
<mat-checkbox matInput *ngIf="userEndpointsAndIsAdmin | async" name="createUserEndpoint"
35+
formControlName="createUserEndpointField" (change)="toggleCreateUserEndpoint()"
36+
[ngClass]="{'hide': fixedUrl, 'show': !fixedUrl}">Create a user endpoint (only visible to you and other admins)
3737
</mat-checkbox>
3838
<mat-checkbox matInput name="skipSll" formControlName="skipSllField"
3939
[ngClass]="{'hide': fixedUrl, 'show': !fixedUrl}">Skip SSL validation for the

src/frontend/packages/git/src/shared/components/git-registration/git-registration.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export class GitRegistrationComponent extends CreateEndpointHelperComponent impl
159159
nameField: ['', [Validators.required]],
160160
urlField: ['', [Validators.required]],
161161
skipSllField: [false, []],
162-
overwriteEndpointsField: [false, []],
162+
createUserEndpointField: [false, []],
163163
});
164164
this.updateType();
165165

@@ -201,10 +201,10 @@ export class GitRegistrationComponent extends CreateEndpointHelperComponent impl
201201
const skipSSL = this.registerForm.controls.nameField.value && this.registerForm.controls.urlField.value ?
202202
this.registerForm.controls.skipSllField.value :
203203
false;
204-
const overwriteEndpoints = this.registerForm.controls.overwriteEndpointsField.value;
204+
const createUserEndpoint = this.registerForm.controls.createUserEndpointField.value;
205205

206206
return stratosEntityCatalog.endpoint.api.register<ActionState>(GIT_ENDPOINT_TYPE,
207-
this.epSubType, name, url, skipSSL, '', '', false, overwriteEndpoints)
207+
this.epSubType, name, url, skipSSL, '', '', false, createUserEndpoint)
208208
.pipe(
209209
pairwise(),
210210
filter(([oldVal, newVal]) => (oldVal.busy && !newVal.busy)),
@@ -240,7 +240,7 @@ export class GitRegistrationComponent extends CreateEndpointHelperComponent impl
240240
return ready + '/' + defn.urlSuffix;
241241
}
242242

243-
toggleOverwriteEndpoints() {
243+
toggleCreateUserEndpoint() {
244244
// wait a tick for validators to adjust to new data in the directive
245245
setTimeout(() => {
246246
this.registerForm.controls.nameField.updateValueAndValidity();

src/frontend/packages/store/src/actions/endpoint.actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export class RegisterEndpoint extends SingleBaseEndpointAction {
215215
public clientID = '',
216216
public clientSecret = '',
217217
public ssoAllowed: boolean,
218-
public overwriteEndpoints: boolean,
218+
public createUserEndpoint: boolean,
219219
) {
220220
super(
221221
REGISTER_ENDPOINTS,

src/frontend/packages/store/src/effects/endpoint.effects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export class EndpointsEffect {
195195
cnsi_client_id: action.clientID,
196196
cnsi_client_secret: action.clientSecret,
197197
sso_allowed: action.ssoAllowed ? 'true' : 'false',
198-
overwrite_endpoints: action.overwriteEndpoints ? 'true' : 'false'
198+
create_user_endpoint: action.createUserEndpoint ? 'true' : 'false'
199199
};
200200
// Do not include sub_type in HttpParams if it doesn't exist (falsies get stringified and sent)
201201
if (action.endpointSubType) {

src/frontend/packages/store/src/stratos-action-builders.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export interface EndpointActionBuilder extends OrchestratedActionBuilders {
6060
clientID?: string,
6161
clientSecret?: string,
6262
ssoAllowed?: boolean,
63-
overwriteEndpointsField?: boolean,
63+
createUserEndpointField?: boolean,
6464
) => RegisterEndpoint;
6565
update: (
6666
guid: string,
@@ -105,7 +105,7 @@ export const endpointActionBuilder: EndpointActionBuilder = {
105105
clientID?: string,
106106
clientSecret?: string,
107107
ssoAllowed?: boolean,
108-
overwriteEndpoints?: boolean,
108+
createUserEndpoint?: boolean,
109109
) => new RegisterEndpoint(
110110
endpointType,
111111
endpointSubType,
@@ -115,7 +115,7 @@ export const endpointActionBuilder: EndpointActionBuilder = {
115115
clientID,
116116
clientSecret,
117117
ssoAllowed,
118-
overwriteEndpoints,
118+
createUserEndpoint,
119119
),
120120
update: (
121121
guid: string,

src/jetstream/cnsi.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ func (p *portalProxy) RegisterEndpoint(c echo.Context, fetchInfo interfaces.Info
6363
cnsiClientSecret := params.CNSIClientSecret
6464
subType := params.SubType
6565

66-
overwriteEndpoints, err := strconv.ParseBool(params.OverwriteEndpoints)
66+
createUserEndpoint, err := strconv.ParseBool(params.CreateUserEndpoint)
6767
if err != nil {
6868
// default to false
69-
overwriteEndpoints = false
69+
createUserEndpoint = false
7070
}
7171

7272
if cnsiClientId == "" {
@@ -82,7 +82,7 @@ func (p *portalProxy) RegisterEndpoint(c echo.Context, fetchInfo interfaces.Info
8282
"Failed to get session user: %v", err)
8383
}
8484

85-
newCNSI, err := p.DoRegisterEndpoint(params.CNSIName, params.APIEndpoint, skipSSLValidation, cnsiClientId, cnsiClientSecret, userID, ssoAllowed, subType, overwriteEndpoints, fetchInfo)
85+
newCNSI, err := p.DoRegisterEndpoint(params.CNSIName, params.APIEndpoint, skipSSLValidation, cnsiClientId, cnsiClientSecret, userID, ssoAllowed, subType, createUserEndpoint, fetchInfo)
8686
if err != nil {
8787
return err
8888
}
@@ -91,7 +91,7 @@ func (p *portalProxy) RegisterEndpoint(c echo.Context, fetchInfo interfaces.Info
9191
return nil
9292
}
9393

94-
func (p *portalProxy) DoRegisterEndpoint(cnsiName string, apiEndpoint string, skipSSLValidation bool, clientId string, clientSecret string, userId string, ssoAllowed bool, subType string, overwriteEndpoints bool, fetchInfo interfaces.InfoFunc) (interfaces.CNSIRecord, error) {
94+
func (p *portalProxy) DoRegisterEndpoint(cnsiName string, apiEndpoint string, skipSSLValidation bool, clientId string, clientSecret string, userId string, ssoAllowed bool, subType string, createUserEndpoint bool, fetchInfo interfaces.InfoFunc) (interfaces.CNSIRecord, error) {
9595
log.Debug("DoRegisterEndpoint")
9696

9797
if len(cnsiName) == 0 || len(apiEndpoint) == 0 {
@@ -170,19 +170,19 @@ func (p *portalProxy) DoRegisterEndpoint(cnsiName string, apiEndpoint string, sk
170170
}
171171

172172
/*
173-
if isAdmin && overwriteEndpoints {
174-
for _, duplicate := range duplicateEndpoints {
175-
log.Infof("An administrator is registering an endpoint with the same API URL ('%+v') as an endpoint administrator's. The existing duplicate endpoint ('%+v') will be removed", apiEndpoint, duplicate.GUID)
176-
err := p.doUnregisterCluster(duplicate.GUID)
177-
if err != nil {
178-
return interfaces.CNSIRecord{}, interfaces.NewHTTPShadowError(
179-
http.StatusInternalServerError,
180-
"Failed to unregister cluster",
181-
"Failed to unregister cluster: %v",
182-
err)
173+
if isAdmin && overwriteEndpoints {
174+
for _, duplicate := range duplicateEndpoints {
175+
log.Infof("An administrator is registering an endpoint with the same API URL ('%+v') as an endpoint administrator's. The existing duplicate endpoint ('%+v') will be removed", apiEndpoint, duplicate.GUID)
176+
err := p.doUnregisterCluster(duplicate.GUID)
177+
if err != nil {
178+
return interfaces.CNSIRecord{}, interfaces.NewHTTPShadowError(
179+
http.StatusInternalServerError,
180+
"Failed to unregister cluster",
181+
"Failed to unregister cluster: %v",
182+
err)
183+
}
183184
}
184185
}
185-
}
186186
*/
187187

188188
}
@@ -315,7 +315,7 @@ func (p *portalProxy) buildCNSIList(c echo.Context) ([]*interfaces.CNSIRecord, e
315315

316316
for i := 0; i < len(filteredList); i++ {
317317
if filteredList[i].APIEndpoint.String() == endpoint.APIEndpoint.String() {
318-
duplicateSystemEndpoint = len(filteredList[i].Creator) != 0
318+
duplicateSystemEndpoint = len(filteredList[i].Creator) == 0
319319
duplicateEndpointIndex = i
320320
}
321321
}

src/jetstream/mock_server_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ func setupMockUser(guid string, admin bool, scopes []string) MockUser {
272272
}
273273

274274
// mockV2Info needs to be closed
275-
func setupMockEndpointRegisterRequest(t *testing.T, user *interfaces.ConnectedUser, mockV2Info *httptest.Server, endpointName string, overwriteEndpoints bool) MockEndpointRequest {
275+
func setupMockEndpointRegisterRequest(t *testing.T, user *interfaces.ConnectedUser, mockV2Info *httptest.Server, endpointName string, createUserEndpoint bool) MockEndpointRequest {
276276

277277
// create a request for each endpoint
278278
req := setupMockReq("POST", "", map[string]string{
@@ -281,7 +281,7 @@ func setupMockEndpointRegisterRequest(t *testing.T, user *interfaces.ConnectedUs
281281
"skip_ssl_validation": "true",
282282
"cnsi_client_id": mockClientId,
283283
"cnsi_client_secret": mockClientSecret,
284-
"overwrite_endpoints": strconv.FormatBool(overwriteEndpoints),
284+
"create_user_endpoint": strconv.FormatBool(createUserEndpoint),
285285
})
286286

287287
res := httptest.NewRecorder()

src/jetstream/repository/interfaces/portal_proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type PortalProxy interface {
1414
GetHttpClient(skipSSLValidation bool) http.Client
1515
GetHttpClientForRequest(req *http.Request, skipSSLValidation bool) http.Client
1616
RegisterEndpoint(c echo.Context, fetchInfo InfoFunc) error
17-
DoRegisterEndpoint(cnsiName string, apiEndpoint string, skipSSLValidation bool, clientId string, clientSecret string, userId string, ssoAllowed bool, subType string, overwriteEndpoints bool, fetchInfo InfoFunc) (CNSIRecord, error)
17+
DoRegisterEndpoint(cnsiName string, apiEndpoint string, skipSSLValidation bool, clientId string, clientSecret string, userId string, ssoAllowed bool, subType string, createUserEndpoint bool, fetchInfo InfoFunc) (CNSIRecord, error)
1818
GetEndpointTypeSpec(typeName string) (EndpointPlugin, error)
1919

2020
// Auth

0 commit comments

Comments
 (0)