feat(client): implemented DeleteInstance
Some checks failed
Go Tests / go-tests (push) Failing after 1m30s
Some checks failed
Go Tests / go-tests (push) Failing after 1m30s
This commit is contained in:
parent
37de81a835
commit
60ceddf649
3 changed files with 37 additions and 12 deletions
|
|
@ -300,6 +300,7 @@ func (e *EdgeConnect) DeleteAppInstance(ctx context.Context, appinstancekey AppI
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
request.Header.Set("Content-Type", "application/json")
|
request.Header.Set("Content-Type", "application/json")
|
||||||
request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
|
request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
|
||||||
|
|
||||||
|
|
@ -313,7 +314,7 @@ func (e *EdgeConnect) DeleteAppInstance(ctx context.Context, appinstancekey AppI
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Printf("Response: %v\n", string(bodyBytes))
|
fmt.Printf("Response: %v%v\n", resp.StatusCode, string(bodyBytes))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
20
lala/lala.go
20
lala/lala.go
|
|
@ -3,12 +3,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"edp.buildth.ing/DevFW-CICD/garm-provider-edge-connect/internal/client"
|
|
||||||
"edp.buildth.ing/DevFW-CICD/garm-provider-edge-connect/provider"
|
"edp.buildth.ing/DevFW-CICD/garm-provider-edge-connect/provider"
|
||||||
"github.com/cloudbase/garm-provider-common/params"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var testManifest = `
|
var testManifest = `
|
||||||
|
|
@ -55,14 +51,14 @@ spec:
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
e := client.EdgeConnect{
|
/*e := client.EdgeConnect{
|
||||||
BaseURL: "https://hub.apps.edge.platform.mg3.mdb.osc.live",
|
BaseURL: "https://hub.apps.edge.platform.mg3.mdb.osc.live",
|
||||||
HttpClient: &http.Client{},
|
HttpClient: &http.Client{},
|
||||||
Credentials: client.Credentials{
|
Credentials: client.Credentials{
|
||||||
Username: os.Getenv("EDGEXR_USERNAME"),
|
Username: os.Getenv("EDGEXR_USERNAME"),
|
||||||
Password: os.Getenv("EDGEXR_PASSWORD"),
|
Password: os.Getenv("EDGEXR_PASSWORD"),
|
||||||
},
|
},
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/*e.DeleteAppInstance(ctx, client.AppInstanceKey{
|
/*e.DeleteAppInstance(ctx, client.AppInstanceKey{
|
||||||
Organization: "edp-developer-framework",
|
Organization: "edp-developer-framework",
|
||||||
|
|
@ -134,7 +130,7 @@ func main() {
|
||||||
|
|
||||||
fmt.Printf("Error: %v\n", err)*/
|
fmt.Printf("Error: %v\n", err)*/
|
||||||
|
|
||||||
appinst, err := e.ShowAppInstance(ctx, client.AppInstanceKey{
|
/*appinst, err := e.ShowAppInstance(ctx, client.AppInstanceKey{
|
||||||
Organization: "edp-developer-framework",
|
Organization: "edp-developer-framework",
|
||||||
Name: "mganterInstanceTest",
|
Name: "mganterInstanceTest",
|
||||||
CloudletKey: client.CloudletKey{
|
CloudletKey: client.CloudletKey{
|
||||||
|
|
@ -145,15 +141,17 @@ func main() {
|
||||||
"EU")
|
"EU")
|
||||||
|
|
||||||
fmt.Printf("appinst: %v\n", appinst)
|
fmt.Printf("appinst: %v\n", appinst)
|
||||||
fmt.Printf("Error: %v\n", err)
|
fmt.Printf("Error: %v\n", err)*/
|
||||||
|
|
||||||
edgeprovider, err := provider.NewEdgeConnectProvider("/home/chris/ipcei/projects/garm-provider-edge-connect/config/config.toml", "lalacontroller")
|
edgeprovider, err := provider.NewEdgeConnectProvider("/home/chris/ipcei/projects/garm-provider-edge-connect/config/config.toml", "lalacontroller")
|
||||||
//providerinst, err := edgeprovider.GetInstance(ctx, appinst.Key.Name)
|
//providerinst, err := edgeprovider.GetInstance(ctx, appinst.Key.Name)
|
||||||
providerinst, err := edgeprovider.CreateInstance(ctx, params.BootstrapInstance{
|
/*providerinst, err := edgeprovider.CreateInstance(ctx, params.BootstrapInstance{
|
||||||
Name: "bootstrapparams",
|
Name: "bootstrapparams",
|
||||||
})
|
})*/
|
||||||
|
|
||||||
fmt.Printf("provider: %v\n", providerinst)
|
err = edgeprovider.DeleteInstance(ctx, "Bootstrapparams")
|
||||||
|
|
||||||
|
//fmt.Printf("provider: %v\n", providerinst)
|
||||||
fmt.Printf("Error: %v\n", err)
|
fmt.Printf("Error: %v\n", err)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -186,6 +186,32 @@ func (a *edgeConnectProvider) CreateInstance(ctx context.Context, bootstrapParam
|
||||||
|
|
||||||
// Delete instance will delete the instance in a provider.
|
// Delete instance will delete the instance in a provider.
|
||||||
func (a *edgeConnectProvider) DeleteInstance(ctx context.Context, instance string) error {
|
func (a *edgeConnectProvider) DeleteInstance(ctx context.Context, instance string) error {
|
||||||
|
|
||||||
|
appinstkey := client.AppInstanceKey{
|
||||||
|
Organization: a.cfg.Organization,
|
||||||
|
Name: instance,
|
||||||
|
CloudletKey: client.CloudletKey{
|
||||||
|
Organization: a.cfg.CloudletKey.Organization,
|
||||||
|
Name: a.cfg.CloudletKey.Name,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
err := a.client.DeleteAppInstance(ctx, appinstkey, a.cfg.Region)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
appkey := client.AppKey{
|
||||||
|
Organization: a.cfg.Organization,
|
||||||
|
Name: instance,
|
||||||
|
Version: "0.0.1",
|
||||||
|
}
|
||||||
|
|
||||||
|
err = a.client.DeleteApp(ctx, appkey, a.cfg.Region)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue