From c71213ce56a6b839bb99fb13f8643d8b825c4c05 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Mon, 18 Nov 2024 22:28:28 +0100 Subject: [PATCH] Use filer for materializing template files --- libs/filer/filer.go | 11 +++- libs/filer/filer_test.go | 11 ++++ libs/filer/local_client.go | 13 +++- libs/template/config_test.go | 4 +- libs/template/file.go | 84 ++++++++----------------- libs/template/file_test.go | 46 ++++---------- libs/template/helpers_test.go | 24 +++----- libs/template/materialize.go | 10 ++- libs/template/renderer.go | 32 +++------- libs/template/renderer_test.go | 109 +++++++++++++++------------------ 10 files changed, 147 insertions(+), 197 deletions(-) create mode 100644 libs/filer/filer_test.go diff --git a/libs/filer/filer.go b/libs/filer/filer.go index fcfbcea0..a748e1fd 100644 --- a/libs/filer/filer.go +++ b/libs/filer/filer.go @@ -7,13 +7,22 @@ import ( "io/fs" ) +// WriteMode captures intent when writing a file. +// +// The first 9 bits are reserved for the [fs.FileMode] permission bits. +// These are used only by the local filer implementation and have +// no effect for the other implementations. type WriteMode int +// writeModePerm is a mask to extract permission bits from a WriteMode. +const writeModePerm = WriteMode(fs.ModePerm) + const ( - OverwriteIfExists WriteMode = 1 << iota + OverwriteIfExists WriteMode = writeModePerm + 1<