@wtf/release-oci 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -121,7 +121,7 @@ build as an argument of its own.
121
121
  | `./images` | `readImages`, `imagesAt`, `imagesOf`, `imageDirOf`, `repositoryOf` |
122
122
  | `./tags` | `tagsOfRelease`, `releaseTagsOf`, `checkReleaseTags` |
123
123
  | `./publish` | `smokeImages`, `publishImages`, `digestOf`, `platformsOf` |
124
- | `./registry` | `registryPageOf` |
124
+ | `./registry` | `registryPageOf`, `checkRegistryAccess` |
125
125
  | `./errors` | `OciError`, `OCI_ERRORS` |
126
126
 
127
127
  ## Errors
@@ -4,6 +4,9 @@
4
4
  * repositories, `GET /projects/<id>/registry/repositories`, each of its `location`, as
5
5
  * `registry.gitlab.com/acme/images/base`, and its ID, whose page is
6
6
  * `<project>/container_registry/<id>`. An image is linked where it lives, never uploaded.
7
+ * {@link checkRegistryAccess} asks the same API once, before anything is released, whether the
8
+ * headers may read it: GitLab's job token may not, so a run of it alone fails there, not after the
9
+ * images are copied.
7
10
  *
8
11
  * ```ts
9
12
  * import { registryPageOf } from '@wtf/release-oci/registry'
@@ -43,4 +46,15 @@ export interface RegistryQuery {
43
46
  * @returns The URL of the page of the image.
44
47
  */
45
48
  export declare function registryPageOf(query: RegistryQuery): Promise<string>;
49
+ /** What {@link checkRegistryAccess} asks: a registry query of no repository. */
50
+ export type RegistryAccess = Omit<RegistryQuery, 'repository'>;
51
+ /**
52
+ * Checks that `headers` may read the container registry of `project`, by one request of no
53
+ * effect, `GET /projects/<id>/registry/repositories?per_page=1`, as {@link registryPageOf} needs it
54
+ * to: a token of the `read_api` or `api` scope may; the job token of a pipeline, `CI_JOB_TOKEN`, may
55
+ * not. Throws `EOCILINK` of a request GitLab refuses or that cannot be made.
56
+ *
57
+ * @param query - The `fetch`, the project and the headers.
58
+ */
59
+ export declare function checkRegistryAccess(query: RegistryAccess): Promise<void>;
46
60
  //# sourceMappingURL=registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAI1E,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;IACzB,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAA;IAC/B,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACnD;AAQD;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CA+B1E"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAI1E,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;IACzB,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAA;IAC/B,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACnD;AAQD;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CA+B1E;AAED,gFAAgF;AAChF,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,CAAA;AAE9D;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAc9E"}
package/dist/registry.js CHANGED
@@ -33,4 +33,24 @@ export async function registryPageOf(query) {
33
33
  throw new OciError('EOCILINK', `The container registry of ${project.path} lists no repository ${repository}.`, 'Publish the image to the registry of the project of the release, whose page the release links: its repository is `CI_REGISTRY_IMAGE`, of its folder.');
34
34
  return `${project.url}/container_registry/${found.id}`;
35
35
  }
36
+ /**
37
+ * Checks that `headers` may read the container registry of `project`, by one request of no
38
+ * effect, `GET /projects/<id>/registry/repositories?per_page=1`, as {@link registryPageOf} needs it
39
+ * to: a token of the `read_api` or `api` scope may; the job token of a pipeline, `CI_JOB_TOKEN`, may
40
+ * not. Throws `EOCILINK` of a request GitLab refuses or that cannot be made.
41
+ *
42
+ * @param query - The `fetch`, the project and the headers.
43
+ */
44
+ export async function checkRegistryAccess(query) {
45
+ const { fetch, project, headers } = query;
46
+ const url = `${project.api}/projects/${project.id}/registry/repositories?per_page=1`;
47
+ try {
48
+ const response = await fetch(url, { method: 'GET', headers: { ...headers } });
49
+ if (!response.ok)
50
+ throw new Error(`GitLab answered ${response.status}: ${await response.text()}`);
51
+ }
52
+ catch (error) {
53
+ throw new OciError('EOCILINK', `The container registry of ${project.path} cannot be read, at ${url}: ${error.message}`, 'Give the run a token that may read the API of the project, `GITLAB_TOKEN` of the `read_api` or `api` scope: GitLab refuses the job token, `CI_JOB_TOKEN`, there.');
54
+ }
55
+ }
36
56
  //# sourceMappingURL=registry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,QAAQ,EAAE,MAAM,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O,EAAE,EAClG,kKAAkK,CACnK,CAAA;IACH,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtf/release-oci",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "The OCI images of a repo released in trains and tagged in their registry, of no release tool and no rebuild, each function by the System it is given: the ecosystem of OCI images, as the trains read it, its default export (., ./ecosystem), the images of a repo, each folder of a Dockerfile, a Containerfile or a .devcontainer/devcontainer.json git tracks, of the working tree or of a commit (./images), the tags of a release, its version and of a release the moving minor and major (./tags), the tested image of each found by its digest and copied to the tags of the release by crane, a full version the registry has at another digest refused (./publish), the page of each image in the container registry of GitLab (./registry), and OciError, the class of its errors, with their codes (./errors).",
5
5
  "keywords": [
6
6
  "container",