Merge pull request 'add mode to vars files' (#2560) from vars-mode into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/2560
This commit is contained in:
@@ -51,6 +51,9 @@ in
|
|||||||
_name: file: {
|
_name: file: {
|
||||||
inherit (file)
|
inherit (file)
|
||||||
name
|
name
|
||||||
|
owner
|
||||||
|
group
|
||||||
|
mode
|
||||||
deploy
|
deploy
|
||||||
secret
|
secret
|
||||||
neededForUsers
|
neededForUsers
|
||||||
|
|||||||
@@ -206,13 +206,18 @@ in
|
|||||||
default = false;
|
default = false;
|
||||||
};
|
};
|
||||||
owner = lib.mkOption {
|
owner = lib.mkOption {
|
||||||
description = "The user name or id that will own the secret file.";
|
description = "The user name or id that will own the file.";
|
||||||
default = "root";
|
default = "root";
|
||||||
};
|
};
|
||||||
group = lib.mkOption {
|
group = lib.mkOption {
|
||||||
description = "The group name or id that will own the secret file.";
|
description = "The group name or id that will own the file.";
|
||||||
default = "root";
|
default = "root";
|
||||||
};
|
};
|
||||||
|
mode = lib.mkOption {
|
||||||
|
type = lib.types.strMatching "^[0-7]{3}$";
|
||||||
|
description = "The unix file mode of the file. Must be a 3-digit octal number.";
|
||||||
|
default = "400";
|
||||||
|
};
|
||||||
value =
|
value =
|
||||||
lib.mkOption {
|
lib.mkOption {
|
||||||
description = ''
|
description = ''
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ class SecretStore(SecretStoreBase):
|
|||||||
continue
|
continue
|
||||||
if not file.secret:
|
if not file.secret:
|
||||||
continue
|
continue
|
||||||
if not dir_exists:
|
if not dir_exists and not file.needed_for_users:
|
||||||
tar_dir = tarfile.TarInfo(name=generator.name)
|
tar_dir = tarfile.TarInfo(name=generator.name)
|
||||||
tar_dir.type = tarfile.DIRTYPE
|
tar_dir.type = tarfile.DIRTYPE
|
||||||
tar_dir.mode = 0o511
|
tar_dir.mode = 0o511
|
||||||
@@ -170,7 +170,7 @@ class SecretStore(SecretStoreBase):
|
|||||||
tar_file = tarfile.TarInfo(name=f"{generator.name}/{file.name}")
|
tar_file = tarfile.TarInfo(name=f"{generator.name}/{file.name}")
|
||||||
content = self.get(generator, file.name)
|
content = self.get(generator, file.name)
|
||||||
tar_file.size = len(content)
|
tar_file.size = len(content)
|
||||||
tar_file.mode = 0o440
|
tar_file.mode = file.mode
|
||||||
tar_file.uname = file.owner
|
tar_file.uname = file.owner
|
||||||
tar_file.gname = file.group
|
tar_file.gname = file.group
|
||||||
if file.needed_for_users:
|
if file.needed_for_users:
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class Var:
|
|||||||
deploy: bool = False
|
deploy: bool = False
|
||||||
owner: str = "root"
|
owner: str = "root"
|
||||||
group: str = "root"
|
group: str = "root"
|
||||||
|
mode: int = 0o400
|
||||||
needed_for_users: bool = False
|
needed_for_users: bool = False
|
||||||
|
|
||||||
# TODO: those shouldn't be set here
|
# TODO: those shouldn't be set here
|
||||||
@@ -75,5 +76,6 @@ class Var:
|
|||||||
deploy=data["deploy"],
|
deploy=data["deploy"],
|
||||||
owner=data.get("owner", "root"),
|
owner=data.get("owner", "root"),
|
||||||
group=data.get("group", "root"),
|
group=data.get("group", "root"),
|
||||||
|
mode=int(data.get("mode", "400"), 8),
|
||||||
needed_for_users=data.get("neededForUsers", False),
|
needed_for_users=data.get("neededForUsers", False),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user