-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
214 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package requests | ||
|
||
import ( | ||
"github.com/kyma-project/btp-manager/internal/service-manager/types/requests" | ||
) | ||
|
||
func CreateServiceBindingVM(request CreateServiceBinding) requests.CreateServiceBindingRequestPayload { | ||
payload := requests.CreateServiceBindingRequestPayload{ | ||
Name: request.Name, | ||
ServiceInstanceID: request.ServiceInstanceId, | ||
Parameters: []byte(request.Parameters), | ||
Labels: map[string][]string{}, | ||
} | ||
payload.Labels["_clusterid"] = append(payload.Labels["_clusterid"], payload.Name) | ||
payload.Labels["_namespace"] = append(payload.Labels["_namespace"], request.Namespace) | ||
payload.Labels["_k8sname"] = append(payload.Labels["_k8sname"], request.Name) | ||
return payload | ||
} |
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,8 @@ | ||
package requests | ||
|
||
type CreateServiceBinding struct { | ||
Name string `json:"name"` | ||
Namespace string `json:"namespace"` | ||
ServiceInstanceId string `json:"serviceInstanceId"` | ||
Parameters string `json:"parameters"` | ||
} |
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,83 @@ | ||
package responses | ||
|
||
import ( | ||
"github.com/kyma-project/btp-manager/internal/service-manager/types" | ||
v1 "k8s.io/api/core/v1" | ||
) | ||
|
||
func ToSecretVM(list v1.SecretList) Secrets { | ||
secrets := Secrets{ | ||
Items: []Secret{}, | ||
} | ||
for _, secret := range list.Items { | ||
secrets.Items = append( | ||
secrets.Items, Secret{ | ||
Name: secret.Name, | ||
Namespace: secret.Namespace, | ||
}, | ||
) | ||
} | ||
return secrets | ||
} | ||
|
||
func ToServiceOfferingsVM(offerings *types.ServiceOfferings) ServiceOfferings { | ||
toReturn := ServiceOfferings{ | ||
NumItems: len(offerings.ServiceOfferings), | ||
Items: []ServiceOffering{}, | ||
} | ||
|
||
for _, offering := range offerings.ServiceOfferings { | ||
imageUrl, _ := offering.MetadataValueByFieldName(types.ServiceOfferingImageUrl) | ||
displayName, _ := offering.MetadataValueByFieldName(types.ServiceOfferingDisplayName) | ||
supportUrl, _ := offering.MetadataValueByFieldName(types.ServiceOfferingSupportURL) | ||
documentationUrl, _ := offering.MetadataValueByFieldName(types.ServiceOfferingDocumentationUrl) | ||
offering := ServiceOffering{ | ||
ID: offering.ID, | ||
Description: offering.Description, | ||
CatalogID: offering.CatalogID, | ||
CatalogName: offering.CatalogName, | ||
Metadata: ServiceOfferingMetadata{ | ||
ImageUrl: imageUrl, | ||
DisplayName: displayName, | ||
SupportUrl: supportUrl, | ||
DocumentationUrl: documentationUrl, | ||
}, | ||
} | ||
toReturn.Items = append(toReturn.Items, offering) | ||
} | ||
return toReturn | ||
} | ||
|
||
func ToServiceOfferingDetailsVM(details *types.ServiceOfferingDetails) ServiceOfferingDetails { | ||
toReturn := ServiceOfferingDetails{ | ||
Plans: []ServiceOfferingPlan{}, | ||
} | ||
|
||
toReturn.LongDescription, _ = details.MetadataValueByFieldName(types.ServiceOfferingLongDescription) | ||
|
||
for _, plan := range details.ServicePlans.ServicePlans { | ||
toReturn.Plans = append(toReturn.Plans, ServiceOfferingPlan{ | ||
Name: plan.Name, | ||
Description: plan.Description, | ||
}) | ||
} | ||
|
||
return toReturn | ||
} | ||
|
||
func ToServiceBindingsVM(bindings *types.ServiceBindings) ServiceBindings { | ||
toReturn := ServiceBindings{ | ||
Items: []ServiceBinding{}, | ||
} | ||
|
||
for _, _ = range bindings.ServiceBindings { | ||
n := ServiceBinding{} | ||
toReturn.Items = append(toReturn.Items, n) | ||
} | ||
|
||
return toReturn | ||
} | ||
|
||
func ToServiceBindingVM(binding *types.ServiceBinding) ServiceBindings { | ||
return ServiceBindings{} | ||
} |
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,58 @@ | ||
package responses | ||
|
||
type Secrets struct { | ||
Items []Secret `json:"items"` | ||
} | ||
|
||
type Secret struct { | ||
Name string `json:"name"` | ||
Namespace string `json:"namespace"` | ||
} | ||
|
||
type ServiceOfferings struct { | ||
NumItems int `json:"numItems"` | ||
Items []ServiceOffering `json:"items"` | ||
} | ||
|
||
type ServiceOffering struct { | ||
ID string `json:"id"` | ||
Description string `json:"description"` | ||
CatalogID string `json:"catalogID"` | ||
CatalogName string `json:"catalogName"` | ||
Metadata ServiceOfferingMetadata `json:"metadata"` | ||
} | ||
|
||
type ServiceOfferingMetadata struct { | ||
ImageUrl string `json:"imageUrl"` | ||
DisplayName string `json:"displayName"` | ||
DocumentationUrl string `json:"documentationUrl"` | ||
SupportUrl string `json:"supportUrl"` | ||
} | ||
|
||
type ServiceInstances struct { | ||
Items []ServiceInstance `json:"items"` | ||
} | ||
|
||
type ServiceInstance struct { | ||
Name string `json:"name"` | ||
Namespace string `json:"namespace"` | ||
} | ||
|
||
type ServiceOfferingDetails struct { | ||
LongDescription string `json:"longDescription"` | ||
Plans []ServiceOfferingPlan `json:"plans"` | ||
} | ||
|
||
type ServiceOfferingPlan struct { | ||
Name string `json:"name"` | ||
Description string `json:"description"` | ||
} | ||
|
||
type ServiceBinding struct { | ||
Name string `json:"name"` | ||
Namespace string `json:"namespace"` | ||
} | ||
|
||
type ServiceBindings struct { | ||
Items []ServiceBinding `json:"items"` | ||
} |
15 changes: 15 additions & 0 deletions
15
internal/service-manager/types/requests/CreateServiceBindingRequestPayload.go
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,15 @@ | ||
package requests | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/kyma-project/btp-manager/internal/service-manager/types" | ||
) | ||
|
||
type CreateServiceBindingRequestPayload struct { | ||
Name string `json:"name"` | ||
ServiceInstanceID string `json:"service_instance_id" yaml:"service_instance_id,omitempty"` | ||
Parameters json.RawMessage `json:"parameters,omitempty" yaml:"parameters,omitempty"` | ||
Labels types.Labels `json:"labels,omitempty" yaml:"labels,omitempty"` | ||
BindResource json.RawMessage `json:"bind_resource" yaml:"bind_resource"` | ||
} |
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,32 @@ | ||
package types | ||
|
||
import "encoding/json" | ||
|
||
// ServiceBinding defines the data of a service instance. | ||
type ServiceBinding struct { | ||
Common | ||
Labels Labels `json:"labels,omitempty" yaml:"labels,omitempty"` | ||
PagingSequence int64 `json:"-" yaml:"-"` | ||
|
||
Credentials json.RawMessage `json:"credentials,omitempty" yaml:"credentials,omitempty"` | ||
|
||
ServiceInstanceID string `json:"service_instance_id" yaml:"service_instance_id,omitempty"` | ||
ServiceInstanceName string `json:"service_instance_name,omitempty" yaml:"service_instance_name,omitempty"` | ||
|
||
SyslogDrainURL string `json:"syslog_drain_url,omitempty" yaml:"syslog_drain_url,omitempty"` | ||
RouteServiceURL string `json:"route_service_url,omitempty"` | ||
VolumeMounts json.RawMessage `json:"-" yaml:"-"` | ||
Endpoints json.RawMessage `json:"-" yaml:"-"` | ||
Context json.RawMessage `json:"context,omitempty" yaml:"context,omitempty"` | ||
Parameters json.RawMessage `json:"parameters,omitempty" yaml:"parameters,omitempty"` | ||
BindResource json.RawMessage `json:"-" yaml:"-"` | ||
|
||
Namespace string `json:"namespace"` | ||
Name string `json:"name"` | ||
} | ||
|
||
// ServiceBindings wraps an array of service bindings | ||
type ServiceBindings struct { | ||
ServiceBindings []ServiceBinding `json:"items" yaml:"items"` | ||
Vertical bool `json:"-" yaml:"-"` | ||
} |