Skip to content

Commit 0f9d258

Browse files
authored
Merge pull request #1 from solunio/fix/official_docker_images
Fix/official docker images
2 parents eb92b04 + aa30a14 commit 0f9d258

12 files changed

Lines changed: 891 additions & 969 deletions

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[*]
2+
charset=utf-8
3+
end_of_line=lf
4+
insert_final_newline=true
5+
indent_style=space
6+
indent_size=4
7+
trim_trailing_whitespace=true

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dist/
2+
node_modules/
3+
.gitignore
4+
.npmignore
5+
.prettierignore
6+
CHANGELOG.md
7+
yarn.lock

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "none",
4+
"printWidth": 120,
5+
"quoteProps": "consistent",
6+
"arrowParens": "avoid"
7+
}

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ If you are using images from a private registry it is neccessary to login to tha
1010
By default, this application searches for a _docker-compose.yml_ file in the current working directory (same behavior as docker-compose utility). Hence, the directory in which the application is executed, must contain a valid **docker-compose.yml** file.
1111
In order to make this tool work correctly it is neccessary that all images in the _docker-compose.yml_ file are specified with a semver compliant tag. Otherwise execution will fail.
1212

13-
1413
## Usage
1514

1615
You can use this utilty by installing it globally and executing it in your project's root directory:
@@ -34,16 +33,15 @@ library/influxdb 0.13.0 1.7.3 1.7.3
3433
For advanced usage, command line flags can be used to change the default behavoir of the application:
3534

3635
| Flag | Description |
37-
| ----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
36+
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
3837
| --compose-file <file path> | Path to the docker-compose file. Defaults to ./docker-compose.yml |
3938
| --docker-config <file path> | Path to the docker config file, from which authentication details taken. Defaults to ~/.docker/config.json |
4039
| --filter <string> | Filter string to optionally filter the list of checked-images. If specified, only images-names that contain the given search string will be checked |
4140
| -x | When scanning the docker-compose.yml file, exclude all images from the offical docker registry, as well as images that do not have a semver compliant tag |
4241

43-
4442
However, for a fully detailed description of all flags that can be used, see the application's usage information (`dc-outdated --help`).
4543

4644
## TODOs
4745

48-
* For now only docker compose files of version 2.x were tested. For the future docker-compose version 3 should be supported too
49-
* At this moment checking for outdated images against the official docker registry is not fully working. Hence, only images from a self-hosted docker registry (v2) can be checked reliable. This will be changed in the future so that all kind of docker registries are supported. For now you will have to login to _registry-1.docker.io_ in order to verfy images from offical docker registry.
46+
- For now only docker compose files of version 2.x were tested. For the future docker-compose version 3 should be supported too
47+
- At this moment checking for outdated images against the official docker registry is not fully working. Hence, only images from a self-hosted docker registry (v2) can be checked reliable. This will be changed in the future so that all kind of docker registries are supported. For now you will have to login to _registry-1.docker.io_ in order to verfy images from offical docker registry.

package.json

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,39 @@
1515
"semver"
1616
],
1717
"license": "MIT",
18+
"engines": {
19+
"node": ">=12.13.0"
20+
},
1821
"scripts": {
1922
"build": "rimraf dist && tsc",
2023
"start": "node dist/bin/dc-outdated.js",
2124
"version": "yarn run version:changelog && git add CHANGELOG.md",
22-
"version:changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
25+
"version:changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
26+
"cleanup-lockfile": "yarn-deduplicate --strategy fewer",
27+
"format": "prettier --write .",
28+
"check-formatting": "prettier --check ."
2329
},
2430
"dependencies": {
25-
"cli-progress": "^2.1.1",
26-
"commander": "^2.19.0",
31+
"axios": "^0.21.1",
32+
"cli-progress": "^3.9.0",
33+
"commander": "^8.1.0",
2734
"easy-table": "^1.1.1",
28-
"js-yaml": "^3.12.1",
35+
"js-yaml": "^4.1.0",
2936
"lodash": "^4.17.11",
30-
"request": "^2.88.0",
31-
"semver": "^5.6.0"
37+
"semver": "^7.3.5",
38+
"tslib": "^2.3.1"
3239
},
3340
"devDependencies": {
34-
"@types/node": "^10.5.2",
35-
"conventional-changelog-cli": "^2.0.11",
36-
"rimraf": "^2.6.3",
37-
"typescript": "^3.3.3"
41+
"@types/cli-progress": "^3.9.2",
42+
"@types/easy-table": "^0.0.33",
43+
"@types/js-yaml": "^4.0.3",
44+
"@types/lodash": "^4.14.172",
45+
"@types/node": "^12.20.21",
46+
"@types/semver": "^7.3.8",
47+
"conventional-changelog-cli": "^2.1.1",
48+
"prettier": "^2.3.2",
49+
"rimraf": "^3.0.2",
50+
"typescript": "^4.3.5",
51+
"yarn-deduplicate": "^3.1.0"
3852
}
3953
}

src/bin/dc-outdated.ts

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,49 @@
11
#!/usr/bin/env node
22

3-
import * as program from 'commander';
4-
import * as os from 'os';
5-
import * as path from 'path';
3+
import { Command } from 'commander';
4+
import { homedir as osHomedir } from 'os';
5+
import { join as joinPath } from 'path';
6+
67
import { listOutdated, Options } from '../lib';
78

89
const pkg = require('../../package.json');
10+
interface CliOptions {
11+
readonly composeFile: string;
12+
readonly dockerConfig: string;
13+
readonly filter: string;
14+
readonly excludeOfficalsAndInvalids: boolean;
15+
}
916

10-
program.version(pkg.version)
17+
const program = new Command()
18+
.version(pkg.version)
1119
.option('--compose-file <file path>', 'Path to the docker-compose file. Defaults to ./docker-compose.yml')
12-
.option('--docker-config <file path>', 'Path to the docker config file, from which authentication details taken. Defaults to ~/.docker/config.json')
13-
.option('-f --filter <string>', 'Filter string to optionally filter the list of checked-images. If specified, only images-names that contain the given search string will be checked')
14-
.option('-x --exclude-officals-and-invalids', 'When scanning the docker-compose.yml file, exclude all images from the offical docker registry, as well as images that do not have a semver compliant tag')
20+
.option(
21+
'--docker-config <file path>',
22+
'Path to the docker config file, from which authentication details taken. Defaults to ~/.docker/config.json'
23+
)
24+
.option(
25+
'-f --filter <string>',
26+
'Filter string to optionally filter the list of checked-images. If specified, only images-names that contain the given search string will be checked'
27+
)
28+
.option(
29+
'-x --exclude-officals-and-invalids',
30+
'When scanning the docker-compose.yml file, exclude all images from the offical docker registry, as well as images that do not have a semver compliant tag'
31+
)
1532
.parse(process.argv);
1633

1734
const options: Options = {
1835
composeFilePath: './docker-compose.yml',
19-
dockerConfigPath: path.join(os.homedir(), '.docker', 'config.json')
36+
dockerConfigPath: joinPath(osHomedir(), '.docker', 'config.json')
2037
};
2138

22-
if(program.composeFile) options.composeFilePath = program.composeFile;
23-
if(program.dockerConfig) options.dockerConfigPath = program.dockerConfig;
24-
if(program.filter) options.imagesFilter = program.filter;
25-
if(program.excludeOfficalsAndInvalids) options.excludeOfficalsAndInvalids = true;
39+
const cliOptions = program.opts<CliOptions>();
2640

41+
if (cliOptions.composeFile) options.composeFilePath = cliOptions.composeFile;
42+
if (cliOptions.dockerConfig) options.dockerConfigPath = cliOptions.dockerConfig;
43+
if (cliOptions.filter) options.imagesFilter = cliOptions.filter;
44+
if (cliOptions.excludeOfficalsAndInvalids) options.excludeOfficalsAndInvalids = true;
2745

28-
listOutdated(options)
29-
.catch(err => {
30-
console.error(`There was an error: ${err.message}`);
31-
process.exit(1);
32-
});
46+
listOutdated(options).catch(err => {
47+
console.error(`There was an error: ${err.message}`);
48+
process.exit(1);
49+
});

src/lib/compose-utils.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
import * as yaml from 'js-yaml';
2-
import * as path from 'path';
1+
import { load as loadYaml } from 'js-yaml';
2+
import { resolve as resolvePath } from 'path';
3+
34
import { DockerImage, parseDockerImage } from './docker-utils';
45
import { readFile } from './utils';
56

6-
7-
87
async function readComposeFile(composeFilePath: string): Promise<any> {
9-
const data = await readFile(path.resolve(composeFilePath));
10-
return yaml.safeLoad(data);
8+
const data = await readFile(resolvePath(composeFilePath));
9+
return loadYaml(data);
1110
}
1211

13-
1412
export async function getComposeImages(composeFilePath: string): Promise<DockerImage[]> {
1513
const composeFile = await readComposeFile(composeFilePath);
1614

@@ -24,4 +22,3 @@ export async function getComposeImages(composeFilePath: string): Promise<DockerI
2422
}
2523
return res;
2624
}
27-

0 commit comments

Comments
 (0)