Skip to content

Commit

Permalink
set version preflight_spec if preflights are inside helm chart templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig O'Donnell committed Jan 30, 2024
1 parent 2b655b4 commit 4dfe0a2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
16 changes: 14 additions & 2 deletions pkg/store/kotsstore/version_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,21 @@ 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")
}

var renderedPreflight *troubleshootv1beta2.Preflight
if tsKinds.PreflightsV1Beta2 != nil {
for _, v := range tsKinds.PreflightsV1Beta2 {
renderedPreflight = troubleshootpreflight.ConcatPreflightSpec(renderedPreflight, &v)
}
} 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")
}
}
kotsKinds.Preflight = renderedPreflight

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 4dfe0a2

Please sign in to comment.