tested app

This commit is contained in:
Manuel Ganter 2025-11-11 17:05:34 +01:00
parent 6c7a34d68a
commit f41b35cb33
No known key found for this signature in database
4 changed files with 45 additions and 15 deletions

View file

@ -5,7 +5,7 @@ metadata:
labels:
app: nginx
spec:
replicas: 3
replicas: 1
selector:
matchLabels:
app: nginx
@ -16,7 +16,7 @@ spec:
spec:
containers:
- name: nginx
image: nginx:latest
image: docker.io/library/nginx:latest
ports:
- containerPort: 80
---

View file

@ -12,15 +12,15 @@ provider "edge-connect" {
resource "edge-connect_app" "edge_app_demo" {
name = "edge-app-demo"
app_version = "1"
organization = "edp2-orca"
app_version = "1.0.0"
organization = "edp2"
manifest = file("${path.module}/k8s-deployment.yaml")
region = "US"
cloudlet_org = "TelekomOp"
cloudlet_name = "gardener-shepherd-test"
flavor_name = "default"
region = "EU"
cloudlet_org = "TelekomOP"
cloudlet_name = "Munich"
flavor_name = "EU.small"
network {
outbound_connections {

View file

@ -2,6 +2,7 @@ package provider
import (
"context"
"encoding/json"
"fmt"
"github.com/hashicorp/terraform-plugin-framework/path"
@ -98,14 +99,14 @@ func (r *AppResource) Schema(ctx context.Context, req resource.SchemaRequest, re
MarkdownDescription: "Flavor name",
Required: true,
},
"network": schema.SingleNestedAttribute{
},
Blocks: map[string]schema.Block{
"network": schema.SingleNestedBlock{
MarkdownDescription: "Network configuration",
Optional: true,
Attributes: map[string]schema.Attribute{
"outbound_connections": schema.ListNestedAttribute{
Blocks: map[string]schema.Block{
"outbound_connections": schema.ListNestedBlock{
MarkdownDescription: "Outbound connection rules",
Optional: true,
NestedObject: schema.NestedAttributeObject{
NestedObject: schema.NestedBlockObject{
Attributes: map[string]schema.Attribute{
"protocol": schema.StringAttribute{
MarkdownDescription: "Protocol (tcp, udp, icmp)",
@ -181,13 +182,22 @@ func (r *AppResource) Create(ctx context.Context, req resource.CreateRequest, re
Name: data.Name.ValueString(),
Version: data.AppVersion.ValueString(),
},
DefaultFlavor: edgeclient.Flavor{
Name: data.FlavorName.ValueString(),
},
AllowServerless: false,
Deployment: "kubernetes",
ImageType: "docker",
ServerlessConfig: struct{}{},
ImageType: "Docker",
ImagePath: "docker.io/library/nginx:latest",
DeploymentManifest: data.Manifest.ValueString(),
RequiredOutboundConnections: outboundConnections,
},
}
appInputJson, _ := json.Marshal(appInput)
tflog.Info(ctx, fmt.Sprintf("appInput: %v\n", string(appInputJson)), map[string]interface{}{})
err := r.client.CreateApp(ctx, appInput)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to create app, got error: %s", err))

View file

@ -2,6 +2,8 @@ package provider
import (
"context"
"fmt"
"io"
"net/http"
"os"
"time"
@ -148,15 +150,25 @@ func (p *EdgeConnectProvider) Configure(ctx context.Context, req provider.Config
tflog.Debug(ctx, "Creating Edge Connect client with username/password authentication")
}
// open output file
f, err := os.Create("./output.txt")
if err != nil {
panic(err)
}
// close fo on exit and check for its returned error
defer f.Close()
var client *edgeclient.Client
if token != "" {
client = edgeclient.NewClient(endpoint,
edgeclient.WithHTTPClient(&http.Client{Timeout: 30*time.Second}),
edgeclient.WithAuthProvider(edgeclient.NewStaticTokenProvider(token)),
edgeclient.WithLogger(fmtLogger{f}),
)
} else {
client = edgeclient.NewClientWithCredentials(endpoint, username, password,
edgeclient.WithHTTPClient(&http.Client{Timeout: 30*time.Second}),
edgeclient.WithLogger(fmtLogger{f}),
)
}
// TODO: Configure client with authentication credentials
@ -190,3 +202,11 @@ func New(version string) func() provider.Provider {
}
}
}
type fmtLogger struct {
out io.Writer
}
func (logger fmtLogger) Printf(format string, v ...interface{}){
fmt.Fprintf(logger.out, format, v...)
}