- Notifications
You must be signed in to change notification settings - Fork1k
fix(site): Prompting user for missing variables#7002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -5,25 +5,27 @@ import { DeploymentConfig } from "./types" | ||
import * as TypesGen from "./typesGenerated" | ||
// Adds 304 for the default axios validateStatus function | ||
// https://github.com/axios/axios#handling-errors Check status here | ||
// https://httpstatusdogs.com/ | ||
axios.defaults.validateStatus = (status) => { | ||
return (status >= 200 && status < 300) || status === 304 | ||
} | ||
export const hardCodedCSRFCookie = (): string => { | ||
// This is a hard coded CSRF token/cookie pair for local development. In prod, | ||
// the GoLang webserver generates a random cookie with a new token for each | ||
// document request. For local development, we don't use the Go webserver for | ||
// static files, so this is the 'hack' to make local development work with | ||
// remote apis. The CSRF cookie for this token is | ||
// "JXm9hOUdZctWt0ZZGAy9xiS/gxMKYOThdxjjMnMUyn4=" | ||
const csrfToken = | ||
"KNKvagCBEHZK7ihe2t7fj6VeJ0UyTDco1yVUJE8N06oNqxLu5Zx1vRxZbgfC0mJJgeGkVjgs08mgPbcWPBkZ1A==" | ||
axios.defaults.headers.common["X-CSRF-TOKEN"] = csrfToken | ||
return csrfToken | ||
} | ||
// withDefaultFeatures sets all unspecified features to not_entitled and | ||
// disabled. | ||
export const withDefaultFeatures = ( | ||
fs: Partial<TypesGen.Entitlements["features"]>, | ||
): TypesGen.Entitlements["features"] => { | ||
@@ -40,9 +42,8 @@ export const withDefaultFeatures = ( | ||
return fs as TypesGen.Entitlements["features"] | ||
} | ||
// Always attach CSRF token to all requests. In puppeteer the document is | ||
// undefined. In those cases, just do nothing. | ||
const token = | ||
typeof document !== "undefined" | ||
? document.head.querySelector('meta[property="csrf-token"]') | ||
@@ -978,7 +979,8 @@ export class MissingBuildParameters extends Error { | ||
* - Get the latest template to access the latest active version | ||
* - Get the current build parameters | ||
* - Get the template parameters | ||
* - Update the build parameters and check if there are missed parameters for | ||
* the newest version | ||
* - If there are missing parameters raise an error | ||
* - Create a build with the latest version and updated build parameters | ||
*/ | ||
@@ -1017,12 +1019,22 @@ const getMissingParameters = ( | ||
templateParameters: TypesGen.TemplateVersionParameter[], | ||
) => { | ||
const missingParameters: TypesGen.TemplateVersionParameter[] = [] | ||
const requiredParameters: TypesGen.TemplateVersionParameter[] = [] | ||
templateParameters.forEach((p) => { | ||
// Legacy parameters should be required. So we can migrate them. | ||
const isLegacy = p.legacy_variable_name === undefined | ||
// It is mutable and required. Mutable values can be changed after so we | ||
// don't need to ask them if they are not required. | ||
const isMutableAndRequired = p.mutable && p.required | ||
// Is immutable, so we can check if it is its first time on the build | ||
const isImmutable = !p.mutable | ||
if (isLegacy || isMutableAndRequired || isImmutable) { | ||
requiredParameters.push(p) | ||
return | ||
} | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Let me try it locally... | ||
for (const parameter of requiredParameters) { | ||
// Check if there is a new value | ||
@@ -1049,7 +1061,8 @@ const getMissingParameters = ( | ||
/** | ||
* | ||
* @param agentId | ||
* @returns An EventSource that emits agent metadata event objects | ||
* (ServerSentEvent) | ||
*/ | ||
export const watchAgentMetadata = (agentId: string): EventSource => { | ||
return new EventSource( | ||