Skip to content

Commit

Permalink
refacto: Some renames
Browse files Browse the repository at this point in the history
  • Loading branch information
fteychene committed Jul 29, 2024
1 parent f7a362e commit 843d552
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
11 changes: 7 additions & 4 deletions client/gatway_client.go → client/gateway_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

type GatewayClient struct {
cdkGatewayUser string
CdkGatewayPassword string
cdkGatewayPassword string
baseUrl string
client *resty.Client
kinds schema.KindCatalog
Expand All @@ -28,7 +28,7 @@ type GatewayApiParameter struct {
CdkGatewayPassword string
}

func MakeGateaway(apiParameter GatewayApiParameter) (*GatewayClient, error) {
func MakeGateway(apiParameter GatewayApiParameter) (*GatewayClient, error) {
restyClient := resty.New().SetDebug(apiParameter.Debug).SetHeader("X-CDK-CLIENT", "CLI/"+utils.GetConduktorVersion())

if apiParameter.BaseUrl == "" {
Expand All @@ -41,7 +41,7 @@ func MakeGateaway(apiParameter GatewayApiParameter) (*GatewayClient, error) {

result := &GatewayClient{
cdkGatewayUser: apiParameter.CdkGatewayUser,
CdkGatewayPassword: apiParameter.CdkGatewayPassword,
cdkGatewayPassword: apiParameter.CdkGatewayPassword,
baseUrl: apiParameter.BaseUrl,
client: restyClient,
kinds: nil,
Expand All @@ -68,7 +68,7 @@ func MakeGatewayClientFromEnv() (*GatewayClient, error) {
CdkGatewayPassword: os.Getenv("CDK_GATEWAY_PASSWORD"),
}

client, err := MakeGateaway(apiParameter)
client, err := MakeGateway(apiParameter)
if err != nil {
return nil, fmt.Errorf("Cannot create client: %s", err)
}
Expand Down Expand Up @@ -253,6 +253,9 @@ func (client *GatewayClient) DeleteResourceInterceptors(resource *resource.Resou
return fmt.Errorf("kind %s not found", resource.Kind)
}
deletePath, err := kind.DeletePath(resource)
if err != nil {
return err
}
url := client.baseUrl + deletePath
resp, err := client.client.R().SetBody(deleteInterceptorPayload).Delete(url)
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions client/gateway_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var aVClusterResource = resource.Resource{
func TestGwApplyShouldWork(t *testing.T) {
defer httpmock.Reset()
baseUrl := "http://baseUrl"
gatewayClient, err := MakeGateaway(GatewayApiParameter{
gatewayClient, err := MakeGateway(GatewayApiParameter{
BaseUrl: baseUrl,
Debug: false,
CdkGatewayUser: "admin",
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestGwApplyShouldWork(t *testing.T) {
func TestGwApplyWithDryModeShouldWork(t *testing.T) {
defer httpmock.Reset()
baseUrl := "http://baseUrl"
gatewayClient, err := MakeGateaway(GatewayApiParameter{
gatewayClient, err := MakeGateway(GatewayApiParameter{
BaseUrl: baseUrl,
Debug: false,
CdkGatewayUser: "admin",
Expand Down Expand Up @@ -90,7 +90,7 @@ func TestGwApplyWithDryModeShouldWork(t *testing.T) {
func TestGwApplyShouldFailIfNo2xx(t *testing.T) {
defer httpmock.Reset()
baseUrl := "http://baseUrl"
gatewayClient, err := MakeGateaway(GatewayApiParameter{
gatewayClient, err := MakeGateway(GatewayApiParameter{
BaseUrl: baseUrl,
Debug: false,
CdkGatewayUser: "admin",
Expand Down Expand Up @@ -126,7 +126,7 @@ func TestGwApplyShouldFailIfNo2xx(t *testing.T) {
func TestGwGetShouldWork(t *testing.T) {
defer httpmock.Reset()
baseUrl := "http://baseUrl"
gatewayClient, err := MakeGateaway(GatewayApiParameter{
gatewayClient, err := MakeGateway(GatewayApiParameter{
BaseUrl: baseUrl,
Debug: false,
CdkGatewayUser: "admin",
Expand Down Expand Up @@ -165,7 +165,7 @@ func TestGwGetShouldWork(t *testing.T) {
func TestGwGetShouldFailIfN2xx(t *testing.T) {
defer httpmock.Reset()
baseUrl := "http://baseUrl"
gatewayClient, err := MakeGateaway(GatewayApiParameter{
gatewayClient, err := MakeGateway(GatewayApiParameter{
BaseUrl: baseUrl,
Debug: false,
CdkGatewayUser: "admin",
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestGwGetShouldFailIfN2xx(t *testing.T) {
func TestGwDeleteShouldWork(t *testing.T) {
defer httpmock.Reset()
baseUrl := "http://baseUrl"
gatewayClient, err := MakeGateaway(GatewayApiParameter{
gatewayClient, err := MakeGateway(GatewayApiParameter{
BaseUrl: baseUrl,
Debug: false,
CdkGatewayUser: "admin",
Expand Down Expand Up @@ -236,7 +236,7 @@ func TestGwDeleteShouldWork(t *testing.T) {
func TestGwDeleteShouldFailOnNot2XX(t *testing.T) {
defer httpmock.Reset()
baseUrl := "http://baseUrl"
gatewayClient, err := MakeGateaway(GatewayApiParameter{
gatewayClient, err := MakeGateway(GatewayApiParameter{
BaseUrl: baseUrl,
Debug: false,
CdkGatewayUser: "admin",
Expand Down

0 comments on commit 843d552

Please sign in to comment.