From 477152814ad5b71234148fa9a5be9dc7274194c5 Mon Sep 17 00:00:00 2001 From: Tom Wiesing Date: Thu, 8 Sep 2022 17:30:28 +0200 Subject: [PATCH] env/instances: Guarantee that right 'authorized_keys' file is created --- env/instances.go | 10 ++++------ internal/stack/installable.go | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/env/instances.go b/env/instances.go index ef77b36..ea94689 100644 --- a/env/instances.go +++ b/env/instances.go @@ -245,14 +245,12 @@ func (instance Instance) Stack() stack.Installable { "GLOBAL_AUTHORIZED_KEYS_FILE": instance.dis.Config.GlobalAuthorizedKeysFile, }, - CopyContextFiles: nil, - - TouchFiles: []string{ - "authorized_keys", - }, - MakeDirsPerm: fs.ModeDir | fs.ModePerm, MakeDirs: []string{"data", ".composer"}, + + TouchFiles: []string{ + filepath.Join("data", "authorized_keys"), + }, } } diff --git a/internal/stack/installable.go b/internal/stack/installable.go index 0e22d7c..ac2b57c 100644 --- a/internal/stack/installable.go +++ b/internal/stack/installable.go @@ -23,10 +23,10 @@ type Installable struct { CopyContextFiles []string // Files to copy from the installation context - TouchFiles []string // Files to 'touch', i.e. ensure that exist - MakeDirsPerm fs.FileMode // permission for diretories, defaults to fs.ModeDir MakeDirs []string // directories to ensure that exist + + TouchFiles []string // Files to 'touch', i.e. ensure that exist; guaranteed to be run after MakeDirs } // InstallationContext is a context to install data in @@ -61,7 +61,7 @@ func (is Installable) Install(io stream.IOStream, context InstallationContext) e } } - // make sure that certain files exist + // make sure that certain dirs exist for _, name := range is.MakeDirs { // find the destination! dst := filepath.Join(is.Dir, name)