Skip to content

Commit

Permalink
Yaml errors for all app versions (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
emosbaugh committed May 22, 2020
1 parent b2e3ffc commit 56f2eba
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 15 deletions.
15 changes: 8 additions & 7 deletions kotsadm/api/src/kots_app/graphql/kots_app_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ const KotsGitOpsInput = `
}
`;

const InstallationYamlError = `
type InstallationYamlError {
path: String!
error: String
}
`

const KotsVersion = `
type KotsVersion {
title: String!
Expand All @@ -88,16 +95,10 @@ const KotsVersion = `
preflightResultCreatedAt: String
commitUrl: String
gitDeployable: Boolean
yamlErrors: [InstallationYamlError]
}
`;

const InstallationYamlError = `
type InstallationYamlError {
path: String!
error: String
}
`

// midstream
const KotsAppVersion = `
type KotsAppVersion {
Expand Down
1 change: 1 addition & 0 deletions kotsadm/api/src/kots_app/kots_app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ export interface KotsVersion {
diffSummary?: string;
commitUrl?: string;
gitDeployable?: boolean;
yamlErrors?: InstallationYAMLError[];
}

export interface AppRegistryDetails {
Expand Down
49 changes: 41 additions & 8 deletions kotsadm/api/src/kots_app/kots_app_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,14 @@ export class KotsAppStore {
adv.preflight_result_created_at,
adv.git_commit_url,
adv.git_deployable,
ado.is_error AS has_error
ado.is_error AS has_error,
av.kots_installation_spec
FROM
app_downstream_version AS adv
LEFT JOIN
app_version AS av
ON
adv.app_id = av.app_id AND adv.sequence = av.sequence
LEFT JOIN
app_downstream_output AS ado
ON
Expand Down Expand Up @@ -748,6 +753,14 @@ export class KotsAppStore {
commitUrl: row.git_commit_url || "",
gitDeployable: row.git_deployable
};
if (row.kots_installation_spec) {
try {
const installationSpec = yaml.safeLoad(row.kots_installation_spec).spec as InstallationSpec;
versionItem.yamlErrors = installationSpec.yamlErrors;
} catch (err) {
console.log(`Failed to unmarshal installation spec yaml for sequence ${versionItem.sequence}`, err);
}
}
versionItems.push(versionItem);
}

Expand All @@ -772,11 +785,13 @@ export class KotsAppStore {
sequence = -1;
}

q = `select created_at, version_label, status, sequence, parent_sequence,
applied_at, source, diff_summary, preflight_result, preflight_result_created_at, git_commit_url, git_deployable
from app_downstream_version
where app_id = $1 and cluster_id = $3 and sequence > $2
order by sequence desc`;
q = `select adv.created_at, adv.version_label, adv.status, adv.sequence, adv.parent_sequence,
adv.applied_at, adv.source, adv.diff_summary, adv.preflight_result, adv.preflight_result_created_at, adv.git_commit_url, adv.git_deployable,
av.kots_installation_spec
from app_downstream_version as adv
left join app_version as av on adv.app_id = av.app_id and adv.sequence = av.sequence
where adv.app_id = $1 and adv.cluster_id = $3 and adv.sequence > $2
order by adv.sequence desc`;

v = [
appId,
Expand Down Expand Up @@ -805,6 +820,14 @@ order by sequence desc`;
commitUrl: row.git_commit_url || "",
gitDeployable: row.git_deployable
};
if (row.kots_installation_spec) {
try {
const installationSpec = yaml.safeLoad(row.kots_installation_spec).spec as InstallationSpec;
versionItem.yamlErrors = installationSpec.yamlErrors;
} catch (err) {
console.log(`Failed to unmarshal installation spec yaml for sequence ${versionItem.sequence}`, err);
}
}
versionItems.push(versionItem);
}

Expand Down Expand Up @@ -928,8 +951,10 @@ order by sequence desc`;

q = `select adv.created_at, adv.version_label, adv.status, adv.sequence,
adv.parent_sequence, adv.applied_at, adv.source, adv.diff_summary, adv.preflight_result,
adv.preflight_result_created_at, adv.git_commit_url, adv.git_deployable, ado.is_error AS has_error
adv.preflight_result_created_at, adv.git_commit_url, adv.git_deployable, ado.is_error AS has_error,
av.kots_installation_spec
from app_downstream_version as adv
left join app_version as av on adv.app_id = av.app_id and adv.sequence = av.sequence
left join app_downstream_output as ado
on adv.app_id = ado.app_id and adv.cluster_id = ado.cluster_id and adv.sequence = ado.downstream_sequence
where adv.app_id = $1 and adv.cluster_id = $3 and adv.sequence = $2
Expand Down Expand Up @@ -965,6 +990,14 @@ order by adv.sequence desc`;
commitUrl: row.git_commit_url || "",
gitDeployable: row.git_deployable
};
if (row.kots_installation_spec) {
try {
const installationSpec = yaml.safeLoad(row.kots_installation_spec).spec as InstallationSpec;
versionItem.yamlErrors = installationSpec.yamlErrors;
} catch (err) {
console.log(`Failed to unmarshal installation spec yaml for sequence ${versionItem.sequence}`, err);
}
}

return versionItem;
}
Expand Down Expand Up @@ -1020,7 +1053,7 @@ where app_id = $1 and sequence = $2`;
const installationSpec = yaml.safeLoad(row.kots_installation_spec).spec as InstallationSpec;
versionItem.yamlErrors = installationSpec.yamlErrors;
} catch (err) {
console.log("Failed to unmarshal installation spec yaml", err);
console.log(`Failed to unmarshal installation spec yaml for sequence ${versionItem.sequence}`, err);
}
}

Expand Down
36 changes: 36 additions & 0 deletions kotsadm/web/src/queries/AppsQueries.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export const listAppsRaw = `
createdOn
sequence
deployedAt
yamlErrors {
path
error
}
}
gitops {
enabled
Expand All @@ -59,13 +63,21 @@ export const listAppsRaw = `
createdOn
sequence
deployedAt
yamlErrors {
path
error
}
}
pastVersions {
title
status
createdOn
sequence
deployedAt
yamlErrors {
path
error
}
}
cluster {
id
Expand All @@ -79,6 +91,10 @@ export const listAppsRaw = `
createdOn
sequence
deployedAt
yamlErrors {
path
error
}
}
shipOpsRef {
token
Expand Down Expand Up @@ -139,6 +155,10 @@ export const getKotsAppRaw = `
source
releaseNotes
parentSequence
yamlErrors {
path
error
}
}
pendingVersions {
title
Expand All @@ -147,6 +167,10 @@ export const getKotsAppRaw = `
sequence
deployedAt
parentSequence
yamlErrors {
path
error
}
}
pastVersions {
title
Expand All @@ -155,6 +179,10 @@ export const getKotsAppRaw = `
sequence
deployedAt
parentSequence
yamlErrors {
path
error
}
}
gitops {
enabled
Expand All @@ -180,6 +208,10 @@ export const getKotsAppRaw = `
createdOn
sequence
deployedAt
yamlErrors {
path
error
}
}
shipOpsRef {
token
Expand All @@ -206,6 +238,10 @@ export const listDownstreamsForAppRaw = `
createdOn
sequence
deployedAt
yamlErrors {
path
error
}
}
shipOpsRef {
token
Expand Down

0 comments on commit 56f2eba

Please sign in to comment.