This commit is contained in:
mr
2026-03-19 10:50:00 +01:00
parent c7884f5cde
commit 4eb53917b8
7 changed files with 5 additions and 46 deletions

View File

@@ -2,7 +2,6 @@ package bill
import ( import (
"encoding/json" "encoding/json"
"fmt"
"sync" "sync"
"time" "time"
@@ -194,7 +193,6 @@ func (d *PeerItemOrder) GetPriceHT(request *tools.APIRequest) (float64, error) {
b, _ := json.Marshal(d.Item) b, _ := json.Marshal(d.Item)
err := json.Unmarshal(b, priced) err := json.Unmarshal(b, priced)
if err != nil { if err != nil {
fmt.Println(err)
return 0, err return 0, err
} }
accessor := purchase_resource.NewAccessor(request) accessor := purchase_resource.NewAccessor(request)

View File

@@ -92,7 +92,6 @@ func filterEnrich[T utils.ShallowDBObject](arr []string, isDrafted bool, a utils
"abstractobject.id": {{Operator: dbs.IN.String(), Value: arr}}, "abstractobject.id": {{Operator: dbs.IN.String(), Value: arr}},
}, },
}, "", isDrafted) }, "", isDrafted)
fmt.Println(res, arr, isDrafted, a)
if code == 200 { if code == 200 {
for _, r := range res { for _, r := range res {
new = append(new, r.(T)) new = append(new, r.(T))

View File

@@ -41,7 +41,6 @@ func CheckPeerStatus(peerID string, appName string) (*Peer, bool) {
return nil, false return nil, false
} }
url := urlFormat(res.(*Peer).APIUrl, tools.PEER) + "/status" // Format the URL url := urlFormat(res.(*Peer).APIUrl, tools.PEER) + "/status" // Format the URL
fmt.Println(url)
state, services := api.CheckRemotePeer(url) state, services := api.CheckRemotePeer(url)
res.(*Peer).ServicesState = services // Update the services states of the peer res.(*Peer).ServicesState = services // Update the services states of the peer
access.UpdateOne(res.Serialize(res), peerID) // Update the peer in the db access.UpdateOne(res.Serialize(res), peerID) // Update the peer in the db

View File

@@ -189,7 +189,6 @@ func (d *Workflow) ExtractFromPlantUML(plantUML multipart.File, request *tools.A
newRes := new() newRes := new()
newRes.SetID(uuid.New().String()) newRes.SetID(uuid.New().String())
varName, graphItem, err := d.extractResourcePlantUML(parseLine, newRes, n, request.PeerID) varName, graphItem, err := d.extractResourcePlantUML(parseLine, newRes, n, request.PeerID)
fmt.Println(varName, graphItem, err)
if err != nil { if err != nil {
return d, err return d, err
} }
@@ -229,7 +228,6 @@ func (d *Workflow) ExtractFromPlantUML(plantUML multipart.File, request *tools.A
d.generateResource(d.GetResources(tools.STORAGE_RESOURCE), request) d.generateResource(d.GetResources(tools.STORAGE_RESOURCE), request)
d.generateResource(d.GetResources(tools.COMPUTE_RESOURCE), request) d.generateResource(d.GetResources(tools.COMPUTE_RESOURCE), request)
d.generateResource(d.GetResources(tools.WORKFLOW_RESOURCE), request) d.generateResource(d.GetResources(tools.WORKFLOW_RESOURCE), request)
fmt.Println("graphVarName", graphVarName)
d.Graph.Items = graphVarName d.Graph.Items = graphVarName
return d, nil return d, nil
} }
@@ -243,8 +241,7 @@ func (d *Workflow) generateResource(datas []resources.ResourceInterface, request
json.Unmarshal(b, &liv) json.Unmarshal(b, &liv)
data, _, err := access.StoreOne(&liv) data, _, err := access.StoreOne(&liv)
if err == nil { if err == nil {
_, _, err := access.CopyOne(data) access.CopyOne(data)
fmt.Println("COPY ", err)
} }
} }
continue continue
@@ -255,14 +252,12 @@ func (d *Workflow) generateResource(datas []resources.ResourceInterface, request
json.Unmarshal(b, &liv) json.Unmarshal(b, &liv)
data, _, err := access.StoreOne(&liv) data, _, err := access.StoreOne(&liv)
if err == nil { if err == nil {
_, _, err := access.CopyOne(data) access.CopyOne(data)
fmt.Println("COPY ", err)
} }
} }
continue continue
} }
_, _, err := d.GetAccessor(request).StoreOne(d) d.GetAccessor(request).StoreOne(d)
fmt.Println("ERR", err)
} }
return nil return nil
} }
@@ -364,7 +359,6 @@ func (d *Workflow) extractResourcePlantUML(line string, resource resources.Resou
varName := splittedParams[0] varName := splittedParams[0]
splitted := strings.Split(splittedParams[1], "\"") splitted := strings.Split(splittedParams[1], "\"")
fmt.Println(varName, splitted)
if len(splitted) <= 1 { if len(splitted) <= 1 {
return "", nil, errors.New("Can't deserialize Object, there's no name") return "", nil, errors.New("Can't deserialize Object, there's no name")

View File

@@ -2,7 +2,6 @@ package workflow_execution
import ( import (
"encoding/json" "encoding/json"
"fmt"
"strings" "strings"
"time" "time"
@@ -141,7 +140,6 @@ func (d *WorkflowExecution) Buy(bs pricing.BillingStrategy, executionsID string,
func (d *WorkflowExecution) buyEach(bs pricing.BillingStrategy, executionsID string, wfID string, dt tools.DataType, priceds map[string]pricing.PricedItemITF) []*purchase_resource.PurchaseResource { func (d *WorkflowExecution) buyEach(bs pricing.BillingStrategy, executionsID string, wfID string, dt tools.DataType, priceds map[string]pricing.PricedItemITF) []*purchase_resource.PurchaseResource {
items := []*purchase_resource.PurchaseResource{} items := []*purchase_resource.PurchaseResource{}
for itemID, priced := range priceds { for itemID, priced := range priceds {
fmt.Println(priced.IsPurchasable(), bs)
if !priced.IsPurchasable() || bs != pricing.BILL_ONCE { // buy only that must be buy if !priced.IsPurchasable() || bs != pricing.BILL_ONCE { // buy only that must be buy
continue continue
} }
@@ -217,7 +215,6 @@ func (d *WorkflowExecution) bookEach(executionsID string, wfID string, dt tools.
if s := priced.GetLocationStart(); s != nil && s.After(time.Now()) { if s := priced.GetLocationStart(); s != nil && s.After(time.Now()) {
start = *s start = *s
} }
fmt.Println("qdqsd", start, d.ExecDate)
end := start.Add(time.Duration(priced.GetExplicitDurationInS()) * time.Second) end := start.Add(time.Duration(priced.GetExplicitDurationInS()) * time.Second)
var m map[string]interface{} var m map[string]interface{}
b, _ := json.Marshal(priced) b, _ := json.Marshal(priced)

View File

@@ -13,7 +13,6 @@ import (
func LoadKeyFromFilePrivate() (crypto.PrivKey, error) { func LoadKeyFromFilePrivate() (crypto.PrivKey, error) {
path := config.GetConfig().PrivateKeyPath path := config.GetConfig().PrivateKeyPath
fmt.Println(path)
data, err := os.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@@ -71,7 +71,6 @@ func NewKubernetesService(host string, ca string, cert string, data string) (*Ku
// Create clientset // Create clientset
clientset, err := kubernetes.NewForConfig(config) clientset, err := kubernetes.NewForConfig(config)
fmt.Println("NewForConfig", clientset, err)
if err != nil { if err != nil {
return nil, errors.New("Error creating Kubernetes client: " + err.Error()) return nil, errors.New("Error creating Kubernetes client: " + err.Error())
} }
@@ -100,7 +99,7 @@ func (k *KubernetesService) CreateNamespace(ctx context.Context, ns string) erro
}, },
} }
// Create the namespace // Create the namespace
fmt.Println("Creating namespace...", k.Set) fmt.Println("Creating namespace...")
if _, err := k.Set.CoreV1().Namespaces().Create(ctx, namespace, metav1.CreateOptions{}); err != nil { if _, err := k.Set.CoreV1().Namespaces().Create(ctx, namespace, metav1.CreateOptions{}); err != nil {
return errors.New("Error creating namespace: " + err.Error()) return errors.New("Error creating namespace: " + err.Error())
} }
@@ -276,17 +275,12 @@ func (k *KubernetesService) GetTargets(ctx context.Context) ([]string, error) {
return nil, err return nil, err
} }
fmt.Println(string(resp))
var targetDict map[string]interface{} var targetDict map[string]interface{}
err = json.Unmarshal(resp, &targetDict) err = json.Unmarshal(resp, &targetDict)
if err != nil { if err != nil {
fmt.Println("TODO: handle the error when unmarshalling k8s API response")
return nil, err return nil, err
} }
b, _ := json.MarshalIndent(targetDict, "", " ")
fmt.Println(string(b))
data := targetDict["items"].([]interface{}) data := targetDict["items"].([]interface{})
for _, item := range data { for _, item := range data {
@@ -396,7 +390,6 @@ func (k *KubernetesService) CreateKubeconfigSecret(context context.Context, kube
// config, err := base64.RawStdEncoding.DecodeString(kubeconfig) // config, err := base64.RawStdEncoding.DecodeString(kubeconfig)
if err != nil { if err != nil {
fmt.Println("Error while encoding kubeconfig") fmt.Println("Error while encoding kubeconfig")
fmt.Println(err)
return nil, err return nil, err
} }
@@ -406,21 +399,6 @@ func (k *KubernetesService) CreateKubeconfigSecret(context context.Context, kube
"config": config, "config": config,
}, },
) )
// exists, err := k.GetKubeconfigSecret(context,executionId)
// if err != nil {
// fmt.Println("Error verifying if kube secret exists in namespace ", executionId)
// return nil, err
// }
// if exists != nil {
// fmt.Println("kube-secret already exists in namespace", executionId)
// fmt.Println("Overriding existing kube-secret with a newer resource")
// // TODO : implement DeleteKubeConfigSecret(executionID)
// deleted, err := k.DeleteKubeConfigSecret(executionId)
// _ = deleted
// _ = err
// }
resp, err := k.Set.CoreV1(). resp, err := k.Set.CoreV1().
Secrets(executionId). Secrets(executionId).
Apply(context, Apply(context,
@@ -431,14 +409,12 @@ func (k *KubernetesService) CreateKubeconfigSecret(context context.Context, kube
if err != nil { if err != nil {
fmt.Println("Error while trying to contact API to get secret kube-secret-" + executionId) fmt.Println("Error while trying to contact API to get secret kube-secret-" + executionId)
fmt.Println(err)
return nil, err return nil, err
} }
data, err := json.Marshal(resp) data, err := json.Marshal(resp)
if err != nil { if err != nil {
fmt.Println("Couldn't marshal resp from : ", data) fmt.Println("Couldn't marshal resp from : ", data)
fmt.Println(err)
return nil, err return nil, err
} }
return data, nil return data, nil
@@ -455,7 +431,6 @@ func (k *KubernetesService) GetKubeconfigSecret(context context.Context, executi
return nil, nil return nil, nil
} }
fmt.Println("Error while trying to contact API to get secret kube-secret-" + executionId) fmt.Println("Error while trying to contact API to get secret kube-secret-" + executionId)
fmt.Println(err)
return nil, err return nil, err
} }
@@ -463,7 +438,6 @@ func (k *KubernetesService) GetKubeconfigSecret(context context.Context, executi
if err != nil { if err != nil {
fmt.Println("Couldn't marshal resp from : ", data) fmt.Println("Couldn't marshal resp from : ", data)
fmt.Println(err)
return nil, err return nil, err
} }
@@ -526,7 +500,7 @@ func dynamicClientApply(host string, ca string, cert string, data string, execut
// We can add more info to the log with the content of resp if not nil // We can add more info to the log with the content of resp if not nil
resByte, err := json.Marshal(res) resByte, err := json.Marshal(res)
if err != nil { if err != nil {
// fmt.Println("Error trying to create a Source on remote cluster : ", err , " : ", res) fmt.Println("Error trying to create a Source on remote cluster : ", err, " : ", res)
return nil, err return nil, err
} }
@@ -584,7 +558,6 @@ func (k *KubernetesService) GetOneNode(context context.Context, executionID stri
) )
if err != nil { if err != nil {
fmt.Println("Error getting the list of nodes from k8s API") fmt.Println("Error getting the list of nodes from k8s API")
fmt.Println(err)
return nil, err return nil, err
} }