Move version in package name
Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/openfaas/faas-cli/proxy"
|
||||
"github.com/openfaas/faas-cli/schema"
|
||||
v2 "github.com/openfaas/faas-cli/schema/store/v2"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -44,9 +44,9 @@ var storeCmd = &cobra.Command{
|
||||
Long: "Allows browsing and deploying OpenFaaS functions from a store",
|
||||
}
|
||||
|
||||
func storeList(store string) ([]schema.StoreFunction, error) {
|
||||
func storeList(store string) ([]v2.StoreFunction, error) {
|
||||
|
||||
var storeData schema.StoreV2
|
||||
var storeData v2.Store
|
||||
|
||||
store = strings.TrimRight(store, "/")
|
||||
|
||||
@@ -85,8 +85,8 @@ func storeList(store string) ([]schema.StoreFunction, error) {
|
||||
return storeData.Functions, nil
|
||||
}
|
||||
|
||||
func filterStoreList(functions []schema.StoreFunction, platform string) []schema.StoreFunction {
|
||||
var filteredList []schema.StoreFunction
|
||||
func filterStoreList(functions []v2.StoreFunction, platform string) []v2.StoreFunction {
|
||||
var filteredList []v2.StoreFunction
|
||||
|
||||
for _, function := range functions {
|
||||
|
||||
@@ -110,8 +110,8 @@ func getValueIgnoreCase(kv map[string]string, key string) (string, bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
func storeFindFunction(functionName string, storeItems []schema.StoreFunction) *schema.StoreFunction {
|
||||
var item schema.StoreFunction
|
||||
func storeFindFunction(functionName string, storeItems []v2.StoreFunction) *v2.StoreFunction {
|
||||
var item v2.StoreFunction
|
||||
|
||||
for _, item = range storeItems {
|
||||
if item.Name == functionName || item.Title == functionName {
|
||||
@@ -136,7 +136,7 @@ func getTargetPlatform(inputPlatform string) string {
|
||||
return inputPlatform
|
||||
}
|
||||
|
||||
func getStorePlatforms(functions []schema.StoreFunction) []string {
|
||||
func getStorePlatforms(functions []v2.StoreFunction) []string {
|
||||
var distinctPlatformMap = make(map[string]bool)
|
||||
var result []string
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ func runStoreDeploy(cmd *cobra.Command, args []string) error {
|
||||
|
||||
gateway = getGatewayURL(gateway, defaultGateway, "", os.Getenv(openFaaSURLEnvironment))
|
||||
|
||||
statusCode, err := deployImage(item.Image, item.Fprocess, itemName, registryAuth, storeDeployFlags,
|
||||
statusCode, err := deployImage(imageName, item.Fprocess, itemName, registryAuth, storeDeployFlags,
|
||||
tlsInsecure, item.ReadOnlyRootFilesystem, token, functionNamespace)
|
||||
|
||||
if badStatusCode(statusCode) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"fmt"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/openfaas/faas-cli/schema"
|
||||
v2 "github.com/openfaas/faas-cli/schema/store/v2"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -52,7 +52,7 @@ func runStoreInspect(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func storeRenderItem(item *schema.StoreFunction, platform string) string {
|
||||
func storeRenderItem(item *v2.StoreFunction, platform string) string {
|
||||
var b bytes.Buffer
|
||||
w := tabwriter.NewWriter(&b, 0, 0, 1, ' ', 0)
|
||||
fmt.Fprintln(w)
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/openfaas/faas-cli/schema"
|
||||
v2 "github.com/openfaas/faas-cli/schema/store/v2"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -51,7 +51,7 @@ func runStoreList(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func storeRenderItems(items []schema.StoreFunction) string {
|
||||
func storeRenderItems(items []v2.StoreFunction) string {
|
||||
var b bytes.Buffer
|
||||
w := tabwriter.NewWriter(&b, 0, 0, 1, ' ', 0)
|
||||
fmt.Fprintln(w)
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/openfaas/faas-cli/schema"
|
||||
v2 "github.com/openfaas/faas-cli/schema/store/v2"
|
||||
)
|
||||
|
||||
func matchFilteredOutout(t *testing.T, expectedOuputFunctions, filteredFunctions []schema.StoreFunction, platform string) {
|
||||
func matchFilteredOutout(t *testing.T, expectedOuputFunctions, filteredFunctions []v2.StoreFunction, platform string) {
|
||||
if len(expectedOuputFunctions) != len(filteredFunctions) {
|
||||
t.Errorf("Length did not match, expected: %v, got: %v", len(expectedOuputFunctions), len(filteredFunctions))
|
||||
}
|
||||
@@ -29,7 +29,7 @@ func matchFilteredOutout(t *testing.T, expectedOuputFunctions, filteredFunctions
|
||||
}
|
||||
}
|
||||
|
||||
func getInputStoreFunctions(t *testing.T) []schema.StoreFunction {
|
||||
func getInputStoreFunctions(t *testing.T) []v2.StoreFunction {
|
||||
inputJSONBytes := []byte(`[{
|
||||
"title": "NodeInfo",
|
||||
"name": "nodeinfo",
|
||||
@@ -66,7 +66,7 @@ func getInputStoreFunctions(t *testing.T) []schema.StoreFunction {
|
||||
"repo_url": "https://github.com/openfaas/faas/tree/master/sample-functions/figlet"
|
||||
}]`)
|
||||
|
||||
var inputFunctions []schema.StoreFunction
|
||||
var inputFunctions []v2.StoreFunction
|
||||
err := json.Unmarshal(inputJSONBytes, &inputFunctions)
|
||||
if err != nil {
|
||||
t.Errorf(err.Error())
|
||||
@@ -101,7 +101,7 @@ func Test_filterStoreList_x86_64(t *testing.T) {
|
||||
}]`)
|
||||
|
||||
inputFunctions := getInputStoreFunctions(t)
|
||||
var expectedOuputFunctions []schema.StoreFunction
|
||||
var expectedOuputFunctions []v2.StoreFunction
|
||||
err := json.Unmarshal(outputJSONBytes, &expectedOuputFunctions)
|
||||
if err != nil {
|
||||
t.Errorf(err.Error())
|
||||
@@ -138,7 +138,7 @@ func Test_filterStoreList_armhf(t *testing.T) {
|
||||
}]`)
|
||||
|
||||
inputFunctions := getInputStoreFunctions(t)
|
||||
var expectedOuputFunctions []schema.StoreFunction
|
||||
var expectedOuputFunctions []v2.StoreFunction
|
||||
err := json.Unmarshal(outputJSONBytes, &expectedOuputFunctions)
|
||||
if err != nil {
|
||||
t.Errorf(err.Error())
|
||||
@@ -175,7 +175,7 @@ func Test_filterStoreList_arm64(t *testing.T) {
|
||||
}]`)
|
||||
|
||||
inputFunctions := getInputStoreFunctions(t)
|
||||
var expectedOuputFunctions []schema.StoreFunction
|
||||
var expectedOuputFunctions []v2.StoreFunction
|
||||
err := json.Unmarshal(outputJSONBytes, &expectedOuputFunctions)
|
||||
if err != nil {
|
||||
t.Errorf(err.Error())
|
||||
@@ -190,7 +190,7 @@ func Test_filterStoreList_other(t *testing.T) {
|
||||
outputJSONBytes := []byte(`[]`)
|
||||
|
||||
inputFunctions := getInputStoreFunctions(t)
|
||||
var expectedOuputFunctions []schema.StoreFunction
|
||||
var expectedOuputFunctions []v2.StoreFunction
|
||||
err := json.Unmarshal(outputJSONBytes, &expectedOuputFunctions)
|
||||
if err != nil {
|
||||
t.Errorf(err.Error())
|
||||
|
||||
32
schema/store/v2/store.go
Normal file
32
schema/store/v2/store.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) OpenFaaS Author(s) 2019. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
package v2
|
||||
|
||||
//StoreFunction represents a multi-arch function in the store
|
||||
type StoreFunction struct {
|
||||
Icon string `json:"icon"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Name string `json:"name"`
|
||||
Fprocess string `json:"fprocess"`
|
||||
Network string `json:"network"`
|
||||
RepoURL string `json:"repo_url"`
|
||||
ReadOnlyRootFilesystem bool `json:"readOnlyRootFilesystem"`
|
||||
Environment map[string]string `json:"environment"`
|
||||
Labels map[string]string `json:"labels"`
|
||||
Annotations map[string]string `json:"annotations"`
|
||||
Images map[string]string `json:"images"`
|
||||
}
|
||||
|
||||
//GetImageName get image name of function for a platform
|
||||
func (s *StoreFunction) GetImageName(platform string) string {
|
||||
imageName, _ := s.Images[platform]
|
||||
return imageName
|
||||
}
|
||||
|
||||
// Store represents an item of store for version 2
|
||||
type Store struct {
|
||||
Version string `json:"version"`
|
||||
Functions []StoreFunction `json:"functions"`
|
||||
}
|
||||
@@ -15,31 +15,3 @@ type StoreItem struct {
|
||||
Annotations map[string]string `json:"annotations"`
|
||||
ReadOnlyRootFilesystem bool `json:"readOnlyRootFilesystem"`
|
||||
}
|
||||
|
||||
//StoreFunction represents a multi-arch function in the store
|
||||
type StoreFunction struct {
|
||||
Icon string `json:"icon"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Name string `json:"name"`
|
||||
Fprocess string `json:"fprocess"`
|
||||
Network string `json:"network"`
|
||||
RepoURL string `json:"repo_url"`
|
||||
ReadOnlyRootFilesystem bool `json:"readOnlyRootFilesystem"`
|
||||
Environment map[string]string `json:"environment"`
|
||||
Labels map[string]string `json:"labels"`
|
||||
Annotations map[string]string `json:"annotations"`
|
||||
Images map[string]string `json:"images"`
|
||||
}
|
||||
|
||||
//GetImageName get image name of function for a platform
|
||||
func (s *StoreFunction) GetImageName(platform string) string {
|
||||
imageName, _ := s.Images[platform]
|
||||
return imageName
|
||||
}
|
||||
|
||||
// StoreV2 represents an item of store for version 2
|
||||
type StoreV2 struct {
|
||||
Version string `json:"version"`
|
||||
Functions []StoreFunction `json:"functions"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user