Skip to content

Commit f13bf93

Browse files
committed
Add OPENFAAS_STORE for when the function store is custom
Rather than having to set --url each time the store needs to change, this can be set in the .bashrc or equivalent file for the user. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 619282a commit f13bf93

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

commands/store_deploy.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ func preRunEStoreDeploy(cmd *cobra.Command, args []string) error {
7676

7777
func runStoreDeploy(cmd *cobra.Command, args []string) error {
7878
targetPlatform := getTargetPlatform(platformValue)
79+
80+
if v, ok := os.LookupEnv("OPENFAAS_STORE"); ok && len(v) > 0 {
81+
if !storeCmd.Flags().Changed("url") {
82+
storeAddress = v
83+
}
84+
}
85+
7986
storeItems, err := storeList(storeAddress)
8087
if err != nil {
8188
return err

commands/store_describe.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package commands
66
import (
77
"bytes"
88
"fmt"
9+
"os"
910
"text/tabwriter"
1011

1112
"github.com/mitchellh/go-wordwrap"
@@ -33,6 +34,13 @@ func runStoreDescribe(cmd *cobra.Command, args []string) error {
3334
}
3435

3536
targetPlatform := getTargetPlatform(platformValue)
37+
38+
if v, ok := os.LookupEnv("OPENFAAS_STORE"); ok && len(v) > 0 {
39+
if !storeCmd.Flags().Changed("url") {
40+
storeAddress = v
41+
}
42+
}
43+
3644
storeItems, err := storeList(storeAddress)
3745
if err != nil {
3846
return err

commands/store_list.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package commands
66
import (
77
"bytes"
88
"fmt"
9+
"os"
910
"strings"
1011
"text/tabwriter"
1112

@@ -33,6 +34,16 @@ var storeListCmd = &cobra.Command{
3334
func runStoreList(cmd *cobra.Command, args []string) error {
3435
targetPlatform := getTargetPlatform(platformValue)
3536

37+
// Support priority order override.
38+
// --url by default, unless OPENFAAS_STORE is given, in which
39+
// case the flag takes precedence if it has been changed from its
40+
// default
41+
if v, ok := os.LookupEnv("OPENFAAS_STORE"); ok && len(v) > 0 {
42+
if !storeCmd.Flags().Changed("url") {
43+
storeAddress = v
44+
}
45+
}
46+
3647
storeList, err := storeList(storeAddress)
3748
if err != nil {
3849
return err

0 commit comments

Comments
 (0)