diff --git a/go.mod b/go.mod index b5434dc0..99fa50c9 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/BurntSushi/toml v1.2.1 - github.com/cloudbase/garm-provider-common v0.0.0-20230723225907-c058d92fd686 + github.com/cloudbase/garm-provider-common v0.0.0-20230724114054-7aa0a3dfbce0 github.com/go-openapi/errors v0.20.4 github.com/go-openapi/runtime v0.26.0 github.com/go-openapi/strfmt v0.21.7 diff --git a/go.sum b/go.sum index b2f99a53..cfd7aa66 100644 --- a/go.sum +++ b/go.sum @@ -25,8 +25,8 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04= github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudbase/garm-provider-common v0.0.0-20230723225907-c058d92fd686 h1:WpIcNMQV6eCTfppWiylhp6+NKgKvoWhbcMyvLRlYfnc= -github.com/cloudbase/garm-provider-common v0.0.0-20230723225907-c058d92fd686/go.mod h1:RKzgL0MXkNeGfloQpE2swz/y4LWJr5+2Wd45bSXPB0k= +github.com/cloudbase/garm-provider-common v0.0.0-20230724114054-7aa0a3dfbce0 h1:5ScMXea/ZIcUbw1aXAgN8xTqSG84AOf5Maf5hBC82wQ= +github.com/cloudbase/garm-provider-common v0.0.0-20230724114054-7aa0a3dfbce0/go.mod h1:RKzgL0MXkNeGfloQpE2swz/y4LWJr5+2Wd45bSXPB0k= github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= diff --git a/vendor/github.com/cloudbase/garm-provider-common/cloudconfig/util.go b/vendor/github.com/cloudbase/garm-provider-common/cloudconfig/util.go index e8b6d1f8..d9a69a16 100644 --- a/vendor/github.com/cloudbase/garm-provider-common/cloudconfig/util.go +++ b/vendor/github.com/cloudbase/garm-provider-common/cloudconfig/util.go @@ -3,6 +3,7 @@ package cloudconfig import ( "encoding/json" "fmt" + "sort" "strings" "github.com/cloudbase/garm-provider-common/defaults" @@ -21,6 +22,9 @@ type CloudConfigSpec struct { // runner install script. These will run as root and can be used to prep a generic image // before we attempt to install the runner. The key of the map is the name of the script // as it will be written to disk. The value is a byte array with the contents of the script. + // + // These scripts will be added and run in alphabetical order. + // // On Linux, we will set the executable flag. On Windows, the name matters as Windows looks for an // extension to determine if the file is an executable or not. In theory this can hold binaries, // but in most cases this will most likely hold scripts. We do not currenly validate the payload, @@ -32,6 +36,16 @@ type CloudConfigSpec struct { ExtraContext map[string]string `json:"extra_context"` } +func sortMapKeys(m map[string][]byte) []string { + var keys []string + for k := range m { + keys = append(keys, k) + } + sort.Strings(keys) + + return keys +} + // GetSpecs returns the cloud config specific extra specs from the bootstrap params. func GetSpecs(bootstrapParams commonParams.BootstrapInstance) (CloudConfigSpec, error) { var extraSpecs CloudConfigSpec @@ -125,7 +139,9 @@ func GetCloudInitConfig(bootstrapParams commonParams.BootstrapInstance, installS } if len(extraSpecs.PreInstallScripts) > 0 { - for name, script := range extraSpecs.PreInstallScripts { + names := sortMapKeys(extraSpecs.PreInstallScripts) + for _, name := range names { + script := extraSpecs.PreInstallScripts[name] cloudCfg.AddFile(script, fmt.Sprintf("/garm-pre-install/%s", name), "root:root", "755") cloudCfg.AddRunCmd(fmt.Sprintf("/garm-pre-install/%s", name)) } diff --git a/vendor/modules.txt b/vendor/modules.txt index e94db1fb..d014341d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -34,7 +34,7 @@ github.com/cespare/xxhash/v2 # github.com/chzyer/readline v1.5.1 ## explicit; go 1.15 github.com/chzyer/readline -# github.com/cloudbase/garm-provider-common v0.0.0-20230723225907-c058d92fd686 +# github.com/cloudbase/garm-provider-common v0.0.0-20230724114054-7aa0a3dfbce0 ## explicit; go 1.20 github.com/cloudbase/garm-provider-common/cloudconfig github.com/cloudbase/garm-provider-common/defaults