-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #959 from Vafilor/feat/create.namespace.stub
feat: stub out create namespace
- Loading branch information
Showing
11 changed files
with
540 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,4 +40,5 @@ message CreateNamespaceRequest { | |
|
||
message Namespace { | ||
string name = 1; | ||
string sourceName = 2; | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package v1 | ||
|
||
import ( | ||
"fmt" | ||
"github.com/onepanelio/core/pkg/util" | ||
"google.golang.org/grpc/codes" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"k8s.io/client-go/kubernetes/scheme" | ||
"k8s.io/client-go/rest" | ||
"strings" | ||
) | ||
|
||
const istioVirtualServiceResource = "VirtualServices" | ||
|
||
func istioModelRestClient() (*rest.RESTClient, error) { | ||
config := *NewConfig() | ||
config.GroupVersion = &schema.GroupVersion{Group: "networking.istio.io", Version: "v1alpha3"} | ||
config.APIPath = "/apis" | ||
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() | ||
|
||
return rest.RESTClientFor(&config) | ||
} | ||
|
||
// CreateVirtualService creates an istio virtual service | ||
func (c *Client) CreateVirtualService(namespace string, data interface{}) error { | ||
restClient, err := istioModelRestClient() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = restClient.Post(). | ||
Namespace(namespace). | ||
Resource(istioVirtualServiceResource). | ||
Body(data). | ||
Do(). | ||
Error() | ||
|
||
if err != nil && strings.Contains(err.Error(), "already exists") { | ||
return util.NewUserError(codes.AlreadyExists, fmt.Sprintf("VirtualService already exists")) | ||
} | ||
|
||
return err | ||
} |
Oops, something went wrong.