Skip to content

Commit

Permalink
fixed schema & logs
Browse files Browse the repository at this point in the history
  • Loading branch information
yairsimantov20 committed Dec 11, 2023
1 parent a32b98b commit a04dfd1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
19 changes: 18 additions & 1 deletion pkg/port/cli/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,27 @@ import (
"github.com/port-labs/port-k8s-exporter/pkg/port"
)

func parseIntegration(i *port.Integration) *port.Integration {
x := &port.Integration{
Title: i.Title,
InstallationAppType: i.InstallationAppType,
InstallationId: i.InstallationId,
Config: i.Config,
}

if i.EventListener.Type == "KAFKA" {
x.EventListener = port.EventListenerSettings{
Type: i.EventListener.Type,
}
}

return x
}

func (c *PortClient) CreateIntegration(i *port.Integration) (*port.Integration, error) {
pb := &port.ResponseBody{}
resp, err := c.Client.R().
SetBody(i).
SetBody(parseIntegration(i)).
SetResult(&pb).
SetQueryParam("upsert", "true").
Post("v1/integration")
Expand Down
2 changes: 1 addition & 1 deletion pkg/port/cli/kafka_crednetials.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func (c *PortClient) GetKafkaCredentials() (*port.OrgKafkaCredentials, error) {
return nil, err
}
if !pb.OK {
return nil, fmt.Errorf("failed to create integration, got: %s", resp.Body())
return nil, fmt.Errorf("failed to get kafka crednetials, got: %s", resp.Body())
}
return &pb.KafkaCredentials, nil
}
2 changes: 1 addition & 1 deletion pkg/port/cli/org_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (c *PortClient) GetOrgId() (string, error) {
return "", err
}
if !pb.OK {
return "", fmt.Errorf("failed to create integration, got: %s", resp.Body())
return "", fmt.Errorf("failed to get orgId, got: %s", resp.Body())
}
return pb.OrgDetails.OrgId, nil
}
24 changes: 12 additions & 12 deletions pkg/port/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,34 +144,34 @@ type ResponseBody struct {
}

type EntityMapping struct {
Identifier string
Title string
Blueprint string
Team string
Properties map[string]string
Relations map[string]string
Identifier string `json:"identifier"`
Title string `json:"title"`
Blueprint string `json:"blueprint"`
Team string `json:"team"`
Properties map[string]string `json:"properties,omitempty"`
Relations map[string]string `json:"relations,omitempty"`
}

type EntityMappings struct {
Mappings []EntityMapping
Mappings []EntityMapping `json:"mappings"`
}

type Port struct {
Entity EntityMappings
Entity EntityMappings `json:"entity"`
}

type Selector struct {
Query string
}

type Resource struct {
Kind string
Selector Selector
Port Port
Kind string `json:"kind"`
Selector Selector `json:"selector,omitempty"`
Port Port `json:"port"`
}

type EventListenerSettings struct {
Type string `json:"type"`
Type string `json:"type,omitempty"`
}

type KindConfig struct {
Expand Down

0 comments on commit a04dfd1

Please sign in to comment.