feat(sdk): The deploy app example is now working

This commit is contained in:
Waldemar 2025-09-25 16:23:35 +02:00
parent 1bd9105b07
commit 14123cec3d
4 changed files with 17 additions and 13 deletions

View file

@ -47,7 +47,7 @@ func (c *Client) ShowApp(ctx context.Context, appKey AppKey, region string) (App
url := c.BaseURL + "/api/v1/auth/ctrl/ShowApp"
filter := AppFilter{
AppKey: appKey,
App: App{Key: appKey},
Region: region,
}
@ -87,7 +87,7 @@ func (c *Client) ShowApps(ctx context.Context, appKey AppKey, region string) ([]
url := c.BaseURL + "/api/v1/auth/ctrl/ShowApp"
filter := AppFilter{
AppKey: appKey,
App: App{Key: appKey},
Region: region,
}
@ -121,7 +121,7 @@ func (c *Client) DeleteApp(ctx context.Context, appKey AppKey, region string) er
url := c.BaseURL + "/api/v1/auth/ctrl/DeleteApp"
filter := AppFilter{
AppKey: appKey,
App: App{Key: appKey},
Region: region,
}

View file

@ -196,7 +196,7 @@ func (e *APIError) Error() string {
// AppFilter represents filters for app queries
type AppFilter struct {
AppKey AppKey `json:"app"`
App App `json:"app"`
Region string `json:"region"`
}

View file

@ -9,6 +9,7 @@ import (
"log"
"net/http"
"os"
"strings"
"time"
"edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/client"
@ -55,10 +56,12 @@ func main() {
Name: "my-edge-app",
Version: "1.0.0",
},
Deployment: "docker",
ImageType: "ImageTypeDocker",
ImagePath: "nginx:latest",
DefaultFlavor: client.Flavor{Name: "EU.small"},
Deployment: "docker",
ImageType: "ImageTypeDocker",
ImagePath: "https://registry-1.docker.io/library/nginx:latest",
DefaultFlavor: client.Flavor{Name: "EU.small"},
ServerlessConfig: struct{}{},
AllowServerless: false,
},
}
@ -113,7 +116,7 @@ func demonstrateAppLifecycle(ctx context.Context, edgeClient *client.Client, inp
fmt.Println("\n5. Verifying deletion...")
_, err = edgeClient.ShowApp(ctx, appKey, region)
if err != nil {
if fmt.Sprintf("%v", err) == client.ErrResourceNotFound.Error() {
if strings.Contains(fmt.Sprintf("%v", err), client.ErrResourceNotFound.Error()) {
fmt.Printf("✅ App successfully deleted (not found)\n")
} else {
return fmt.Errorf("unexpected error verifying deletion: %w", err)

View file

@ -37,9 +37,9 @@ type Logger interface {
// RetryOptions configures retry behavior
type RetryOptions struct {
MaxRetries int
InitialDelay time.Duration
MaxDelay time.Duration
Multiplier float64
InitialDelay time.Duration
MaxDelay time.Duration
Multiplier float64
RetryableHTTPStatusCodes []int
}
@ -128,6 +128,7 @@ func (t *Transport) Call(ctx context.Context, method, url string, body interface
// Log request
if t.logger != nil {
t.logger.Printf("HTTP %s %s", method, url)
t.logger.Printf("BODY %s", reqBody)
}
// Execute request
@ -215,4 +216,4 @@ func ParseJSONLines(body io.Reader, callback func([]byte) error) error {
}
return nil
}
}