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 {
|
||||
return err
|
||||
}
|
||||
|
||||
request.Header.Set("Content-Type", "application/json")
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("Response: %v\n", string(bodyBytes))
|
||||
fmt.Printf("Response: %v%v\n", resp.StatusCode, string(bodyBytes))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
20
lala/lala.go
20
lala/lala.go
|
|
@ -3,12 +3,8 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"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"
|
||||
"github.com/cloudbase/garm-provider-common/params"
|
||||
)
|
||||
|
||||
var testManifest = `
|
||||
|
|
@ -55,14 +51,14 @@ spec:
|
|||
|
||||
func main() {
|
||||
ctx := context.TODO()
|
||||
e := client.EdgeConnect{
|
||||
/*e := client.EdgeConnect{
|
||||
BaseURL: "https://hub.apps.edge.platform.mg3.mdb.osc.live",
|
||||
HttpClient: &http.Client{},
|
||||
Credentials: client.Credentials{
|
||||
Username: os.Getenv("EDGEXR_USERNAME"),
|
||||
Password: os.Getenv("EDGEXR_PASSWORD"),
|
||||
},
|
||||
}
|
||||
}*/
|
||||
|
||||
/*e.DeleteAppInstance(ctx, client.AppInstanceKey{
|
||||
Organization: "edp-developer-framework",
|
||||
|
|
@ -134,7 +130,7 @@ func main() {
|
|||
|
||||
fmt.Printf("Error: %v\n", err)*/
|
||||
|
||||
appinst, err := e.ShowAppInstance(ctx, client.AppInstanceKey{
|
||||
/*appinst, err := e.ShowAppInstance(ctx, client.AppInstanceKey{
|
||||
Organization: "edp-developer-framework",
|
||||
Name: "mganterInstanceTest",
|
||||
CloudletKey: client.CloudletKey{
|
||||
|
|
@ -145,15 +141,17 @@ func main() {
|
|||
"EU")
|
||||
|
||||
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")
|
||||
//providerinst, err := edgeprovider.GetInstance(ctx, appinst.Key.Name)
|
||||
providerinst, err := edgeprovider.CreateInstance(ctx, params.BootstrapInstance{
|
||||
/*providerinst, err := edgeprovider.CreateInstance(ctx, params.BootstrapInstance{
|
||||
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)
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -186,6 +186,32 @@ func (a *edgeConnectProvider) CreateInstance(ctx context.Context, bootstrapParam
|
|||
|
||||
// Delete instance will delete the instance in a provider.
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue