Skip to content

Commit 39b4bd9

Browse files
authored
Fix git related issues found in release testing (#4850)
* Fix helm chart note for ClusterIP * CF Push: Ensure git credentials are not stored in env var - use a specific var for clone url instead of obj that becomes env var - tidy up logic * Fix issue where path was unescaped, causing proxy fetch of gitlab projects containing %2f to 404 * Update clone failed text, repo does not now have to be public * Apply nginx uri substituion fix to nginx.dev.conf as well - think this is only used by docker compose, which isn't supported anymore
1 parent 423c241 commit 39b4bd9

File tree

6 files changed

+28
-27
lines changed

6 files changed

+28
-27
lines changed

deploy/containers/nginx/conf/nginx.dev.conf

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ http {
6666
proxy_set_header Connection $connection_upgrade;
6767
}
6868

69-
location /api/ {
69+
location /api {
7070
proxy_pass_header Server;
7171
proxy_set_header Host $http_host;
7272
proxy_redirect off;
7373
proxy_set_header X-Real-IP $remote_addr;
7474
proxy_set_header X-Scheme $scheme;
75-
proxy_pass https://portalproxy/api/;
75+
proxy_pass https://portalproxy;
7676
proxy_intercept_errors on;
7777
proxy_http_version 1.1;
7878
proxy_set_header Upgrade $http_upgrade;

deploy/containers/nginx/conf/nginx.k8s.conf

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@ http {
6666
proxy_set_header Connection $connection_upgrade;
6767
}
6868

69-
location /api/ {
69+
location /api {
7070
proxy_pass_header Server;
7171
proxy_set_header Host $http_host;
7272
proxy_redirect off;
7373
proxy_set_header X-Real-IP $remote_addr;
7474
proxy_set_header X-Scheme $scheme;
75-
proxy_pass https://portalproxy/api/;
75+
proxy_pass https://portalproxy;
7676
proxy_intercept_errors on;
7777
proxy_http_version 1.1;
7878
proxy_set_header Upgrade $http_upgrade;
7979
proxy_set_header Connection $connection_upgrade;
80-
}
80+
}
8181

8282
location / {
8383
root /usr/share/nginx/html;

deploy/kubernetes/console/templates/NOTES.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Get the URL by running these commands in the same shell:
2828
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ .Release.Name }}-ui-ext -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
2929
echo http://$SERVICE_IP:{{ .Values.console.service.servicePort }}
3030
{{- else if contains "ClusterIP" .Values.console.service.type }}
31-
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app=stratos-0,component=ui" -o jsonpath="{.items[0].metadata.name}")
31+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ .Release.Name }},component=stratos" -o jsonpath="{.items[0].metadata.name}")
3232
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 443
3333
{{- end }}
3434
{{- end }}

src/frontend/packages/cloud-foundry/src/features/applications/deploy-application/deploy-application-deployer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ export class DeployApplicationDeployer {
341341
break;
342342
case SocketEventTypes.CLOSE_FAILED_CLONE:
343343
this.onClose(log, 'Deploy Failed - Failed to clone repository!',
344-
'Failed to deploy app! Please make sure the repository is public.');
344+
'Failed to deploy app! Please make sure the repository is accessible.');
345345
break;
346346
case SocketEventTypes.CLOSE_FAILED_NO_BRANCH:
347347
this.onClose(log, 'Deploy Failed - Failed to located branch!',

src/jetstream/plugins/cfapppush/deploy.go

+17-17
Original file line numberDiff line numberDiff line change
@@ -389,29 +389,27 @@ func (cfAppPush *CFAppPush) getGitSCMSource(clientWebSocket *websocket.Conn, tem
389389
}
390390

391391
loggerURL := info.URL
392+
cloneURL := info.URL
392393

394+
// Apply credentials associated with the endpoint
393395
if len(info.EndpointGUID) != 0 {
394396
parsedURL, err := url.Parse(info.URL)
395397
if err != nil {
396398
return StratosProject{}, tempDir, errors.New("Failed to parse SCM URL")
397399
}
398400

399-
// mask the credentials for the logs
400-
401401
tokenRecord, isTokenFound := cfAppPush.portalProxy.GetCNSITokenRecord(info.EndpointGUID, userGUID)
402-
if !isTokenFound {
403-
loggerURL = parsedURL.String()
404-
} else {
405-
var (
406-
username string
407-
password string
408-
)
409-
402+
if isTokenFound {
410403
authTokenDecodedBytes, err := base64.StdEncoding.DecodeString(tokenRecord.AuthToken)
411404
if err != nil {
412405
return StratosProject{}, tempDir, errors.New("Failed to decode auth token")
413406
}
414407

408+
var (
409+
username string
410+
password string
411+
)
412+
415413
switch info.SCM {
416414
case SCM_TYPE_GITHUB:
417415
// GitHub API uses token auth: username and password are stored in the token information
@@ -429,20 +427,22 @@ func (cfAppPush *CFAppPush) getGitSCMSource(clientWebSocket *websocket.Conn, tem
429427
return StratosProject{}, tempDir, errors.New("Username is empty")
430428
}
431429

430+
// mask the credentials for the logs and env var
432431
parsedURL.User = url.UserPassword("REDACTED", "REDACTED")
433432
loggerURL = parsedURL.String()
434433

434+
// apply the correct credentials
435435
parsedURL.User = url.UserPassword(username, password)
436+
cloneURL = parsedURL.String()
436437
}
437-
438-
info.URL = parsedURL.String()
439438
}
440439

441440
log.Debugf("GitSCM SCM: %s, Source: %s, branch %s, url: %s", info.SCM, info.Project, info.Branch, loggerURL)
442441
cloneDetails := CloneDetails{
443-
Url: info.URL,
444-
Branch: info.Branch,
445-
Commit: info.CommitHash,
442+
Url: cloneURL,
443+
LoggerUrl: loggerURL,
444+
Branch: info.Branch,
445+
Commit: info.CommitHash,
446446
}
447447
info.CommitHash, err = cloneRepository(cloneDetails, clientWebSocket, tempDir)
448448
if err != nil {
@@ -594,7 +594,7 @@ func cloneRepository(cloneDetails CloneDetails, clientWebSocket *websocket.Conn,
594594

595595
if len(cloneDetails.Branch) == 0 {
596596
err := errors.New("No branch supplied")
597-
log.Infof("Failed to checkout repo %s due to %+v", cloneDetails.Url, err)
597+
log.Infof("Failed to checkout repo %s due to %+v", cloneDetails.LoggerUrl, err)
598598
sendErrorMessage(clientWebSocket, err, CLOSE_FAILED_NO_BRANCH)
599599
return "", err
600600
}
@@ -603,7 +603,7 @@ func cloneRepository(cloneDetails CloneDetails, clientWebSocket *websocket.Conn,
603603

604604
err := vcsGit.Create(tempDir, cloneDetails.Url, cloneDetails.Branch)
605605
if err != nil {
606-
log.Infof("Failed to clone repo %s due to %+v", cloneDetails.Url, err)
606+
log.Infof("Failed to clone repo %s due to %+v", cloneDetails.LoggerUrl, err)
607607
sendErrorMessage(clientWebSocket, err, CLOSE_FAILED_CLONE)
608608
return "", err
609609
}

src/jetstream/plugins/cfapppush/types.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ type Applications struct {
117117
}
118118

119119
type CloneDetails struct {
120-
Url string
121-
Branch string
122-
Commit string
120+
Url string
121+
LoggerUrl string
122+
Branch string
123+
Commit string
123124
}

0 commit comments

Comments
 (0)