Move store item into schema package

Signed-off-by: Amir Karimi <a.karimi.k@gmail.com>
This commit is contained in:
Amir Karimi
2017-12-31 00:19:14 +00:00
committed by Alex Ellis
parent 12d5221572
commit cdeb21d131
2 changed files with 18 additions and 15 deletions

View File

@@ -15,6 +15,7 @@ import (
"text/tabwriter"
"github.com/openfaas/faas-cli/proxy"
"github.com/openfaas/faas-cli/schema"
"github.com/spf13/cobra"
)
@@ -22,17 +23,6 @@ var storeAddress string
const defaultStore = "https://cdn.rawgit.com/openfaas/store/master/store.json"
type storeItem struct {
Title string `json:"title"`
Description string `json:"description"`
Image string `json:"image"`
Name string `json:"name"`
Fprocess string `json:"fprocess"`
Network string `json:"network"`
RepoURL string `json:"repo_url"`
Environment map[string]string `json:"environment"`
}
func init() {
// Setup flags that are used by multiple commands (variables defined in faas.go)
storeListCmd.Flags().StringVarP(&storeAddress, "store", "g", defaultStore, "Store URL starting with http(s)://")
@@ -190,8 +180,8 @@ func runStoreDeploy(cmd *cobra.Command, args []string) error {
)
}
func storeList(store string) ([]storeItem, error) {
var results []storeItem
func storeList(store string) ([]schema.StoreItem, error) {
var results []schema.StoreItem
store = strings.TrimRight(store, "/")
@@ -232,8 +222,8 @@ func storeList(store string) ([]storeItem, error) {
return results, nil
}
func findFunction(functionName string, storeItems []storeItem) *storeItem {
var item storeItem
func findFunction(functionName string, storeItems []schema.StoreItem) *schema.StoreItem {
var item schema.StoreItem
for _, item = range storeItems {
if item.Name == functionName || item.Title == functionName {

13
schema/store_item.go Normal file
View File

@@ -0,0 +1,13 @@
package schema
// StoreItem represents an item of store
type StoreItem struct {
Title string `json:"title"`
Description string `json:"description"`
Image string `json:"image"`
Name string `json:"name"`
Fprocess string `json:"fprocess"`
Network string `json:"network"`
RepoURL string `json:"repo_url"`
Environment map[string]string `json:"environment"`
}