Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions web/src/model/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ describe('catalog', () => {
expect(resolveCreateCatalog([imageOnly], [definition], 'sample-image')?.template).toBe(imageOnly)
})

test('marketplace definitions are never paired with a template, even when listed first with the same shape', () => {
const marketplace: ApplicationStackDefinition = { ...definition, id: 'builder-console', catalogSource: 'appthrust' }
expect(resolveCreateCatalog([template], [marketplace, definition], 'github-template')?.definitionRef?.name).toBe(definition.id)
expect(resolveCreateCatalog([template], [marketplace], 'github-template')).toBeUndefined()
})

test('template allowlists trim and ignore case like the Platform validator; empty allowlists admit all templates', () => {
const blocked = { ...sourceConnection, allowedRepositories: ['appthrust/template-other'] }
expect(templateSourceProblem(template, [blocked])).toBe('not-admitted')
Expand Down
9 changes: 6 additions & 3 deletions web/src/model/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,11 @@ export function templatesFor(

/**
* Picks the requested (or default, or first) template for the source kind, and
* the stack definition whose component count matches it. Templates do not
* reference a definition, so the pairing is structural.
* the platform-shipped stack definition whose component count matches it.
* Templates do not reference a definition, so the pairing is structural;
* marketplace apps (`catalogSource` set, owned by an AppCatalogSource) are
* ApplicationStackDefinitions too and must never be candidates, or the template
* deploys that app's image under the user's name.
*/
export function resolveCreateCatalog(
templates: readonly ApplicationTemplateSummary[],
Expand All @@ -168,7 +171,7 @@ export function resolveCreateCatalog(
const candidates = templatesFor(templates, sourceKind)
const template = templateId ? candidates.find((item) => item.id === templateId) : candidates[0]
if (!template) return undefined
const definition = definitions.find((item) => item.components.length === template.components.length)
const definition = definitions.find((item) => !item.catalogSource && item.components.length === template.components.length)
if (!definition) return undefined
const version =
definition.versions?.find((item) => item.default && item.served !== false) ??
Expand Down