mirror of
https://github.com/renovatebot/github-action.git
synced 2025-12-16 17:02:36 +00:00
fix: throw error if docker group cannot be found (#78)
This commit is contained in:
parent
17a2d55cdd
commit
3aa72249b9
1 changed files with 12 additions and 3 deletions
|
|
@ -6,6 +6,7 @@ import path from 'path';
|
||||||
class Renovate {
|
class Renovate {
|
||||||
private configFileEnv = 'RENOVATE_CONFIG_FILE';
|
private configFileEnv = 'RENOVATE_CONFIG_FILE';
|
||||||
private tokenEnv = 'RENOVATE_TOKEN';
|
private tokenEnv = 'RENOVATE_TOKEN';
|
||||||
|
private dockerGroupName = 'docker';
|
||||||
private configFileMountDir = '/github-action';
|
private configFileMountDir = '/github-action';
|
||||||
|
|
||||||
private configFile: string;
|
private configFile: string;
|
||||||
|
|
@ -47,7 +48,8 @@ class Renovate {
|
||||||
* required permissions on the Docker socket.
|
* required permissions on the Docker socket.
|
||||||
*/
|
*/
|
||||||
private getDockerGroupId(): string {
|
private getDockerGroupId(): string {
|
||||||
const groups = fs.readFileSync('/etc/group', {
|
const groupFile = '/etc/group';
|
||||||
|
const groups = fs.readFileSync(groupFile, {
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -57,8 +59,15 @@ class Renovate {
|
||||||
*
|
*
|
||||||
* Source: https://www.thegeekdiary.com/etcgroup-file-explained/
|
* Source: https://www.thegeekdiary.com/etcgroup-file-explained/
|
||||||
*/
|
*/
|
||||||
const [, group] = /^docker:x:([1-9][0-9]*):$/m.exec(groups);
|
const re = new RegExp(`^${this.dockerGroupName}:x:([1-9][0-9]*):`, 'm');
|
||||||
return group;
|
const match = re.exec(groups);
|
||||||
|
if (!match || match.length < 2) {
|
||||||
|
throw new Error(
|
||||||
|
`Could not find group '${this.dockerGroupName}' in ${groupFile}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return match[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
private validateArguments(): void {
|
private validateArguments(): void {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue