update
This commit is contained in:
parent
d9becc67b6
commit
9308795b8b
964 changed files with 104265 additions and 16 deletions
50
node_modules/docker-hub-utils/README.md
generated
vendored
Normal file
50
node_modules/docker-hub-utils/README.md
generated
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
<p align="center">
|
||||
<a href="https://github.com/jessestuart/docker-hub-utils">
|
||||
<img
|
||||
src="https://github.com/jessestuart/docker-hub-utils/blob/master/assets/nodejs-docker.png?raw=true"
|
||||
width="50%"
|
||||
/>
|
||||
</a>
|
||||
</p>
|
||||
<h1 align="center">
|
||||
docker-hub-utils
|
||||
</h1>
|
||||
|
||||
[![CircleCI][circleci-badge]][circleci-link] [![npm][npm-badge]][npm-link]
|
||||
[![codecov][codecov]][codecov 2]
|
||||
|
||||
### What is this?
|
||||
|
||||
`docker-hub-utils` is an [NPM package][npm-link] (packaged to work both in
|
||||
`node.js` as well as in the browser), providing utility functions wrapping the
|
||||
[Docker Hub API][docker 2]. This was created because the native API provides
|
||||
little to no support for basic operations like filtering queries, and can be
|
||||
quite verbose when e.g., fetching [Manifest Lists][docker], which is required to
|
||||
determine which architectures a given image supports.
|
||||
|
||||
---
|
||||
|
||||
### Currently supported operations
|
||||
|
||||
- Querying top repos by username / organization name.
|
||||
- Filtering top user / org repositories by date last updated; this is useful
|
||||
when you're only interested in repositories that have been updated in the past
|
||||
`N` months / years / etc, a feature missing from the native API.
|
||||
- Fetching Manifest Lists for any repository image in a single function call,
|
||||
abstracting away the bearer token authentication dance.
|
||||
|
||||
You can see examples of these operations in use within the
|
||||
[`docker-hub-graphql-api`][github 2] project, or in this project's test cases.
|
||||
|
||||
[circleci-badge]:
|
||||
https://circleci.com/gh/jessestuart/docker-hub-utils.svg?style=shield
|
||||
[circleci-link]: https://circleci.com/gh/jessestuart/docker-hub-utils
|
||||
[codecov 2]: https://codecov.io/gh/jessestuart/docker-hub-utils
|
||||
[codecov]:
|
||||
https://codecov.io/gh/jessestuart/docker-hub-utils/branch/master/graph/badge.svg
|
||||
[docker 2]: https://docs.docker.com/registry/spec/api/
|
||||
[docker]: https://docs.docker.com/registry/spec/manifest-v2-2/
|
||||
[github 2]: https://github.com/jessestuart/docker-hub-graphql-api
|
||||
[github]: https://github.com/jessestuart/multiar.ch
|
||||
[npm-badge]: https://img.shields.io/npm/v/docker-hub-utils.svg
|
||||
[npm-link]: https://www.npmjs.com/package/docker-hub-utils
|
272
node_modules/docker-hub-utils/dist/docker-hub-utils.cjs.development.js
generated
vendored
Normal file
272
node_modules/docker-hub-utils/dist/docker-hub-utils.cjs.development.js
generated
vendored
Normal file
|
@ -0,0 +1,272 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
var axios = _interopDefault(require('axios'));
|
||||
var camelcaseKeys = _interopDefault(require('camelcase-keys'));
|
||||
var luxon = require('luxon');
|
||||
var R = _interopDefault(require('ramda'));
|
||||
var pino = _interopDefault(require('pino'));
|
||||
|
||||
/**
|
||||
* Union type representing the architecture defined in part of an OCI image's
|
||||
* manifest list.
|
||||
*
|
||||
* As specified in the Docker Manifest spec, any valid GOARCH values are valid
|
||||
* image architecture values, and vice versa:
|
||||
* > The platform object describes the platform which the image in the manifest
|
||||
* > runs on. A full list of valid operating system and architecture values are
|
||||
* > listed in the Go language documentation for $GOOS and $GOARCH
|
||||
* @see https://docs.docker.com/registry/spec/manifest-v2-2/#manifest-list-field-descriptions
|
||||
*/
|
||||
|
||||
(function (Architecture) {
|
||||
Architecture["i386"] = "386";
|
||||
Architecture["amd64"] = "amd64";
|
||||
Architecture["arm"] = "arm";
|
||||
Architecture["arm64"] = "arm64";
|
||||
Architecture["mips"] = "mips";
|
||||
Architecture["mips64"] = "mips64";
|
||||
Architecture["mips64le"] = "mips64le";
|
||||
Architecture["mipsle"] = "mipsle";
|
||||
Architecture["ppc64"] = "ppc64";
|
||||
Architecture["ppc64le"] = "ppc64le";
|
||||
Architecture["s390x"] = "s390x";
|
||||
Architecture["wasm"] = "wasm";
|
||||
})(exports.Architecture || (exports.Architecture = {}));
|
||||
/**
|
||||
* Union type representing the OS defined in part of an OCI image's
|
||||
* manifest list.
|
||||
* See the docs for the `Architecture` type above for more info.
|
||||
*/
|
||||
|
||||
|
||||
var OS;
|
||||
|
||||
(function (OS) {
|
||||
OS["aix"] = "aix";
|
||||
OS["android"] = "android";
|
||||
OS["darwin"] = "darwin";
|
||||
OS["dragonfly"] = "dragonfly";
|
||||
OS["freebsd"] = "freebsd";
|
||||
OS["illumos"] = "illumos";
|
||||
OS["js"] = "js";
|
||||
OS["linux"] = "linux";
|
||||
OS["netbsd"] = "netbsd";
|
||||
OS["openbsd"] = "openbsd";
|
||||
OS["plan9"] = "plan9";
|
||||
OS["solaris"] = "solaris";
|
||||
OS["windows"] = "windows";
|
||||
})(OS || (OS = {}));
|
||||
|
||||
(function (ManifestMediaType) {
|
||||
ManifestMediaType["Manifest"] = "application/vnd.docker.distribution.manifest.v2+json";
|
||||
ManifestMediaType["ManifestList"] = "application/vnd.docker.distribution.manifest.list.v2+json";
|
||||
})(exports.ManifestMediaType || (exports.ManifestMediaType = {}));
|
||||
|
||||
var log = /*#__PURE__*/
|
||||
pino({
|
||||
base: null,
|
||||
useLevelLabels: true
|
||||
});
|
||||
|
||||
var DOCKER_HUB_API_ROOT = 'https://hub.docker.com/v2/';
|
||||
var DOCKER_HUB_API_AUTH_URL = 'https://auth.docker.io/token';
|
||||
|
||||
/**
|
||||
* Currently only supports fetching the manifest for the `latest` tag; in
|
||||
* reality, we can pass any valid content digest[1] to retrieve the manifest(s)
|
||||
* for that image.
|
||||
*
|
||||
* [1]: https://github.com/opencontainers/distribution-spec/blob/master/spec.md#content-digests
|
||||
*/
|
||||
|
||||
var createManifestListURL = function createManifestListURL(_ref) {
|
||||
var repo = _ref.repo;
|
||||
return "https://registry-1.docker.io/v2/" + repo.user + "/" + repo.name + "/manifests/latest";
|
||||
};
|
||||
|
||||
var createUserReposListURL = function createUserReposListURL(user) {
|
||||
return DOCKER_HUB_API_ROOT + "repositories/" + user;
|
||||
};
|
||||
/**
|
||||
* The OCI distribution spec requires a unique token for each repo manifest queried.
|
||||
*/
|
||||
|
||||
|
||||
var fetchDockerHubToken = function fetchDockerHubToken(repo) {
|
||||
try {
|
||||
var name = repo.name,
|
||||
user = repo.user;
|
||||
return Promise.resolve(axios.get(DOCKER_HUB_API_AUTH_URL, {
|
||||
params: {
|
||||
scope: "repository:" + user + "/" + name + ":pull",
|
||||
service: 'registry.docker.io'
|
||||
}
|
||||
})).then(function (tokenRequest) {
|
||||
var token = R.path(['data', 'token'], tokenRequest);
|
||||
|
||||
if (!token) {
|
||||
throw new Error('Unable to retrieve auth token from registry.');
|
||||
}
|
||||
|
||||
return token;
|
||||
});
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Pure function that massages the Docker Hub API response into the
|
||||
* format we want to return. e.g., only extracting certain fields;
|
||||
* converting snake_case to camelCase, etc.
|
||||
*/
|
||||
|
||||
var extractRepositoryDetails = function extractRepositoryDetails(repos, lastUpdatedSince) {
|
||||
if (!repos || R.isEmpty(repos)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var parsedRepos = camelcaseKeys(repos);
|
||||
|
||||
if (R.isNil(lastUpdatedSince)) {
|
||||
return parsedRepos;
|
||||
}
|
||||
|
||||
return parsedRepos.filter(function (repo) {
|
||||
return luxon.DateTime.fromISO(repo.lastUpdated) < lastUpdatedSince;
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Query a single repository given a repo name and username.
|
||||
*
|
||||
* @param user The DockerHub username or org name to query for.
|
||||
* @param name The DockerHub repo name -- restrict to this single repo.
|
||||
*/
|
||||
|
||||
var queryRepo = function queryRepo(_ref2) {
|
||||
var name = _ref2.name,
|
||||
user = _ref2.user;
|
||||
|
||||
try {
|
||||
return Promise.resolve(axios.request({
|
||||
url: DOCKER_HUB_API_ROOT + "repositories/" + user + "/" + name + "/"
|
||||
})).then(function (repoResult) {
|
||||
var repo = R.prop('data', repoResult);
|
||||
|
||||
if (repoResult.status !== 200 || !repo || R.isEmpty(repo)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return camelcaseKeys(repo);
|
||||
});
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Top-level function for querying repositories.
|
||||
*
|
||||
* @TODO Rename to just `queryRepos`.
|
||||
*
|
||||
* @param user The DockerHub username or org name to query for.
|
||||
* @param numRepos The number of repos to query (max 100).
|
||||
* @param lastUpdatedSince Filter by the DateTime at which a repo was last updated.
|
||||
*/
|
||||
|
||||
var queryTopRepos = function queryTopRepos(_ref3) {
|
||||
var lastUpdatedSince = _ref3.lastUpdatedSince,
|
||||
_ref3$numRepos = _ref3.numRepos,
|
||||
numRepos = _ref3$numRepos === void 0 ? 100 : _ref3$numRepos,
|
||||
user = _ref3.user;
|
||||
|
||||
try {
|
||||
if (numRepos > 100) {
|
||||
throw new RangeError('Number of repos to query cannot exceed 100.');
|
||||
}
|
||||
|
||||
var listReposURL = createUserReposListURL(user);
|
||||
return Promise.resolve(axios.get(listReposURL, {
|
||||
params: {
|
||||
page: 1,
|
||||
page_size: numRepos
|
||||
}
|
||||
})).then(function (repoResults) {
|
||||
var repos = R.path(['data', 'results'], repoResults);
|
||||
return extractRepositoryDetails(repos, lastUpdatedSince);
|
||||
});
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Query image tags.
|
||||
*/
|
||||
|
||||
var queryTags = function queryTags(repo) {
|
||||
try {
|
||||
var repoUrl = createUserReposListURL(repo.user);
|
||||
var tagsUrl = repoUrl + "/" + repo.name + "/tags?page_size=100";
|
||||
return Promise.resolve(axios.get(tagsUrl)).then(function (tagsResults) {
|
||||
var tags = R.path(['data', 'results'], tagsResults);
|
||||
|
||||
if (!tags || R.isEmpty(tags)) {
|
||||
return;
|
||||
} // @ts-ignore
|
||||
|
||||
|
||||
return camelcaseKeys(tags);
|
||||
});
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Queries the Docker Hub API to retrieve a "fat manifest", an object of
|
||||
* `Content-Type` `application/vnd.docker.distribution.manifest.list.v2+json/`.
|
||||
* Read up on the Manifest v2, Schema 2 Spec in more detail:
|
||||
* @see https://github.com/docker/distribution/blob/master/docs/spec/manifest-v2-2.md
|
||||
* Or the shiny new OCI distribution spec which builds on it:
|
||||
* @see https://github.com/opencontainers/distribution-spec/blob/f67bc11ba3a083a9c62f8fa53ad14c5bcf2116af/spec.md
|
||||
*/
|
||||
|
||||
var fetchManifestList = function fetchManifestList(repo) {
|
||||
try {
|
||||
// Docker Hub requires a unique token for each repo manifest queried.
|
||||
return Promise.resolve(fetchDockerHubToken(repo)).then(function (token) {
|
||||
var manifestListURL = createManifestListURL({
|
||||
repo: repo
|
||||
});
|
||||
return Promise.resolve(axios.get(manifestListURL, {
|
||||
headers: {
|
||||
Accept: 'application/vnd.docker.distribution.manifest.list.v2+json',
|
||||
Authorization: "Bearer " + token
|
||||
}
|
||||
})).then(function (manifestListResponse) {
|
||||
// For now, just ignore legacy V1 schema manifests. They have an entirely
|
||||
// different response shape and it's not worth mucking up the schema to
|
||||
// support a legacy format.
|
||||
if (manifestListResponse.data.schemaVersion === 1) {
|
||||
log.info('Schema version 1 is unsupported.', repo.name);
|
||||
return;
|
||||
}
|
||||
|
||||
return R.path(['data'], manifestListResponse);
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
};
|
||||
|
||||
exports.DOCKER_HUB_API_AUTH_URL = DOCKER_HUB_API_AUTH_URL;
|
||||
exports.DOCKER_HUB_API_ROOT = DOCKER_HUB_API_ROOT;
|
||||
exports.extractRepositoryDetails = extractRepositoryDetails;
|
||||
exports.fetchDockerHubToken = fetchDockerHubToken;
|
||||
exports.fetchManifestList = fetchManifestList;
|
||||
exports.queryRepo = queryRepo;
|
||||
exports.queryTags = queryTags;
|
||||
exports.queryTopRepos = queryTopRepos;
|
||||
//# sourceMappingURL=docker-hub-utils.cjs.development.js.map
|
1
node_modules/docker-hub-utils/dist/docker-hub-utils.cjs.development.js.map
generated
vendored
Normal file
1
node_modules/docker-hub-utils/dist/docker-hub-utils.cjs.development.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/docker-hub-utils/dist/docker-hub-utils.cjs.production.min.js
generated
vendored
Normal file
2
node_modules/docker-hub-utils/dist/docker-hub-utils.cjs.production.min.js
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r,t,s,i=e(require("axios")),o=e(require("camelcase-keys")),n=require("luxon"),a=e(require("ramda")),u=e(require("pino"));(r=exports.Architecture||(exports.Architecture={})).i386="386",r.amd64="amd64",r.arm="arm",r.arm64="arm64",r.mips="mips",r.mips64="mips64",r.mips64le="mips64le",r.mipsle="mipsle",r.ppc64="ppc64",r.ppc64le="ppc64le",r.s390x="s390x",r.wasm="wasm",function(e){e.aix="aix",e.android="android",e.darwin="darwin",e.dragonfly="dragonfly",e.freebsd="freebsd",e.illumos="illumos",e.js="js",e.linux="linux",e.netbsd="netbsd",e.openbsd="openbsd",e.plan9="plan9",e.solaris="solaris",e.windows="windows"}(t||(t={})),(s=exports.ManifestMediaType||(exports.ManifestMediaType={})).Manifest="application/vnd.docker.distribution.manifest.v2+json",s.ManifestList="application/vnd.docker.distribution.manifest.list.v2+json";var p=u({base:null,useLevelLabels:!0}),c=function(e){return"https://hub.docker.com/v2/repositories/"+e},d=function(e){try{return Promise.resolve(i.get("https://auth.docker.io/token",{params:{scope:"repository:"+e.user+"/"+e.name+":pull",service:"registry.docker.io"}})).then((function(e){var r=a.path(["data","token"],e);if(!r)throw new Error("Unable to retrieve auth token from registry.");return r}))}catch(e){return Promise.reject(e)}},m=function(e,r){if(!e||a.isEmpty(e))return[];var t=o(e);return a.isNil(r)?t:t.filter((function(e){return n.DateTime.fromISO(e.lastUpdated)<r}))};exports.DOCKER_HUB_API_AUTH_URL="https://auth.docker.io/token",exports.DOCKER_HUB_API_ROOT="https://hub.docker.com/v2/",exports.extractRepositoryDetails=m,exports.fetchDockerHubToken=d,exports.fetchManifestList=function(e){try{return Promise.resolve(d(e)).then((function(r){var t=function(e){var r=e.repo;return"https://registry-1.docker.io/v2/"+r.user+"/"+r.name+"/manifests/latest"}({repo:e});return Promise.resolve(i.get(t,{headers:{Accept:"application/vnd.docker.distribution.manifest.list.v2+json",Authorization:"Bearer "+r}})).then((function(r){if(1!==r.data.schemaVersion)return a.path(["data"],r);p.info("Schema version 1 is unsupported.",e.name)}))}))}catch(e){return Promise.reject(e)}},exports.queryRepo=function(e){var r=e.name,t=e.user;try{return Promise.resolve(i.request({url:"https://hub.docker.com/v2/repositories/"+t+"/"+r+"/"})).then((function(e){var r=a.prop("data",e);if(200===e.status&&r&&!a.isEmpty(r))return o(r)}))}catch(e){return Promise.reject(e)}},exports.queryTags=function(e){try{var r=c(e.user);return Promise.resolve(i.get(r+"/"+e.name+"/tags?page_size=100")).then((function(e){var r=a.path(["data","results"],e);if(r&&!a.isEmpty(r))return o(r)}))}catch(e){return Promise.reject(e)}},exports.queryTopRepos=function(e){var r=e.lastUpdatedSince,t=e.numRepos,s=void 0===t?100:t,o=e.user;try{if(s>100)throw new RangeError("Number of repos to query cannot exceed 100.");var n=c(o);return Promise.resolve(i.get(n,{params:{page:1,page_size:s}})).then((function(e){var t=a.path(["data","results"],e);return m(t,r)}))}catch(e){return Promise.reject(e)}};
|
||||
//# sourceMappingURL=docker-hub-utils.cjs.production.min.js.map
|
1
node_modules/docker-hub-utils/dist/docker-hub-utils.cjs.production.min.js.map
generated
vendored
Normal file
1
node_modules/docker-hub-utils/dist/docker-hub-utils.cjs.production.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
262
node_modules/docker-hub-utils/dist/docker-hub-utils.esm.js
generated
vendored
Normal file
262
node_modules/docker-hub-utils/dist/docker-hub-utils.esm.js
generated
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
import axios from 'axios';
|
||||
import camelcaseKeys from 'camelcase-keys';
|
||||
import { DateTime } from 'luxon';
|
||||
import R from 'ramda';
|
||||
import pino from 'pino';
|
||||
|
||||
/**
|
||||
* Union type representing the architecture defined in part of an OCI image's
|
||||
* manifest list.
|
||||
*
|
||||
* As specified in the Docker Manifest spec, any valid GOARCH values are valid
|
||||
* image architecture values, and vice versa:
|
||||
* > The platform object describes the platform which the image in the manifest
|
||||
* > runs on. A full list of valid operating system and architecture values are
|
||||
* > listed in the Go language documentation for $GOOS and $GOARCH
|
||||
* @see https://docs.docker.com/registry/spec/manifest-v2-2/#manifest-list-field-descriptions
|
||||
*/
|
||||
var Architecture;
|
||||
|
||||
(function (Architecture) {
|
||||
Architecture["i386"] = "386";
|
||||
Architecture["amd64"] = "amd64";
|
||||
Architecture["arm"] = "arm";
|
||||
Architecture["arm64"] = "arm64";
|
||||
Architecture["mips"] = "mips";
|
||||
Architecture["mips64"] = "mips64";
|
||||
Architecture["mips64le"] = "mips64le";
|
||||
Architecture["mipsle"] = "mipsle";
|
||||
Architecture["ppc64"] = "ppc64";
|
||||
Architecture["ppc64le"] = "ppc64le";
|
||||
Architecture["s390x"] = "s390x";
|
||||
Architecture["wasm"] = "wasm";
|
||||
})(Architecture || (Architecture = {}));
|
||||
/**
|
||||
* Union type representing the OS defined in part of an OCI image's
|
||||
* manifest list.
|
||||
* See the docs for the `Architecture` type above for more info.
|
||||
*/
|
||||
|
||||
|
||||
var OS;
|
||||
|
||||
(function (OS) {
|
||||
OS["aix"] = "aix";
|
||||
OS["android"] = "android";
|
||||
OS["darwin"] = "darwin";
|
||||
OS["dragonfly"] = "dragonfly";
|
||||
OS["freebsd"] = "freebsd";
|
||||
OS["illumos"] = "illumos";
|
||||
OS["js"] = "js";
|
||||
OS["linux"] = "linux";
|
||||
OS["netbsd"] = "netbsd";
|
||||
OS["openbsd"] = "openbsd";
|
||||
OS["plan9"] = "plan9";
|
||||
OS["solaris"] = "solaris";
|
||||
OS["windows"] = "windows";
|
||||
})(OS || (OS = {}));
|
||||
|
||||
var ManifestMediaType;
|
||||
|
||||
(function (ManifestMediaType) {
|
||||
ManifestMediaType["Manifest"] = "application/vnd.docker.distribution.manifest.v2+json";
|
||||
ManifestMediaType["ManifestList"] = "application/vnd.docker.distribution.manifest.list.v2+json";
|
||||
})(ManifestMediaType || (ManifestMediaType = {}));
|
||||
|
||||
var log = /*#__PURE__*/
|
||||
pino({
|
||||
base: null,
|
||||
useLevelLabels: true
|
||||
});
|
||||
|
||||
var DOCKER_HUB_API_ROOT = 'https://hub.docker.com/v2/';
|
||||
var DOCKER_HUB_API_AUTH_URL = 'https://auth.docker.io/token';
|
||||
|
||||
/**
|
||||
* Currently only supports fetching the manifest for the `latest` tag; in
|
||||
* reality, we can pass any valid content digest[1] to retrieve the manifest(s)
|
||||
* for that image.
|
||||
*
|
||||
* [1]: https://github.com/opencontainers/distribution-spec/blob/master/spec.md#content-digests
|
||||
*/
|
||||
|
||||
var createManifestListURL = function createManifestListURL(_ref) {
|
||||
var repo = _ref.repo;
|
||||
return "https://registry-1.docker.io/v2/" + repo.user + "/" + repo.name + "/manifests/latest";
|
||||
};
|
||||
|
||||
var createUserReposListURL = function createUserReposListURL(user) {
|
||||
return DOCKER_HUB_API_ROOT + "repositories/" + user;
|
||||
};
|
||||
/**
|
||||
* The OCI distribution spec requires a unique token for each repo manifest queried.
|
||||
*/
|
||||
|
||||
|
||||
var fetchDockerHubToken = function fetchDockerHubToken(repo) {
|
||||
try {
|
||||
var name = repo.name,
|
||||
user = repo.user;
|
||||
return Promise.resolve(axios.get(DOCKER_HUB_API_AUTH_URL, {
|
||||
params: {
|
||||
scope: "repository:" + user + "/" + name + ":pull",
|
||||
service: 'registry.docker.io'
|
||||
}
|
||||
})).then(function (tokenRequest) {
|
||||
var token = R.path(['data', 'token'], tokenRequest);
|
||||
|
||||
if (!token) {
|
||||
throw new Error('Unable to retrieve auth token from registry.');
|
||||
}
|
||||
|
||||
return token;
|
||||
});
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Pure function that massages the Docker Hub API response into the
|
||||
* format we want to return. e.g., only extracting certain fields;
|
||||
* converting snake_case to camelCase, etc.
|
||||
*/
|
||||
|
||||
var extractRepositoryDetails = function extractRepositoryDetails(repos, lastUpdatedSince) {
|
||||
if (!repos || R.isEmpty(repos)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var parsedRepos = camelcaseKeys(repos);
|
||||
|
||||
if (R.isNil(lastUpdatedSince)) {
|
||||
return parsedRepos;
|
||||
}
|
||||
|
||||
return parsedRepos.filter(function (repo) {
|
||||
return DateTime.fromISO(repo.lastUpdated) < lastUpdatedSince;
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Query a single repository given a repo name and username.
|
||||
*
|
||||
* @param user The DockerHub username or org name to query for.
|
||||
* @param name The DockerHub repo name -- restrict to this single repo.
|
||||
*/
|
||||
|
||||
var queryRepo = function queryRepo(_ref2) {
|
||||
var name = _ref2.name,
|
||||
user = _ref2.user;
|
||||
|
||||
try {
|
||||
return Promise.resolve(axios.request({
|
||||
url: DOCKER_HUB_API_ROOT + "repositories/" + user + "/" + name + "/"
|
||||
})).then(function (repoResult) {
|
||||
var repo = R.prop('data', repoResult);
|
||||
|
||||
if (repoResult.status !== 200 || !repo || R.isEmpty(repo)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return camelcaseKeys(repo);
|
||||
});
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Top-level function for querying repositories.
|
||||
*
|
||||
* @TODO Rename to just `queryRepos`.
|
||||
*
|
||||
* @param user The DockerHub username or org name to query for.
|
||||
* @param numRepos The number of repos to query (max 100).
|
||||
* @param lastUpdatedSince Filter by the DateTime at which a repo was last updated.
|
||||
*/
|
||||
|
||||
var queryTopRepos = function queryTopRepos(_ref3) {
|
||||
var lastUpdatedSince = _ref3.lastUpdatedSince,
|
||||
_ref3$numRepos = _ref3.numRepos,
|
||||
numRepos = _ref3$numRepos === void 0 ? 100 : _ref3$numRepos,
|
||||
user = _ref3.user;
|
||||
|
||||
try {
|
||||
if (numRepos > 100) {
|
||||
throw new RangeError('Number of repos to query cannot exceed 100.');
|
||||
}
|
||||
|
||||
var listReposURL = createUserReposListURL(user);
|
||||
return Promise.resolve(axios.get(listReposURL, {
|
||||
params: {
|
||||
page: 1,
|
||||
page_size: numRepos
|
||||
}
|
||||
})).then(function (repoResults) {
|
||||
var repos = R.path(['data', 'results'], repoResults);
|
||||
return extractRepositoryDetails(repos, lastUpdatedSince);
|
||||
});
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Query image tags.
|
||||
*/
|
||||
|
||||
var queryTags = function queryTags(repo) {
|
||||
try {
|
||||
var repoUrl = createUserReposListURL(repo.user);
|
||||
var tagsUrl = repoUrl + "/" + repo.name + "/tags?page_size=100";
|
||||
return Promise.resolve(axios.get(tagsUrl)).then(function (tagsResults) {
|
||||
var tags = R.path(['data', 'results'], tagsResults);
|
||||
|
||||
if (!tags || R.isEmpty(tags)) {
|
||||
return;
|
||||
} // @ts-ignore
|
||||
|
||||
|
||||
return camelcaseKeys(tags);
|
||||
});
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Queries the Docker Hub API to retrieve a "fat manifest", an object of
|
||||
* `Content-Type` `application/vnd.docker.distribution.manifest.list.v2+json/`.
|
||||
* Read up on the Manifest v2, Schema 2 Spec in more detail:
|
||||
* @see https://github.com/docker/distribution/blob/master/docs/spec/manifest-v2-2.md
|
||||
* Or the shiny new OCI distribution spec which builds on it:
|
||||
* @see https://github.com/opencontainers/distribution-spec/blob/f67bc11ba3a083a9c62f8fa53ad14c5bcf2116af/spec.md
|
||||
*/
|
||||
|
||||
var fetchManifestList = function fetchManifestList(repo) {
|
||||
try {
|
||||
// Docker Hub requires a unique token for each repo manifest queried.
|
||||
return Promise.resolve(fetchDockerHubToken(repo)).then(function (token) {
|
||||
var manifestListURL = createManifestListURL({
|
||||
repo: repo
|
||||
});
|
||||
return Promise.resolve(axios.get(manifestListURL, {
|
||||
headers: {
|
||||
Accept: 'application/vnd.docker.distribution.manifest.list.v2+json',
|
||||
Authorization: "Bearer " + token
|
||||
}
|
||||
})).then(function (manifestListResponse) {
|
||||
// For now, just ignore legacy V1 schema manifests. They have an entirely
|
||||
// different response shape and it's not worth mucking up the schema to
|
||||
// support a legacy format.
|
||||
if (manifestListResponse.data.schemaVersion === 1) {
|
||||
log.info('Schema version 1 is unsupported.', repo.name);
|
||||
return;
|
||||
}
|
||||
|
||||
return R.path(['data'], manifestListResponse);
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
};
|
||||
|
||||
export { Architecture, DOCKER_HUB_API_AUTH_URL, DOCKER_HUB_API_ROOT, ManifestMediaType, extractRepositoryDetails, fetchDockerHubToken, fetchManifestList, queryRepo, queryTags, queryTopRepos };
|
||||
//# sourceMappingURL=docker-hub-utils.esm.js.map
|
1
node_modules/docker-hub-utils/dist/docker-hub-utils.esm.js.map
generated
vendored
Normal file
1
node_modules/docker-hub-utils/dist/docker-hub-utils.esm.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
6
node_modules/docker-hub-utils/dist/index.d.ts
generated
vendored
Normal file
6
node_modules/docker-hub-utils/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
import { Architecture, DockerHubAPIRepo, DockerHubRepo, DockerManifest, DockerManifestList, ManifestMediaType, Tag } from './types/DockerHubRepo';
|
||||
import { extractRepositoryDetails, fetchDockerHubToken, fetchManifestList, queryRepo, queryTags, queryTopRepos } from './services/DockerHubAPI';
|
||||
import { DOCKER_HUB_API_AUTH_URL, DOCKER_HUB_API_ROOT } from './utils/constants';
|
||||
export { Architecture, DockerHubAPIRepo, DockerHubRepo, DockerManifest, DockerManifestList, ManifestMediaType, Tag, };
|
||||
export { extractRepositoryDetails, fetchDockerHubToken, fetchManifestList, queryRepo, queryTags, queryTopRepos, };
|
||||
export { DOCKER_HUB_API_ROOT, DOCKER_HUB_API_AUTH_URL };
|
8
node_modules/docker-hub-utils/dist/index.js
generated
vendored
Normal file
8
node_modules/docker-hub-utils/dist/index.js
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
|
||||
'use strict'
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./docker-hub-utils.cjs.production.min.js')
|
||||
} else {
|
||||
module.exports = require('./docker-hub-utils.cjs.development.js')
|
||||
}
|
49
node_modules/docker-hub-utils/dist/services/DockerHubAPI.d.ts
generated
vendored
Normal file
49
node_modules/docker-hub-utils/dist/services/DockerHubAPI.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
import { DateTime } from 'luxon';
|
||||
import { DockerHubAPIRepo, DockerHubRepo, DockerManifestList, Tag } from '../types/DockerHubRepo';
|
||||
/**
|
||||
* The OCI distribution spec requires a unique token for each repo manifest queried.
|
||||
*/
|
||||
export declare const fetchDockerHubToken: (repo: DockerHubRepo) => Promise<string>;
|
||||
/**
|
||||
* Pure function that massages the Docker Hub API response into the
|
||||
* format we want to return. e.g., only extracting certain fields;
|
||||
* converting snake_case to camelCase, etc.
|
||||
*/
|
||||
export declare const extractRepositoryDetails: (repos: DockerHubAPIRepo[], lastUpdatedSince?: DateTime | undefined) => DockerHubRepo[];
|
||||
/**
|
||||
* Query a single repository given a repo name and username.
|
||||
*
|
||||
* @param user The DockerHub username or org name to query for.
|
||||
* @param name The DockerHub repo name -- restrict to this single repo.
|
||||
*/
|
||||
export declare const queryRepo: ({ name, user, }: {
|
||||
name: string;
|
||||
user: string;
|
||||
}) => Promise<DockerHubRepo | undefined>;
|
||||
/**
|
||||
* Top-level function for querying repositories.
|
||||
*
|
||||
* @TODO Rename to just `queryRepos`.
|
||||
*
|
||||
* @param user The DockerHub username or org name to query for.
|
||||
* @param numRepos The number of repos to query (max 100).
|
||||
* @param lastUpdatedSince Filter by the DateTime at which a repo was last updated.
|
||||
*/
|
||||
export declare const queryTopRepos: ({ lastUpdatedSince, numRepos, user, }: {
|
||||
lastUpdatedSince?: DateTime | undefined;
|
||||
numRepos?: number | undefined;
|
||||
user: string;
|
||||
}) => Promise<DockerHubRepo[]>;
|
||||
/**
|
||||
* Query image tags.
|
||||
*/
|
||||
export declare const queryTags: (repo: DockerHubRepo) => Promise<Tag[] | undefined>;
|
||||
/**
|
||||
* Queries the Docker Hub API to retrieve a "fat manifest", an object of
|
||||
* `Content-Type` `application/vnd.docker.distribution.manifest.list.v2+json/`.
|
||||
* Read up on the Manifest v2, Schema 2 Spec in more detail:
|
||||
* @see https://github.com/docker/distribution/blob/master/docs/spec/manifest-v2-2.md
|
||||
* Or the shiny new OCI distribution spec which builds on it:
|
||||
* @see https://github.com/opencontainers/distribution-spec/blob/f67bc11ba3a083a9c62f8fa53ad14c5bcf2116af/spec.md
|
||||
*/
|
||||
export declare const fetchManifestList: (repo: DockerHubRepo) => Promise<DockerManifestList | undefined>;
|
123
node_modules/docker-hub-utils/dist/types/DockerHubRepo.d.ts
generated
vendored
Normal file
123
node_modules/docker-hub-utils/dist/types/DockerHubRepo.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,123 @@
|
|||
/**
|
||||
* This is a direct representation of what we get back from the `/repositories`
|
||||
* API call.
|
||||
*/
|
||||
export interface DockerHubAPIRepo {
|
||||
readonly can_edit: boolean;
|
||||
readonly description: string;
|
||||
readonly is_automated: boolean;
|
||||
readonly is_migrated: boolean;
|
||||
readonly is_private: boolean;
|
||||
readonly last_updated: string;
|
||||
readonly name: string;
|
||||
readonly namespace: string;
|
||||
readonly pull_count: number;
|
||||
readonly repository_type: string;
|
||||
readonly star_count: number;
|
||||
readonly status: number;
|
||||
readonly user: string;
|
||||
}
|
||||
/**
|
||||
* Union type representing the architecture defined in part of an OCI image's
|
||||
* manifest list.
|
||||
*
|
||||
* As specified in the Docker Manifest spec, any valid GOARCH values are valid
|
||||
* image architecture values, and vice versa:
|
||||
* > The platform object describes the platform which the image in the manifest
|
||||
* > runs on. A full list of valid operating system and architecture values are
|
||||
* > listed in the Go language documentation for $GOOS and $GOARCH
|
||||
* @see https://docs.docker.com/registry/spec/manifest-v2-2/#manifest-list-field-descriptions
|
||||
*/
|
||||
export declare enum Architecture {
|
||||
i386 = "386",
|
||||
amd64 = "amd64",
|
||||
arm = "arm",
|
||||
arm64 = "arm64",
|
||||
mips = "mips",
|
||||
mips64 = "mips64",
|
||||
mips64le = "mips64le",
|
||||
mipsle = "mipsle",
|
||||
ppc64 = "ppc64",
|
||||
ppc64le = "ppc64le",
|
||||
s390x = "s390x",
|
||||
wasm = "wasm"
|
||||
}
|
||||
/**
|
||||
* Union type representing the OS defined in part of an OCI image's
|
||||
* manifest list.
|
||||
* See the docs for the `Architecture` type above for more info.
|
||||
*/
|
||||
export declare enum OS {
|
||||
aix = "aix",
|
||||
android = "android",
|
||||
darwin = "darwin",
|
||||
dragonfly = "dragonfly",
|
||||
freebsd = "freebsd",
|
||||
illumos = "illumos",
|
||||
js = "js",
|
||||
linux = "linux",
|
||||
netbsd = "netbsd",
|
||||
openbsd = "openbsd",
|
||||
plan9 = "plan9",
|
||||
solaris = "solaris",
|
||||
windows = "windows"
|
||||
}
|
||||
export declare enum ManifestMediaType {
|
||||
Manifest = "application/vnd.docker.distribution.manifest.v2+json",
|
||||
ManifestList = "application/vnd.docker.distribution.manifest.list.v2+json"
|
||||
}
|
||||
/**
|
||||
* Yes, there's *way* more information contained in the manifest / "fat"
|
||||
* manifestList than just architectures, but I find this to be the most
|
||||
* relevant section for my projects. PR's welcome.
|
||||
*/
|
||||
export interface DockerManifest {
|
||||
readonly digest: string;
|
||||
readonly mediaType: ManifestMediaType;
|
||||
readonly platform: Array<{
|
||||
architecture: Architecture;
|
||||
os: OS;
|
||||
}>;
|
||||
readonly schemaVersion: 1 | 2 | number;
|
||||
}
|
||||
export interface DockerManifestList {
|
||||
readonly manifests: DockerManifest[];
|
||||
readonly mediaType: ManifestMediaType;
|
||||
readonly schemaVersion: 1 | 2 | any;
|
||||
}
|
||||
export interface DockerHubRepo {
|
||||
readonly description: string | null | undefined;
|
||||
readonly lastUpdated: string;
|
||||
readonly name: string;
|
||||
readonly pullCount: number;
|
||||
readonly starCount: number;
|
||||
readonly user: string;
|
||||
readonly manifestList?: DockerManifestList;
|
||||
readonly tags?: Tag[];
|
||||
readonly canEdit?: boolean;
|
||||
readonly isAutomated?: boolean;
|
||||
readonly isMigrated?: boolean;
|
||||
readonly isPrivate?: boolean;
|
||||
readonly namespace?: string;
|
||||
readonly repositoryType?: string;
|
||||
readonly status?: number;
|
||||
}
|
||||
export interface Tag {
|
||||
creator: number;
|
||||
fullSize: number;
|
||||
id: number;
|
||||
images: TagElement[];
|
||||
lastUpdated: string;
|
||||
lastUpdater: number;
|
||||
lastUpdaterUsername: string;
|
||||
name: string;
|
||||
repository: number;
|
||||
v2: boolean;
|
||||
}
|
||||
export interface TagElement {
|
||||
architecture: Architecture;
|
||||
digest: string;
|
||||
features: string;
|
||||
os: OS;
|
||||
size: number;
|
||||
}
|
3
node_modules/docker-hub-utils/dist/utils/constants.d.ts
generated
vendored
Normal file
3
node_modules/docker-hub-utils/dist/utils/constants.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
export declare const DOCKER_CLOUD_URL = "https://cloud.docker.com/repository/docker/";
|
||||
export declare const DOCKER_HUB_API_ROOT = "https://hub.docker.com/v2/";
|
||||
export declare const DOCKER_HUB_API_AUTH_URL = "https://auth.docker.io/token";
|
3
node_modules/docker-hub-utils/dist/utils/log.d.ts
generated
vendored
Normal file
3
node_modules/docker-hub-utils/dist/utils/log.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
import pino from 'pino';
|
||||
declare const _default: pino.Logger;
|
||||
export default _default;
|
114
node_modules/docker-hub-utils/package.json
generated
vendored
Normal file
114
node_modules/docker-hub-utils/package.json
generated
vendored
Normal file
|
@ -0,0 +1,114 @@
|
|||
{
|
||||
"_from": "docker-hub-utils",
|
||||
"_id": "docker-hub-utils@1.10.29",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-wZ3BmcG3mq90rlXGfGcgqwgyTyO0kWQA5D+3J7T+nLgE1mzjggK1ZDB44krt5dj5lK/nXla3vGIw7nF7IE2kQQ==",
|
||||
"_location": "/docker-hub-utils",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "docker-hub-utils",
|
||||
"name": "docker-hub-utils",
|
||||
"escapedName": "docker-hub-utils",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/docker-hub-utils/-/docker-hub-utils-1.10.29.tgz",
|
||||
"_shasum": "8e1f910e704c9a7706dba8fb2b3078d7fbbe7a6e",
|
||||
"_spec": "docker-hub-utils",
|
||||
"_where": "/home/dawidd6/github/dawidd6/action-debian-package",
|
||||
"author": {
|
||||
"name": "Jesse Stuart",
|
||||
"email": "hi@jessestuart.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jessestuart/docker-hub-utils/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"axios": "0.19.2",
|
||||
"camelcase-keys": "6.2.1",
|
||||
"luxon": "1.22.2",
|
||||
"pino": "5.17.0",
|
||||
"ramda": "0.27.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Typescript / Node utilities for interacting with the Docker Hub API.",
|
||||
"devDependencies": {
|
||||
"@semantic-release/git": "9.0.0",
|
||||
"@types/jest": "25.1.4",
|
||||
"@types/luxon": "1.22.0",
|
||||
"@types/node": "13.9.4",
|
||||
"@types/pino": "5.17.0",
|
||||
"@types/ramda": "0.27.0",
|
||||
"@typescript-eslint/eslint-plugin": "2.25.0",
|
||||
"@typescript-eslint/parser": "2.25.0",
|
||||
"codecov": "3.6.5",
|
||||
"concurrently": "5.1.0",
|
||||
"eslint": "6.8.0",
|
||||
"eslint-config-prettier": "6.10.1",
|
||||
"eslint-plugin-import": "2.20.1",
|
||||
"eslint-plugin-prettier": "3.1.2",
|
||||
"husky": "4.2.3",
|
||||
"jest": "25.1.0",
|
||||
"jest-junit": "10.0.0",
|
||||
"nodemon": "2.0.2",
|
||||
"prettier": "1.19.1",
|
||||
"pretty-quick": "2.0.1",
|
||||
"semantic-release": "17.0.4",
|
||||
"source-map-support": "0.5.16",
|
||||
"ts-jest": "25.2.1",
|
||||
"tsdx": "0.13.0",
|
||||
"tslib": "1.11.1",
|
||||
"tslint": "6.1.0",
|
||||
"tslint-config-prettier": "1.18.0",
|
||||
"typedoc": "0.17.3",
|
||||
"typescript": "3.8.3"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"homepage": "https://github.com/jessestuart/docker-hub-utils",
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "pretty-quick --staged"
|
||||
}
|
||||
},
|
||||
"keywords": [
|
||||
"api",
|
||||
"docker",
|
||||
"docker-hub",
|
||||
"typescript",
|
||||
"utils",
|
||||
"wrapper-api"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/docker-hub-utils.esm.js",
|
||||
"name": "docker-hub-utils",
|
||||
"peerDependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jessestuart/docker-hub-utils.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsdx build",
|
||||
"ci": "JEST_JUNIT_OUTPUT=reports/junit/js-test-results.xml jest --ci --runInBand --coverage --reporters=default --reporters=jest-junit",
|
||||
"docs": "typedoc --mode modules --out public",
|
||||
"lint": "eslint --quiet src/ --ext ts,tsx",
|
||||
"prepublishOnly": "yarn build",
|
||||
"push": "yarn build && yalc push",
|
||||
"rebuild": "rm -rf dist/* && yarn build",
|
||||
"release": "yarn rebuild && semantic-release",
|
||||
"start": "tsdx watch",
|
||||
"test": "yarn jest --cache --coverage"
|
||||
},
|
||||
"typings": "dist/index.d.ts",
|
||||
"version": "1.10.29"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue