Skip to content

Commit

Permalink
wip: show initial preflight page for helm chart preflights
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig O'Donnell committed Jan 26, 2024
1 parent ce358e8 commit ee9bedb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
23 changes: 19 additions & 4 deletions pkg/store/kotsstore/version_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,11 +546,26 @@ func (s *KOTSStore) upsertAppVersionStatements(appID string, sequence int64, bas

appIcon := kotsKinds.KotsApplication.Spec.Icon

renderedPreflight, err := s.renderPreflightSpec(appID, a.Slug, sequence, a.IsAirgap, kotsKinds, renderer)
tsKinds, err := kotsutil.LoadTSKindsFromPath(filepath.Join(filesInDir, "rendered"))
if err != nil {
return nil, errors.Wrap(err, "failed to render app preflight spec")
return nil, errors.Wrap(err, "failed to load troubleshoot kinds from path")
}
kotsKinds.Preflight = renderedPreflight

var builtPreflight *troubleshootv1beta2.Preflight
if tsKinds.PreflightsV1Beta2 != nil {
for _, v := range tsKinds.PreflightsV1Beta2 {
builtPreflight = troubleshootpreflight.ConcatPreflightSpec(builtPreflight, &v)
}
fmt.Println("***** loaded preflight from rendered")
} else {
renderedPreflight, err := s.renderPreflightSpec(appID, a.Slug, sequence, a.IsAirgap, kotsKinds, renderer)
if err != nil {
return nil, errors.Wrap(err, "failed to render app preflight spec")
}
builtPreflight = renderedPreflight
fmt.Println("***** loaded preflight from kotskinds")
}
kotsKinds.Preflight = builtPreflight

renderedApplication, err := s.renderApplicationSpec(appID, a.Slug, sequence, a.IsAirgap, kotsKinds, renderer)
if err != nil {
Expand Down Expand Up @@ -613,7 +628,7 @@ func (s *KOTSStore) upsertAppVersionStatements(appID string, sequence int64, bas
for _, d := range downstreams {
// there's a small chance this is not optimal, but no current code path
// will support multiple downstreams, so this is cleaner here for now
hasStrictPreflights, err := troubleshootpreflight.HasStrictAnalyzers(renderedPreflight)
hasStrictPreflights, err := troubleshootpreflight.HasStrictAnalyzers(builtPreflight)
if err != nil {
return nil, errors.Wrap(err, "failed to check strict preflights from spec")
}
Expand Down
18 changes: 9 additions & 9 deletions web/src/features/AppConfig/components/AppConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ class AppConfig extends Component<Props, State> {
}
window.addEventListener("resize", this.determineSidebarHeight);

if (!this.props.app) {
this.getApp();
if (!app) {
this.fetchApp();
} else {
this.setState({ app });
}
this.getConfig();
}
Expand Down Expand Up @@ -204,11 +206,7 @@ class AppConfig extends Component<Props, State> {
}
};

getApp = async () => {
if (this.props.app) {
return;
}

fetchApp = async (): Promise<App | undefined> => {
try {
const { slug } = this.props.params;
const res = await fetch(`${process.env.API_ENDPOINT}/app/${slug}`, {
Expand All @@ -221,6 +219,7 @@ class AppConfig extends Component<Props, State> {
if (res.ok && res.status == 200) {
const app = await res.json();
this.setState({ app });
return app;
}
} catch (err) {
console.log(err);
Expand Down Expand Up @@ -416,7 +415,8 @@ class AppConfig extends Component<Props, State> {
}

if (fromLicenseFlow) {
const hasPreflight = this.props.app.hasPreflight;
const app = await this.fetchApp();
const hasPreflight = app?.hasPreflight;

if (hasPreflight) {
navigate(`/${slug}/preflight`, { replace: true });
Expand Down Expand Up @@ -661,6 +661,7 @@ class AppConfig extends Component<Props, State> {

render() {
const {
app,
changed,
showConfigError,
configErrorMessage,
Expand All @@ -675,7 +676,6 @@ class AppConfig extends Component<Props, State> {
showValidationError,
} = this.state;
const { fromLicenseFlow, params, isHelmManaged } = this.props;
const app = this.props.app;

if (configLoading || !app) {
return (
Expand Down

0 comments on commit ee9bedb

Please sign in to comment.