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

Commit

Permalink
Disable runtime check if has no permissions to do so (#992)
Browse files Browse the repository at this point in the history
* Disable runtime check if has no permissions to do so

* Stupid error

* Making sure nobody uses nil config
  • Loading branch information
dimm0 authored and andresmgot committed Jan 31, 2019
1 parent 6d371ae commit 25afd67
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions cmd/kubeless/function/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,31 @@ var deployCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
cli := kubelessUtils.GetClientOutOfCluster()
apiExtensionsClientset := kubelessUtils.GetAPIExtensionsClientOutOfCluster()
config, err := kubelessUtils.GetKubelessConfig(cli, apiExtensionsClientset)
if err != nil {
logrus.Fatalf("Unable to read the configmap: %v", err)
}

var lr = langruntime.New(config)
lr.ReadConfigMap()

if len(args) != 1 {
logrus.Fatal("Need exactly one argument - function name")
}
funcName := args[0]

runtime, err := cmd.Flags().GetString("runtime")
if err != nil {
logrus.Fatal(err)
}

// Checking runtime parameter if allowed by RBAC, otherwide skip the check
config, err := kubelessUtils.GetKubelessConfig(cli, apiExtensionsClientset)
if config == nil || err != nil {
logrus.Warnf("%v. Runtime check is disabled.", err)
} else {
lr := langruntime.New(config)
lr.ReadConfigMap()

if runtime != "" && !lr.IsValidRuntime(runtime) {
logrus.Fatalf("Invalid runtime: %s. Supported runtimes are: %s",
runtime, strings.Join(lr.GetRuntimes(), ", "))
}
}

schedule, err := cmd.Flags().GetString("schedule")
if err != nil {
logrus.Fatal(err)
Expand All @@ -74,16 +86,6 @@ var deployCmd = &cobra.Command{
logrus.Fatal(err)
}

runtime, err := cmd.Flags().GetString("runtime")
if err != nil {
logrus.Fatal(err)
}

if runtime != "" && !lr.IsValidRuntime(runtime) {
logrus.Fatalf("Invalid runtime: %s. Supported runtimes are: %s",
runtime, strings.Join(lr.GetRuntimes(), ", "))
}

handler, err := cmd.Flags().GetString("handler")
if err != nil {
logrus.Fatal(err)
Expand Down

0 comments on commit 25afd67

Please sign in to comment.