diff --git a/commands/secret_create.go b/commands/secret_create.go index 8c5d10d2..890dfd3c 100644 --- a/commands/secret_create.go +++ b/commands/secret_create.go @@ -11,7 +11,7 @@ import ( "strings" "github.com/openfaas/faas-cli/proxy" - "github.com/openfaas/faas-cli/schema" + types "github.com/openfaas/faas-provider/types" "github.com/spf13/cobra" ) @@ -68,7 +68,7 @@ func preRunSecretCreate(cmd *cobra.Command, args []string) error { } func runSecretCreate(cmd *cobra.Command, args []string) error { - secret := schema.Secret{ + secret := types.Secret{ Name: args[0], } diff --git a/commands/secret_list.go b/commands/secret_list.go index adf7ed7f..922ad88c 100644 --- a/commands/secret_list.go +++ b/commands/secret_list.go @@ -10,7 +10,7 @@ import ( "text/tabwriter" "github.com/openfaas/faas-cli/proxy" - "github.com/openfaas/faas-cli/schema" + types "github.com/openfaas/faas-provider/types" "github.com/spf13/cobra" ) @@ -61,7 +61,7 @@ func runSecretList(cmd *cobra.Command, args []string) error { return nil } -func renderSecretList(secrets []schema.Secret) string { +func renderSecretList(secrets []types.Secret) string { var b bytes.Buffer w := tabwriter.NewWriter(&b, 0, 0, 1, ' ', 0) fmt.Fprintln(w) diff --git a/commands/secret_remove.go b/commands/secret_remove.go index ab28bd76..b4d27a64 100644 --- a/commands/secret_remove.go +++ b/commands/secret_remove.go @@ -8,7 +8,7 @@ import ( "os" "github.com/openfaas/faas-cli/proxy" - "github.com/openfaas/faas-cli/schema" + types "github.com/openfaas/faas-provider/types" "github.com/spf13/cobra" ) @@ -49,7 +49,7 @@ func runSecretRemove(cmd *cobra.Command, args []string) error { fmt.Println(msg) } - secret := schema.Secret{ + secret := types.Secret{ Name: args[0], } err := proxy.RemoveSecretToken(gatewayAddress, secret, tlsInsecure, token) diff --git a/commands/secret_update.go b/commands/secret_update.go index 330d47f2..f5721562 100644 --- a/commands/secret_update.go +++ b/commands/secret_update.go @@ -10,7 +10,7 @@ import ( "strings" "github.com/openfaas/faas-cli/proxy" - "github.com/openfaas/faas-cli/schema" + types "github.com/openfaas/faas-provider/types" "github.com/spf13/cobra" ) @@ -60,7 +60,7 @@ func runSecretUpdate(cmd *cobra.Command, args []string) error { fmt.Println(msg) } - secret := schema.Secret{ + secret := types.Secret{ Name: args[0], } diff --git a/proxy/secret.go b/proxy/secret.go index 0e9e7301..c8a67844 100644 --- a/proxy/secret.go +++ b/proxy/secret.go @@ -8,17 +8,17 @@ import ( "net/http" "strings" - "github.com/openfaas/faas-cli/schema" + types "github.com/openfaas/faas-provider/types" ) // GetSecretList get secrets list -func GetSecretList(gateway string, tlsInsecure bool) ([]schema.Secret, error) { +func GetSecretList(gateway string, tlsInsecure bool) ([]types.Secret, error) { return GetSecretListToken(gateway, tlsInsecure, "") } // GetSecretListToken get secrets lists with taken as auth -func GetSecretListToken(gateway string, tlsInsecure bool, token string) ([]schema.Secret, error) { - var results []schema.Secret +func GetSecretListToken(gateway string, tlsInsecure bool, token string) ([]types.Secret, error) { + var results []types.Secret gateway = strings.TrimRight(gateway, "/") client := MakeHTTPClient(&defaultCommandTimeout, tlsInsecure) @@ -70,12 +70,12 @@ func GetSecretListToken(gateway string, tlsInsecure bool, token string) ([]schem } // UpdateSecret update a secret via the OpenFaaS API by name -func UpdateSecret(gateway string, secret schema.Secret, tlsInsecure bool) (int, string) { +func UpdateSecret(gateway string, secret types.Secret, tlsInsecure bool) (int, string) { return UpdateSecretToken(gateway, secret, tlsInsecure, "") } // UpdateSecretToken update a secret with token as auth -func UpdateSecretToken(gateway string, secret schema.Secret, tlsInsecure bool, token string) (int, string) { +func UpdateSecretToken(gateway string, secret types.Secret, tlsInsecure bool, token string) (int, string) { var output string gateway = strings.TrimRight(gateway, "/") @@ -127,12 +127,12 @@ func UpdateSecretToken(gateway string, secret schema.Secret, tlsInsecure bool, t } // RemoveSecret remove a secret via the OpenFaaS API by name -func RemoveSecret(gateway string, secret schema.Secret, tlsInsecure bool) error { +func RemoveSecret(gateway string, secret types.Secret, tlsInsecure bool) error { return RemoveSecretToken(gateway, secret, tlsInsecure, "") } // RemoveSecretToken remove a secret with token as auth -func RemoveSecretToken(gateway string, secret schema.Secret, tlsInsecure bool, token string) error { +func RemoveSecretToken(gateway string, secret types.Secret, tlsInsecure bool, token string) error { gateway = strings.TrimRight(gateway, "/") client := MakeHTTPClient(&defaultCommandTimeout, tlsInsecure) @@ -179,12 +179,12 @@ func RemoveSecretToken(gateway string, secret schema.Secret, tlsInsecure bool, t } // CreateSecret create secret -func CreateSecret(gateway string, secret schema.Secret, tlsInsecure bool) (int, string) { +func CreateSecret(gateway string, secret types.Secret, tlsInsecure bool) (int, string) { return CreateSecretToken(gateway, secret, tlsInsecure, "") } // CreateSecretToken create secret with token as auth -func CreateSecretToken(gateway string, secret schema.Secret, tlsInsecure bool, token string) (int, string) { +func CreateSecretToken(gateway string, secret types.Secret, tlsInsecure bool, token string) (int, string) { var output string gateway = strings.TrimRight(gateway, "/") diff --git a/proxy/secret_test.go b/proxy/secret_test.go index 65d7accc..534485f3 100644 --- a/proxy/secret_test.go +++ b/proxy/secret_test.go @@ -5,8 +5,8 @@ import ( "regexp" "testing" - "github.com/openfaas/faas-cli/schema" "github.com/openfaas/faas-cli/test" + types "github.com/openfaas/faas-provider/types" ) func Test_GetSecretList_200OK(t *testing.T) { @@ -81,7 +81,7 @@ func Test_GetSecretList_Unauthorized401(t *testing.T) { } } -var expectedSecretList = []schema.Secret{ +var expectedSecretList = []types.Secret{ { Name: "Secret1", }, @@ -92,7 +92,7 @@ var expectedSecretList = []schema.Secret{ func Test_CreateSecret_200OK(t *testing.T) { s := test.MockHttpServerStatus(t, http.StatusOK) - secret := schema.Secret{ + secret := types.Secret{ Name: "secret-name", Value: "secret-value", } @@ -106,7 +106,7 @@ func Test_CreateSecret_200OK(t *testing.T) { func Test_CreateSecret_201Created(t *testing.T) { s := test.MockHttpServerStatus(t, http.StatusCreated) - secret := schema.Secret{ + secret := types.Secret{ Name: "secret-name", Value: "secret-value", } @@ -120,7 +120,7 @@ func Test_CreateSecret_201Created(t *testing.T) { func Test_CreateSecret_202Accepted(t *testing.T) { s := test.MockHttpServerStatus(t, http.StatusAccepted) - secret := schema.Secret{ + secret := types.Secret{ Name: "secret-name", Value: "secret-value", } @@ -135,7 +135,7 @@ func Test_CreateSecret_202Accepted(t *testing.T) { func Test_CreateSecret_Not200(t *testing.T) { s := test.MockHttpServerStatus(t, http.StatusBadRequest) - secret := schema.Secret{ + secret := types.Secret{ Name: "secret-name", Value: "secret-value", } @@ -154,7 +154,7 @@ func Test_CreateSecret_Not200(t *testing.T) { func Test_CreateSecret_Unauthorized401(t *testing.T) { s := test.MockHttpServerStatus(t, http.StatusUnauthorized) - secret := schema.Secret{ + secret := types.Secret{ Name: "secret-name", Value: "secret-value", } @@ -173,7 +173,7 @@ func Test_CreateSecret_Unauthorized401(t *testing.T) { func Test_CreateSecret_Conflict409(t *testing.T) { s := test.MockHttpServerStatus(t, http.StatusConflict) - secret := schema.Secret{ + secret := types.Secret{ Name: "secret-name", Value: "secret-value", } diff --git a/schema/secret.go b/schema/secret.go index 8d9b54c0..9c0ef59b 100644 --- a/schema/secret.go +++ b/schema/secret.go @@ -11,9 +11,3 @@ type KubernetesSecretMetadata struct { Name string `json:"name"` Namespace string `json:"namespace"` } - -//Secret secret type -type Secret struct { - Name string `json:"name"` - Value string `json:"value,omitempty"` -}