Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Bigler <[email protected]>
  • Loading branch information
TheBigLee committed Dec 19, 2023
1 parent 32805e9 commit 0ce3089
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions pkg/exoscale/dbaas.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ var (
Kind: "KafkaList",
},
}

dbaasTypes = map[string]string{
"pg": "PostgreSQL",
"mysql": "MySQL",
"opensearch": "OpenSearch",
"redis": "Redis",
"kafka": "Kafka",
}
)

// Detail a helper structure for intermediate operations
Expand Down Expand Up @@ -147,6 +155,7 @@ func findDBaaSDetailInNamespacesMap(ctx context.Context, resource metav1.Partial
Kind: gvk.Kind,
Namespace: namespace,
Organization: organization,
Zone: resource.GetAnnotations()["appcat.vshn.io/cloudzone"],
}

logger.V(1).Info("Added namespace and organization to DBaaS", "namespace", dbaasDetail.Namespace, "organization", dbaasDetail.Organization)
Expand Down Expand Up @@ -198,7 +207,10 @@ func (ds *DBaaS) AggregateDBaaS(ctx context.Context, exoscaleDBaaS []*egoscale.D
if exists && dbaasDetail.Kind == groupVersionKinds[*dbaasUsage.Type].Kind {
logger.V(1).Info("Found exoscale dbaas usage", "instance", dbaasUsage.Name, "instance created", dbaasUsage.CreatedAt)

itemGroup := fmt.Sprintf("APPUiO Managed - Zone: %s / Namespace: %s", ds.clusterId, dbaasDetail.Namespace)
instanceId := fmt.Sprintf("%s/%s", dbaasDetail.Zone, dbaasDetail.DBName)
if ds.salesOrder == "" {
itemGroup = fmt.Sprintf("APPUiO Cloud - Zone: %s / Namespace: %s", ds.clusterId, dbaasDetail.Namespace)
ds.salesOrder, err = controlAPI.GetSalesOrder(ctx, ds.controlApiClient, dbaasDetail.Organization)
if err != nil {
logger.Error(err, "Unable to sync DBaaS, cannot get salesOrder", "namespace", dbaasDetail.Namespace)
Expand All @@ -209,9 +221,9 @@ func (ds *DBaaS) AggregateDBaaS(ctx context.Context, exoscaleDBaaS []*egoscale.D
// TODO zones and namespaces?
o := odoo.OdooMeteredBillingRecord{
ProductID: productIdPrefix + fmt.Sprintf("-%s-%s", *dbaasUsage.Type, *dbaasUsage.Plan),
InstanceID: dbaasDetail.DBName,
ItemDescription: "Exoscale DBaaS",
ItemGroupDescription: "AppCat Exoscale DBaaS",
InstanceID: instanceId,
ItemDescription: "Exoscale DBaaS " + dbaasTypes[*dbaasUsage.Type],
ItemGroupDescription: itemGroup,
SalesOrder: ds.salesOrder,
UnitID: ds.uomMapping[odoo.InstanceHour],
ConsumedUnits: 1,
Expand Down

0 comments on commit 0ce3089

Please sign in to comment.