Renamed package and removed unused make calls
This commit is contained in:
parent
7c5db7fa39
commit
55e9f86759
16 changed files with 91 additions and 103 deletions
|
|
@ -1,7 +1,7 @@
|
|||
// ABOUTME: Application instance lifecycle management APIs for EdgeXR Master Controller
|
||||
// ABOUTME: Provides typed methods for creating, querying, and deleting application instances
|
||||
|
||||
package client
|
||||
package edgeconnect
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// ABOUTME: Unit tests for AppInstance management APIs using httptest mock server
|
||||
// ABOUTME: Tests create, show, list, refresh, and delete operations with error conditions
|
||||
|
||||
package client
|
||||
package edgeconnect
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// ABOUTME: Application lifecycle management APIs for EdgeXR Master Controller
|
||||
// ABOUTME: Provides typed methods for creating, querying, and deleting applications
|
||||
|
||||
package client
|
||||
package edgeconnect
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// ABOUTME: Unit tests for App management APIs using httptest mock server
|
||||
// ABOUTME: Tests create, show, list, and delete operations with error conditions
|
||||
|
||||
package client
|
||||
package edgeconnect
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// ABOUTME: Authentication providers for EdgeXR Master Controller API
|
||||
// ABOUTME: Supports Bearer token authentication with pluggable provider interface
|
||||
|
||||
package client
|
||||
package edgeconnect
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
|
@ -181,4 +181,4 @@ func NewNoAuthProvider() *NoAuthProvider {
|
|||
// Attach does nothing (no authentication)
|
||||
func (n *NoAuthProvider) Attach(ctx context.Context, req *http.Request) error {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// ABOUTME: Unit tests for authentication providers including username/password token flow
|
||||
// ABOUTME: Tests token caching, login flow, and error conditions with mock servers
|
||||
|
||||
package client
|
||||
package edgeconnect
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -223,4 +223,4 @@ func TestNewClientWithCredentials(t *testing.T) {
|
|||
assert.Equal(t, "testuser", authProvider.Username)
|
||||
assert.Equal(t, "testpass", authProvider.Password)
|
||||
assert.Equal(t, "https://example.com", authProvider.BaseURL)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// ABOUTME: Core EdgeXR Master Controller SDK client with HTTP transport and auth
|
||||
// ABOUTME: Provides typed APIs for app, instance, and cloudlet management operations
|
||||
|
||||
package client
|
||||
package edgeconnect
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
|
@ -20,10 +20,10 @@ type Client struct {
|
|||
|
||||
// RetryOptions configures retry behavior for API calls
|
||||
type RetryOptions struct {
|
||||
MaxRetries int
|
||||
InitialDelay time.Duration
|
||||
MaxDelay time.Duration
|
||||
Multiplier float64
|
||||
MaxRetries int
|
||||
InitialDelay time.Duration
|
||||
MaxDelay time.Duration
|
||||
Multiplier float64
|
||||
RetryableHTTPStatusCodes []int
|
||||
}
|
||||
|
||||
|
|
@ -119,4 +119,4 @@ func (c *Client) logf(format string, v ...interface{}) {
|
|||
if c.Logger != nil {
|
||||
c.Logger.Printf(format, v...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// ABOUTME: Cloudlet management APIs for EdgeXR Master Controller
|
||||
// ABOUTME: Provides typed methods for creating, querying, and managing edge cloudlets
|
||||
|
||||
package client
|
||||
package edgeconnect
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// ABOUTME: Unit tests for Cloudlet management APIs using httptest mock server
|
||||
// ABOUTME: Tests create, show, list, delete, manifest, and resource usage operations
|
||||
|
||||
package client
|
||||
package edgeconnect
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// ABOUTME: Core type definitions for EdgeXR Master Controller SDK
|
||||
// ABOUTME: These types are based on the swagger API specification and existing client patterns
|
||||
|
||||
package client
|
||||
package edgeconnect
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
|
@ -12,7 +12,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/client"
|
||||
"edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/edgeconnect"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -24,20 +24,20 @@ func main() {
|
|||
username := getEnvOrDefault("EDGEXR_USERNAME", "")
|
||||
password := getEnvOrDefault("EDGEXR_PASSWORD", "")
|
||||
|
||||
var edgeClient *client.Client
|
||||
var client *edgeconnect.Client
|
||||
|
||||
if token != "" {
|
||||
fmt.Println("🔐 Using Bearer token authentication")
|
||||
edgeClient = client.NewClient(baseURL,
|
||||
client.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
||||
client.WithAuthProvider(client.NewStaticTokenProvider(token)),
|
||||
client.WithLogger(log.Default()),
|
||||
client = edgeconnect.NewClient(baseURL,
|
||||
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
||||
edgeconnect.WithAuthProvider(edgeconnect.NewStaticTokenProvider(token)),
|
||||
edgeconnect.WithLogger(log.Default()),
|
||||
)
|
||||
} else if username != "" && password != "" {
|
||||
fmt.Println("🔐 Using username/password authentication")
|
||||
edgeClient = client.NewClientWithCredentials(baseURL, username, password,
|
||||
client.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
||||
client.WithLogger(log.Default()),
|
||||
client = edgeconnect.NewClientWithCredentials(baseURL, username, password,
|
||||
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
||||
edgeconnect.WithLogger(log.Default()),
|
||||
)
|
||||
} else {
|
||||
log.Fatal("Authentication required: Set either EDGEXR_TOKEN or both EDGEXR_USERNAME and EDGEXR_PASSWORD")
|
||||
|
|
@ -61,7 +61,7 @@ func main() {
|
|||
fmt.Printf("Organization: %s, Region: %s\n\n", config.Organization, config.Region)
|
||||
|
||||
// Run the complete workflow
|
||||
if err := runComprehensiveWorkflow(ctx, edgeClient, config); err != nil {
|
||||
if err := runComprehensiveWorkflow(ctx, client, config); err != nil {
|
||||
log.Fatalf("Workflow failed: %v", err)
|
||||
}
|
||||
|
||||
|
|
@ -85,15 +85,15 @@ type WorkflowConfig struct {
|
|||
FlavorName string
|
||||
}
|
||||
|
||||
func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config WorkflowConfig) error {
|
||||
func runComprehensiveWorkflow(ctx context.Context, c *edgeconnect.Client, config WorkflowConfig) error {
|
||||
fmt.Println("═══ Phase 1: Application Management ═══")
|
||||
|
||||
// 1. Create Application
|
||||
fmt.Println("\n1️⃣ Creating application...")
|
||||
app := &client.NewAppInput{
|
||||
app := &edgeconnect.NewAppInput{
|
||||
Region: config.Region,
|
||||
App: client.App{
|
||||
Key: client.AppKey{
|
||||
App: edgeconnect.App{
|
||||
Key: edgeconnect.AppKey{
|
||||
Organization: config.Organization,
|
||||
Name: config.AppName,
|
||||
Version: config.AppVersion,
|
||||
|
|
@ -101,10 +101,10 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work
|
|||
Deployment: "kubernetes",
|
||||
ImageType: "ImageTypeDocker",
|
||||
ImagePath: "https://registry-1.docker.io/library/nginx:latest",
|
||||
DefaultFlavor: client.Flavor{Name: config.FlavorName},
|
||||
DefaultFlavor: edgeconnect.Flavor{Name: config.FlavorName},
|
||||
ServerlessConfig: struct{}{},
|
||||
AllowServerless: true,
|
||||
RequiredOutboundConnections: []client.SecurityRule{
|
||||
RequiredOutboundConnections: []edgeconnect.SecurityRule{
|
||||
{
|
||||
Protocol: "tcp",
|
||||
PortRangeMin: 80,
|
||||
|
|
@ -128,7 +128,7 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work
|
|||
|
||||
// 2. Show Application Details
|
||||
fmt.Println("\n2️⃣ Querying application details...")
|
||||
appKey := client.AppKey{
|
||||
appKey := edgeconnect.AppKey{
|
||||
Organization: config.Organization,
|
||||
Name: config.AppName,
|
||||
Version: config.AppVersion,
|
||||
|
|
@ -146,7 +146,7 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work
|
|||
|
||||
// 3. List Applications in Organization
|
||||
fmt.Println("\n3️⃣ Listing applications in organization...")
|
||||
filter := client.AppKey{Organization: config.Organization}
|
||||
filter := edgeconnect.AppKey{Organization: config.Organization}
|
||||
apps, err := c.ShowApps(ctx, filter, config.Region)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to list apps: %w", err)
|
||||
|
|
@ -160,19 +160,19 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work
|
|||
|
||||
// 4. Create Application Instance
|
||||
fmt.Println("\n4️⃣ Creating application instance...")
|
||||
instance := &client.NewAppInstanceInput{
|
||||
instance := &edgeconnect.NewAppInstanceInput{
|
||||
Region: config.Region,
|
||||
AppInst: client.AppInstance{
|
||||
Key: client.AppInstanceKey{
|
||||
AppInst: edgeconnect.AppInstance{
|
||||
Key: edgeconnect.AppInstanceKey{
|
||||
Organization: config.Organization,
|
||||
Name: config.InstanceName,
|
||||
CloudletKey: client.CloudletKey{
|
||||
CloudletKey: edgeconnect.CloudletKey{
|
||||
Organization: config.CloudletOrg,
|
||||
Name: config.CloudletName,
|
||||
},
|
||||
},
|
||||
AppKey: appKey,
|
||||
Flavor: client.Flavor{Name: config.FlavorName},
|
||||
Flavor: edgeconnect.Flavor{Name: config.FlavorName},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -184,10 +184,10 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work
|
|||
|
||||
// 5. Wait for Application Instance to be Ready
|
||||
fmt.Println("\n5️⃣ Waiting for application instance to be ready...")
|
||||
instanceKey := client.AppInstanceKey{
|
||||
instanceKey := edgeconnect.AppInstanceKey{
|
||||
Organization: config.Organization,
|
||||
Name: config.InstanceName,
|
||||
CloudletKey: client.CloudletKey{
|
||||
CloudletKey: edgeconnect.CloudletKey{
|
||||
Organization: config.CloudletOrg,
|
||||
Name: config.CloudletName,
|
||||
},
|
||||
|
|
@ -207,7 +207,7 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work
|
|||
|
||||
// 6. List Application Instances
|
||||
fmt.Println("\n6️⃣ Listing application instances...")
|
||||
instances, err := c.ShowAppInstances(ctx, client.AppInstanceKey{Organization: config.Organization}, config.Region)
|
||||
instances, err := c.ShowAppInstances(ctx, edgeconnect.AppInstanceKey{Organization: config.Organization}, config.Region)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to list app instances: %w", err)
|
||||
}
|
||||
|
|
@ -228,7 +228,7 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work
|
|||
|
||||
// 8. Show Cloudlet Details
|
||||
fmt.Println("\n8️⃣ Querying cloudlet information...")
|
||||
cloudletKey := client.CloudletKey{
|
||||
cloudletKey := edgeconnect.CloudletKey{
|
||||
Organization: config.CloudletOrg,
|
||||
Name: config.CloudletName,
|
||||
}
|
||||
|
|
@ -287,7 +287,7 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work
|
|||
// 13. Verify Cleanup
|
||||
fmt.Println("\n1️⃣3️⃣ Verifying cleanup...")
|
||||
_, err = c.ShowApp(ctx, appKey, config.Region)
|
||||
if err != nil && fmt.Sprintf("%v", err) == client.ErrResourceNotFound.Error() {
|
||||
if err != nil && fmt.Sprintf("%v", err) == edgeconnect.ErrResourceNotFound.Error() {
|
||||
fmt.Printf("✅ Cleanup verified - app no longer exists\n")
|
||||
} else if err != nil {
|
||||
fmt.Printf("✅ Cleanup appears successful (verification returned: %v)\n", err)
|
||||
|
|
@ -306,7 +306,7 @@ func getEnvOrDefault(key, defaultValue string) string {
|
|||
}
|
||||
|
||||
// waitForInstanceReady polls the instance status until it's no longer "Creating" or timeout
|
||||
func waitForInstanceReady(ctx context.Context, c *client.Client, instanceKey client.AppInstanceKey, region string, timeout time.Duration) (client.AppInstance, error) {
|
||||
func waitForInstanceReady(ctx context.Context, c *edgeconnect.Client, instanceKey edgeconnect.AppInstanceKey, region string, timeout time.Duration) (edgeconnect.AppInstance, error) {
|
||||
timeoutCtx, cancel := context.WithTimeout(ctx, timeout)
|
||||
defer cancel()
|
||||
|
||||
|
|
@ -318,7 +318,7 @@ func waitForInstanceReady(ctx context.Context, c *client.Client, instanceKey cli
|
|||
for {
|
||||
select {
|
||||
case <-timeoutCtx.Done():
|
||||
return client.AppInstance{}, fmt.Errorf("timeout waiting for instance to be ready after %v", timeout)
|
||||
return edgeconnect.AppInstance{}, fmt.Errorf("timeout waiting for instance to be ready after %v", timeout)
|
||||
|
||||
case <-ticker.C:
|
||||
instance, err := c.ShowAppInstance(timeoutCtx, instanceKey, region)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/client"
|
||||
"edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/edgeconnect"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -24,22 +24,22 @@ func main() {
|
|||
username := getEnvOrDefault("EDGEXR_USERNAME", "")
|
||||
password := getEnvOrDefault("EDGEXR_PASSWORD", "")
|
||||
|
||||
var edgeClient *client.Client
|
||||
var edgeClient *edgeconnect.Client
|
||||
|
||||
if token != "" {
|
||||
// Use static token authentication
|
||||
fmt.Println("🔐 Using Bearer token authentication")
|
||||
edgeClient = client.NewClient(baseURL,
|
||||
client.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
||||
client.WithAuthProvider(client.NewStaticTokenProvider(token)),
|
||||
client.WithLogger(log.Default()),
|
||||
edgeClient = edgeconnect.NewClient(baseURL,
|
||||
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
||||
edgeconnect.WithAuthProvider(edgeconnect.NewStaticTokenProvider(token)),
|
||||
edgeconnect.WithLogger(log.Default()),
|
||||
)
|
||||
} else if username != "" && password != "" {
|
||||
// Use username/password authentication (matches existing client pattern)
|
||||
fmt.Println("🔐 Using username/password authentication")
|
||||
edgeClient = client.NewClientWithCredentials(baseURL, username, password,
|
||||
client.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
||||
client.WithLogger(log.Default()),
|
||||
edgeClient = edgeconnect.NewClientWithCredentials(baseURL, username, password,
|
||||
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
||||
edgeconnect.WithLogger(log.Default()),
|
||||
)
|
||||
} else {
|
||||
log.Fatal("Authentication required: Set either EDGEXR_TOKEN or both EDGEXR_USERNAME and EDGEXR_PASSWORD")
|
||||
|
|
@ -48,10 +48,10 @@ func main() {
|
|||
ctx := context.Background()
|
||||
|
||||
// Example application to deploy
|
||||
app := &client.NewAppInput{
|
||||
app := &edgeconnect.NewAppInput{
|
||||
Region: "EU",
|
||||
App: client.App{
|
||||
Key: client.AppKey{
|
||||
App: edgeconnect.App{
|
||||
Key: edgeconnect.AppKey{
|
||||
Organization: "edp2",
|
||||
Name: "my-edge-app",
|
||||
Version: "1.0.0",
|
||||
|
|
@ -59,7 +59,7 @@ func main() {
|
|||
Deployment: "docker",
|
||||
ImageType: "ImageTypeDocker",
|
||||
ImagePath: "https://registry-1.docker.io/library/nginx:latest",
|
||||
DefaultFlavor: client.Flavor{Name: "EU.small"},
|
||||
DefaultFlavor: edgeconnect.Flavor{Name: "EU.small"},
|
||||
ServerlessConfig: struct{}{},
|
||||
AllowServerless: false,
|
||||
},
|
||||
|
|
@ -73,7 +73,7 @@ func main() {
|
|||
fmt.Println("✅ SDK example completed successfully!")
|
||||
}
|
||||
|
||||
func demonstrateAppLifecycle(ctx context.Context, edgeClient *client.Client, input *client.NewAppInput) error {
|
||||
func demonstrateAppLifecycle(ctx context.Context, edgeClient *edgeconnect.Client, input *edgeconnect.NewAppInput) error {
|
||||
appKey := input.App.Key
|
||||
region := input.Region
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ func demonstrateAppLifecycle(ctx context.Context, edgeClient *client.Client, inp
|
|||
|
||||
// Step 3: List applications in the organization
|
||||
fmt.Println("\n3. Listing applications...")
|
||||
filter := client.AppKey{Organization: appKey.Organization}
|
||||
filter := edgeconnect.AppKey{Organization: appKey.Organization}
|
||||
apps, err := edgeClient.ShowApps(ctx, filter, region)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to list apps: %w", err)
|
||||
|
|
@ -116,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 strings.Contains(fmt.Sprintf("%v", err), client.ErrResourceNotFound.Error()) {
|
||||
if strings.Contains(fmt.Sprintf("%v", err), edgeconnect.ErrResourceNotFound.Error()) {
|
||||
fmt.Printf("✅ App successfully deleted (not found)\n")
|
||||
} else {
|
||||
return fmt.Errorf("unexpected error verifying deletion: %w", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue