add more formatter

main
Jörg Thalheim 2 years ago
parent 7f6af15b82
commit 233c80b94e
No known key found for this signature in database

@ -1,6 +1,5 @@
with import <nixpkgs> {}; with import <nixpkgs> {};
buildGoModule {
buildGoModule {
name = "systemd-vaultd"; name = "systemd-vaultd";
src = ./.; src = ./.;
vendorSha256 = null; vendorSha256 = null;
@ -8,7 +7,7 @@ buildGoModule {
description = "A proxy for secrets between systemd services and vault"; description = "A proxy for secrets between systemd services and vault";
homepage = "https://github.com/numtide/systemd-vaultd"; homepage = "https://github.com/numtide/systemd-vaultd";
license = licenses.mit; license = licenses.mit;
maintainers = with maintainers; [ mic92 ]; maintainers = with maintainers; [mic92];
platforms = platforms.unix; platforms = platforms.unix;
}; };
} }

@ -22,10 +22,10 @@ type server struct {
func inheritSocket() *net.UnixListener { func inheritSocket() *net.UnixListener {
socks := systemdSockets(true) socks := systemdSockets(true)
stat := &syscall.Stat_t {} stat := &syscall.Stat_t{}
for _, s := range socks { for _, s := range socks {
fd := s.Fd() fd := s.Fd()
err := syscall.Fstat(int(fd), stat); err := syscall.Fstat(int(fd), stat)
if err != nil { if err != nil {
log.Printf("Received invalid file descriptor from systemd for fd%d: %v", fd, err) log.Printf("Received invalid file descriptor from systemd for fd%d: %v", fd, err)
continue continue
@ -35,7 +35,7 @@ func inheritSocket() *net.UnixListener {
log.Printf("Received file descriptor %d from systemd that is not a valid socket: %v", fd, err) log.Printf("Received file descriptor %d from systemd that is not a valid socket: %v", fd, err)
continue continue
} }
unixListener, ok := listener.(*net.UnixListener); unixListener, ok := listener.(*net.UnixListener)
if !ok { if !ok {
log.Printf("Ignore file descriptor %d from systemd, which is not a unix socket", fd) log.Printf("Ignore file descriptor %d from systemd, which is not a unix socket", fd)
continue continue

@ -1,14 +1,19 @@
{ pkgs ? import <nixpkgs> {} }: {pkgs ? import <nixpkgs> {}}:
with pkgs; with pkgs;
mkShell {
mkShell {
buildInputs = [ buildInputs = [
python3.pkgs.pytest python3.pkgs.pytest
python3.pkgs.flake8
python3.pkgs.black
python3.pkgs.mypy
gofumpt
golangci-lint golangci-lint
alejandra
vault vault
systemd systemd
hivemind hivemind
go go
treefmt
]; ];
} }

@ -35,7 +35,18 @@ def test_socket_activation(
secrets_dir.mkdir() secrets_dir.mkdir()
sock = tempdir / "sock" sock = tempdir / "sock"
command.run(["systemd-socket-activate", "--listen", str(sock), str(systemd_vault), "-secrets", str(secrets_dir), "-sock", str(sock)]) command.run(
[
"systemd-socket-activate",
"--listen",
str(sock),
str(systemd_vault),
"-secrets",
str(secrets_dir),
"-sock",
str(sock),
]
)
while not sock.exists(): while not sock.exists():
time.sleep(0.1) time.sleep(0.1)

@ -0,0 +1,21 @@
[formatter.nix]
command = "alejandra"
includes = ["*.nix"]
[formatter.python]
command = "sh"
options = [
"-eucx",
"""
flake8 "$@"
black "$@"
"""
]
includes = ["*.py"]
excludes = []
[formatter.go]
command = "gofumpt"
options = ["-w"]
includes = ["*.go"]
excludes = []

@ -174,7 +174,7 @@ func (s *server) setupWatcher(dir string) error {
return fmt.Errorf("Failed to initialize inotify: %v", err) return fmt.Errorf("Failed to initialize inotify: %v", err)
} }
flags := uint32(syscall.IN_CREATE | syscall.IN_MOVED_TO | syscall.IN_ONLYDIR) flags := uint32(syscall.IN_CREATE | syscall.IN_MOVED_TO | syscall.IN_ONLYDIR)
res := os.MkdirAll(dir, 0700) res := os.MkdirAll(dir, 0o700)
if err != nil && !os.IsNotExist(res) { if err != nil && !os.IsNotExist(res) {
return fmt.Errorf("Failed to create secret directory: %v", err) return fmt.Errorf("Failed to create secret directory: %v", err)
} }

Loading…
Cancel
Save