197 lines
4.6 KiB
Go
197 lines
4.6 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"edp.buildth.ing/DevFW-CICD/garm-provider-edge-connect/provider"
|
|
)
|
|
|
|
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",
|
|
},
|
|
},
|
|
"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)*/
|
|
|
|
/*appinst, err := e.ShowAppInstance(ctx, client.AppInstanceKey{
|
|
Organization: "edp-developer-framework",
|
|
Name: "mganterInstanceTest",
|
|
CloudletKey: client.CloudletKey{
|
|
Organization: "TelekomOP",
|
|
Name: "Munich",
|
|
},
|
|
},
|
|
"EU")
|
|
|
|
fmt.Printf("appinst: %v\n", appinst)
|
|
fmt.Printf("Error: %v\n", err)*/
|
|
|
|
edgeprovider, _, _ := provider.NewEdgeConnectProvider("/home/chris/ipcei/projects/garm-provider-edge-connect/config/config.toml", "lalacontroller")
|
|
//providerinst, err := edgeprovider.GetInstance(ctx, appinst.Key.Name)
|
|
|
|
/*_, err := edgeprovider.CreateInstance(ctx, params.BootstrapInstance{
|
|
Name: "bootstrapparams-1",
|
|
PoolID: "123456",
|
|
})
|
|
|
|
_, err = edgeprovider.CreateInstance(ctx, params.BootstrapInstance{
|
|
Name: "bootstrapparams-2",
|
|
PoolID: "123456",
|
|
})*/
|
|
|
|
err := edgeprovider.RemoveAllInstances(ctx)
|
|
//lists, err := edgeprovider.ListInstances(ctx, "123456")
|
|
/*result, _ := e.ShowApps(ctx, client.AppKey{
|
|
Organization: "edp-developer-framework",
|
|
}, "EU")*/
|
|
|
|
//fmt.Printf("Lists: %v", lists)
|
|
fmt.Printf("Error: %v", err)
|
|
//ShowApps
|
|
|
|
//fmt.Printf("provider: %v\n", providerinst)
|
|
//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)*/
|
|
}
|