feat(client): implemented client calls for app instance creation/deletion
Some checks failed
Go Tests / go-tests (push) Failing after 1m18s
Some checks failed
Go Tests / go-tests (push) Failing after 1m18s
This commit is contained in:
parent
58c9b9fb7e
commit
f1f644648f
2 changed files with 162 additions and 2 deletions
|
|
@ -173,3 +173,97 @@ func (e *EdgeConnect) RetrieveToken(ctx context.Context) (string, error) {
|
|||
|
||||
return respData.Token, nil
|
||||
}
|
||||
|
||||
func (e *EdgeConnect) DeleteApp(ctx context.Context, appkey AppKey, region string) error {
|
||||
token, err := e.RetrieveToken(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
input := struct {
|
||||
App struct {
|
||||
Key AppKey `json:"key"`
|
||||
} `json:"App"`
|
||||
Region string `json:"Region"`
|
||||
}{
|
||||
App: struct {
|
||||
Key AppKey `json:"key"`
|
||||
}{
|
||||
Key: appkey,
|
||||
},
|
||||
Region: region,
|
||||
}
|
||||
|
||||
json_data, err := json.Marshal(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
request, err := http.NewRequestWithContext(ctx, "POST", e.BaseURL+"/api/v1/auth/ctrl/DeleteApp", bytes.NewBuffer(json_data))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
request.Header.Set("Content-Type", "application/json")
|
||||
request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
|
||||
|
||||
resp, err := e.HttpClient.Do(request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("Response: %v\n", string(bodyBytes))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *EdgeConnect) DeleteAppInstance(ctx context.Context, appinstancekey AppInstanceKey, appkey AppKey, region string) error {
|
||||
token, err := e.RetrieveToken(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
input := struct {
|
||||
App struct {
|
||||
AppInstKey AppInstanceKey `json:"key"`
|
||||
} `json:"appinst"`
|
||||
Region string `json:"Region"`
|
||||
}{
|
||||
App: struct {
|
||||
AppInstKey AppInstanceKey `json:"key"`
|
||||
}{
|
||||
AppInstKey: appinstancekey,
|
||||
},
|
||||
Region: region,
|
||||
}
|
||||
|
||||
json_data, err := json.Marshal(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
request, err := http.NewRequestWithContext(ctx, "POST", e.BaseURL+"/api/v1/auth/ctrl/DeleteAppInst", bytes.NewBuffer(json_data))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
request.Header.Set("Content-Type", "application/json")
|
||||
request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
|
||||
|
||||
resp, err := e.HttpClient.Do(request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("Response: %v\n", string(bodyBytes))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
70
lala/lala.go
70
lala/lala.go
|
|
@ -44,7 +44,7 @@ spec:
|
|||
volumes:
|
||||
containers:
|
||||
- name: mganter-test
|
||||
image:
|
||||
image: edp.buildth.ing/devfw-cicd/nginx
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 80
|
||||
|
|
@ -62,6 +62,48 @@ func main() {
|
|||
},
|
||||
}
|
||||
|
||||
e.DeleteAppInstance(ctx, client.AppInstanceKey{
|
||||
Organization: "edp-developer-framework",
|
||||
Name: "mganterInstanceTest",
|
||||
CloudletKey: client.CloudletKey{
|
||||
Organization: "TelekomOP",
|
||||
Name: "Munich",
|
||||
},
|
||||
},
|
||||
client.AppKey{
|
||||
Organization: "edp-developer-framework",
|
||||
Name: "mganter-test",
|
||||
Version: "0.0.1",
|
||||
}, "EU")
|
||||
|
||||
e.DeleteApp(ctx, client.AppKey{
|
||||
Organization: "edp-developer-framework",
|
||||
Name: "mganter-test",
|
||||
Version: "0.0.1",
|
||||
}, "EU")
|
||||
|
||||
err := e.NewApp(ctx, client.NewAppInput{
|
||||
Region: "EU",
|
||||
App: client.App{
|
||||
Key: client.AppKey{
|
||||
Organization: "edp-developer-framework",
|
||||
Name: "mganter-test",
|
||||
Version: "0.0.1",
|
||||
},
|
||||
Deployment: "kubernetes",
|
||||
ImageType: "Docker",
|
||||
ImagePath: "edp.buildth.ing/devfw-cicd/nginx",
|
||||
AllowServerless: true,
|
||||
ServerlessConfig: struct{}{},
|
||||
DefaultFlavor: client.Flavor{
|
||||
Name: "EU.small",
|
||||
},
|
||||
DeploymentGenerator: "kubernetes-basic",
|
||||
DeploymentManifest: testManifest,
|
||||
},
|
||||
})
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
|
||||
app, err := e.ShowApp(ctx, client.AppKey{
|
||||
Organization: "edp-developer-framework",
|
||||
Name: "mganter-test",
|
||||
|
|
@ -70,6 +112,30 @@ func main() {
|
|||
fmt.Printf("Error: %v\n", err)
|
||||
fmt.Printf("App: %v\n", app)
|
||||
|
||||
err = e.NewAppInstance(ctx, client.NewAppInstanceInput{
|
||||
Region: "EU",
|
||||
AppInst: client.AppInstance{
|
||||
Key: client.AppInstanceKey{
|
||||
Organization: "edp-developer-framework",
|
||||
Name: "mganterInstanceTest",
|
||||
CloudletKey: client.CloudletKey{
|
||||
Organization: "TelekomOP",
|
||||
Name: "Munich",
|
||||
},
|
||||
},
|
||||
AppKey: client.AppKey{
|
||||
Organization: "edp-developer-framework",
|
||||
Name: "mganter-test",
|
||||
Version: "0.0.1",
|
||||
},
|
||||
Flavor: client.Flavor{
|
||||
Name: "EU.small",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
|
||||
/*
|
||||
token, err := e.RetrieveToken(ctx)
|
||||
fmt.Printf("Token: %v\n", token)
|
||||
|
|
@ -84,7 +150,7 @@ func main() {
|
|||
},
|
||||
Deployment: "kubernetes",
|
||||
ImageType: "Docker",
|
||||
ImagePath: "",
|
||||
ImagePath: "nginx",
|
||||
AllowServerless: true,
|
||||
ServerlessConfig: struct{}{},
|
||||
DefaultFlavor: client.Flavor{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue