Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
Inform users not to run as root or on a K8s master
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Dec 15, 2020
1 parent a8c36ce commit daf63ff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
13 changes: 10 additions & 3 deletions cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,16 @@ func runApplyCommandE(command *cobra.Command, _ []string) error {
}

if len(files) == 0 {
return fmt.Errorf("Provide one or more --file arguments")
return fmt.Errorf("provide one or more --file arguments")
}

if os.Getuid() == 0 {
return fmt.Errorf("do not run this tool as root, or on your server. Run it from your own client remotely")
}

plans := []types.Plan{}

log.Printf("Loading %d plans\n", len(files))
log.Printf("Loading %d plan(s)..OK.\n", len(files))
for _, yamlFile := range files {

yamlBytes, yamlErr := ioutil.ReadFile(yamlFile)
Expand Down Expand Up @@ -126,7 +130,6 @@ func runApplyCommandE(command *cobra.Command, _ []string) error {
}

clientArch, clientOS := env.GetClientArch()

userDir, err := config.InitUserDir()
if err != nil {
return err
Expand Down Expand Up @@ -162,6 +165,10 @@ func runApplyCommandE(command *cobra.Command, _ []string) error {
return errors.Wrap(err, "validateTools")
}

if arch := k8s.GetNodeArchitecture(); len(arch) == 0 {
return fmt.Errorf("unable to detect node architecture. Do not run as root, or directly on a Kubernetes master node")
}

if prefs.SkipCreateSecrets == false {
validateErr := validatePlan(plan)
if validateErr != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/registry_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func generateRegistryAuthFile(command *cobra.Command, _ []string) error {
return generateErr
}

fmt.Printf("\nWrote ./credentials/docker.json..OK\n")
fmt.Printf("\nWrote ./credentials/config.json..OK\n")

return nil
}
Expand Down
1 change: 0 additions & 1 deletion scripts/create-namespaces.sh

This file was deleted.

0 comments on commit daf63ff

Please sign in to comment.