Skip to main content

Read a scaffold file of a template change preview of a library

POST 

/libraries/:libraryId/template/preview/file

Returns the content of one scaffold file of the template change preview: one of the preview's otherFiles, rendered from the target template with the resource's properties. Read-only: nothing is written and no build is started. The UI and agents call it on demand, when the user wants to see a file.


Body: the same as POST .../template/preview without includePaths (it is not part of this body), plus path, exactly one of that preview's otherFiles[].path. Any other path, including .codenow.yaml, Dockerfile and the helm/ files (they are in the preview's files[]), is rejected with E7017.


Response: path, inRepository, binary and vsRepository {result, current, target} with base64-encoded contents: current is the file on the default branch, target the rendering. result is CHANGED or IDENTICAL for a file already in the repository, TARGET_ONLY with current: null for a new one. vsRepository is omitted when binary is true (the content is not text, e.g. a Gradle wrapper jar): the content of a binary file is not returned; to get the file, include its path in includePaths so it is committed to the branch.


CodeNOW does not require these files: the change (PUT .../template) commits one to its branch only when it is in includePaths; otherwise the user applies it by hand, as far as the resource needs it.


Errors (problem+json, parameters.errorId where CodeNOW assigns a code): the same as the preview — 400 E7011 / E7001 or a property / not-ready rejection, 403, 404, 502 E7014, 502 (too large) / 504 (no answer in time) without errorId — plus 400 E7017 when path is not one of the preview's otherFiles. 400 E7020 the target template itself cannot be rendered (context: templateId, version, path; the message names the template, the file and the line). Nothing was changed. Do not retry and do not vary properties: tell the user. A running build does not block it: it never returns 409.

Request​

Responses​

The rendered file and its comparison with the repository; nothing was changed