Skip to content

Commit

Permalink
Try to fix various git issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mirandachrist committed Jun 19, 2019
1 parent d8131de commit c1bd203
Show file tree
Hide file tree
Showing 8 changed files with 1,104 additions and 53 deletions.
8 changes: 4 additions & 4 deletions prow/cmd/deck/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,14 @@ func prodOnlyMain(cfg config.Getter, o options, mux *http.ServeMux) *http.ServeM
githubOAuthConfig.InitGitHubOAuthConfig(cookie)

goa := githuboauth.NewAgent(&githubOAuthConfig, logrus.WithField("client", "githuboauth"))
oauthClient := &oauth2.Config{
oauthClient := githuboauth.NewClient(&oauth2.Config{
ClientID: githubOAuthConfig.ClientID,
ClientSecret: githubOAuthConfig.ClientSecret,
RedirectURL: githubOAuthConfig.RedirectURL,
Scopes: githubOAuthConfig.Scopes,
Endpoint: github.Endpoint,
}
},
)

repoSet := make(map[string]bool)
for r := range cfg().Presubmits {
Expand Down Expand Up @@ -1211,6 +1212,5 @@ func handleFavicon(staticFilesLocation string, cfg config.Getter) http.HandlerFu

func isValidatedGitOAuthConfig(githubOAuthConfig *config.GitHubOAuthConfig) bool {
return githubOAuthConfig.ClientID != "" && githubOAuthConfig.ClientSecret != "" &&
githubOAuthConfig.RedirectURL != "" &&
githubOAuthConfig.FinalRedirectURL != ""
githubOAuthConfig.RedirectURL != ""
}
15 changes: 15 additions & 0 deletions prow/cmd/deck/static/common/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,18 @@ export namespace tidehistory {
return link;
}
}

export function getCookieByName(name: string): string {
if (!document.cookie) {
return "";
}
const docCookies = decodeURIComponent(document.cookie).split(";");
for (const cookie of docCookies) {
const c = cookie.trim();
const pref = name + "=";
if (c.indexOf(pref) === 0) {
return c.slice(pref.length);
}
}
return "";
}
22 changes: 2 additions & 20 deletions prow/cmd/deck/static/pr/pr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {Context} from '../api/github';
import {Label, PullRequest, UserData} from '../api/pr';
import {Job, JobState} from '../api/prow';
import {Blocker, TideData, TidePool, TideQuery as ITideQuery} from '../api/tide';
import {tidehistory} from '../common/common';
import {getCookieByName, tidehistory} from '../common/common';

declare const tideData: TideData;
declare const allBuilds: Job[];
Expand Down Expand Up @@ -179,24 +179,6 @@ function onLoadQuery(): string {
return "";
}

/**
* Gets cookie by its name.
*/
function getCookieByName(name: string): string {
if (!document.cookie) {
return "";
}
const cookies = decodeURIComponent(document.cookie).split(";");
for (const cookie of cookies) {
const c = cookie.trim();
const pref = name + "=";
if (c.indexOf(pref) === 0) {
return c.slice(pref.length);
}
}
return "";
}

/**
* Creates an alert for merge blocking issues on tide.
*/
Expand Down Expand Up @@ -1154,7 +1136,7 @@ function createPRCard(pr: PullRequest, builds: UnifiedContext[] = [], queries: P
* Redirect to initiate github login flow.
*/
function forceGitHubLogin(): void {
window.location.href = window.location.origin + "/github-login";
window.location.href = window.location.origin + "/github-login?dest=%2Fpr";
}

type VagueState = "succeeded" | "failed" | "pending" | "unknown";
Expand Down
28 changes: 26 additions & 2 deletions prow/cmd/deck/static/prow/prow.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import moment from "moment";
import {Job, JobState, JobType} from "../api/prow";
import {cell, icon} from "../common/common";
import {cell, getCookieByName, icon} from "../common/common";
import {FuzzySearch} from './fuzzy-search';
import {JobHistogram, JobSample} from './histogram';

Expand Down Expand Up @@ -397,6 +397,7 @@ function escapeRegexLiteral(s: string): string {
}

function redraw(fz: FuzzySearch): void {
const rerunStatus = getParameterByName("rerun");
const modal = document.getElementById('rerun')!;
const rerunCommand = document.getElementById('rerun-content')!;
window.onclick = (event) => {
Expand Down Expand Up @@ -648,12 +649,18 @@ function redraw(fz: FuzzySearch): void {
max = 2 * 3600;
}
drawJobHistogram(totalJob, jobHistogram, now - (12 * 3600), now, max);
if (rerunStatus != null) {
modal.style.display = "block";
rerunCommand.innerHTML = `Nice try! The direct rerun feature hasn't been implemented yet, so that button does nothing.`;
}

}

function createRerunCell(modal: HTMLElement, rerunElement: HTMLElement, prowjob: string): HTMLTableDataCellElement {
const url = `https://${window.location.hostname}/rerun?prowjob=${prowjob}`;
const url = `/rerun?prowjob=${prowjob}`;
const c = document.createElement("td");
const i = icon.create("refresh", "Show instructions for rerunning this job");
const login = getCookieByName("github_login");
i.onclick = () => {
modal.style.display = "block";
rerunElement.innerHTML = `kubectl create -f "<a href="${url}">${url}</a>"`;
Expand All @@ -662,6 +669,23 @@ function createRerunCell(modal: HTMLElement, rerunElement: HTMLElement, prowjob:
copyButton.onclick = () => copyToClipboardWithToast(`kubectl create -f "${url}"`);
copyButton.innerHTML = "<i class='material-icons state triggered' style='color: gray'>file_copy</i>";
rerunElement.appendChild(copyButton);
const runButton = document.createElement('a');
runButton.innerHTML = "<button class='mdl-button mdl-js-button'>Run</button>";
if (login === "") {
runButton.href = `/github-login?dest=%2F?rerun=work_in_progress`;
} else {
if (rerunCreatesJob) {
runButton.onclick = () => {
const form = document.createElement('form');
form.method = 'POST';
form.action = `${url}`;
c.appendChild(form);
form.submit();
};
}
runButton.href = `/?rerun=work_in_progress`;
}
rerunElement.appendChild(runButton);
};
c.appendChild(i);
c.classList.add("icon-cell");
Expand Down
Loading

0 comments on commit c1bd203

Please sign in to comment.