164 lines
3.6 KiB
Go
164 lines
3.6 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/http"
|
|
"os"
|
|
|
|
"edp.buildth.ing/DevFW-CICD/garm-provider-edge-connect/internal/client"
|
|
)
|
|
|
|
var testManifest = `
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: mganter-test-tcp
|
|
labels:
|
|
run: mganter-test
|
|
spec:
|
|
type: LoadBalancer
|
|
ports:
|
|
- name: tcp80
|
|
protocol: TCP
|
|
port: 80
|
|
targetPort: 80
|
|
selector:
|
|
run: mganter-test
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: mganter-test-deployment
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
run: mganter-test
|
|
template:
|
|
metadata:
|
|
labels:
|
|
run: mganter-test
|
|
mexDeployGen: kubernetes-basic
|
|
spec:
|
|
volumes:
|
|
containers:
|
|
- name: mganter-test
|
|
image: edp.buildth.ing/devfw-cicd/nginx
|
|
imagePullPolicy: Always
|
|
ports:
|
|
- containerPort: 80
|
|
protocol: TCP
|
|
`
|
|
|
|
func main() {
|
|
ctx := context.TODO()
|
|
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",
|
|
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",
|
|
Version: "0.0.1",
|
|
}, "EU")
|
|
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)
|
|
fmt.Printf("Error: %v\n", err)
|
|
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: "nginx",
|
|
AllowServerless: true,
|
|
ServerlessConfig: struct{}{},
|
|
DefaultFlavor: client.Flavor{
|
|
Name: "EU.small",
|
|
},
|
|
DeploymentGenerator: "kubernetes-basic",
|
|
DeploymentManifest: testManifest,
|
|
},
|
|
})
|
|
fmt.Printf("Error: %v\n", err)*/
|
|
}
|