mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-02 06:16:08 -04:00
[node operator] self-initialize resources
Signed-off-by: Malte Poll <mp@edgeless.systems>
This commit is contained in:
parent
1cee319174
commit
51cf638361
27 changed files with 1021 additions and 26 deletions
|
@ -0,0 +1,24 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"regexp"
|
||||
|
||||
"github.com/spf13/afero"
|
||||
)
|
||||
|
||||
var projectIDRegex = regexp.MustCompile(`(?m)^project-id = (.*)$`)
|
||||
|
||||
// loadProjectID loads the project id from the gce config file.
|
||||
func loadProjectID(fs afero.Fs, path string) (string, error) {
|
||||
rawConfig, err := afero.ReadFile(fs, path)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
// find project-id line
|
||||
matches := projectIDRegex.FindStringSubmatch(string(rawConfig))
|
||||
if len(matches) != 2 {
|
||||
return "", errors.New("invalid config: project-id not found")
|
||||
}
|
||||
return matches[1], nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue