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
10
Makefile
10
Makefile
|
|
@ -1,16 +1,12 @@
|
||||||
# ABOUTME: Build automation and code generation for EdgeXR SDK
|
# ABOUTME: Build automation and code generation for EdgeXR SDK
|
||||||
# ABOUTME: Provides targets for generating types, testing, and building the CLI
|
# ABOUTME: Provides targets for generating types, testing, and building the CLI
|
||||||
|
|
||||||
.PHONY: generate test build clean install-tools
|
.PHONY: test build clean install-tools
|
||||||
|
|
||||||
# Install required tools
|
# Install required tools
|
||||||
install-tools:
|
install-tools:
|
||||||
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest
|
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest
|
||||||
|
|
||||||
# Generate Go types from OpenAPI spec
|
|
||||||
generate:
|
|
||||||
oapi-codegen -config oapi-codegen.yaml api/swagger.json
|
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
test:
|
test:
|
||||||
go test -v ./...
|
go test -v ./...
|
||||||
|
|
@ -35,7 +31,7 @@ lint:
|
||||||
golangci-lint run
|
golangci-lint run
|
||||||
|
|
||||||
# Run all checks (generate, test, lint)
|
# Run all checks (generate, test, lint)
|
||||||
check: generate test lint
|
check: test lint
|
||||||
|
|
||||||
# Default target
|
# Default target
|
||||||
all: check build
|
all: check build
|
||||||
|
|
|
||||||
24
cmd/app.go
24
cmd/app.go
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/client"
|
"edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/edgeconnect"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
@ -19,20 +19,20 @@ var (
|
||||||
region string
|
region string
|
||||||
)
|
)
|
||||||
|
|
||||||
func newSDKClient() *client.Client {
|
func newSDKClient() *edgeconnect.Client {
|
||||||
baseURL := viper.GetString("base_url")
|
baseURL := viper.GetString("base_url")
|
||||||
username := viper.GetString("username")
|
username := viper.GetString("username")
|
||||||
password := viper.GetString("password")
|
password := viper.GetString("password")
|
||||||
|
|
||||||
if username != "" && password != "" {
|
if username != "" && password != "" {
|
||||||
return client.NewClientWithCredentials(baseURL, username, password,
|
return edgeconnect.NewClientWithCredentials(baseURL, username, password,
|
||||||
client.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to no auth for now - in production should require auth
|
// Fallback to no auth for now - in production should require auth
|
||||||
return client.NewClient(baseURL,
|
return edgeconnect.NewClient(baseURL,
|
||||||
client.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,10 +47,10 @@ var createAppCmd = &cobra.Command{
|
||||||
Short: "Create a new Edge Connect application",
|
Short: "Create a new Edge Connect application",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
c := newSDKClient()
|
c := newSDKClient()
|
||||||
input := &client.NewAppInput{
|
input := &edgeconnect.NewAppInput{
|
||||||
Region: region,
|
Region: region,
|
||||||
App: client.App{
|
App: edgeconnect.App{
|
||||||
Key: client.AppKey{
|
Key: edgeconnect.AppKey{
|
||||||
Organization: organization,
|
Organization: organization,
|
||||||
Name: appName,
|
Name: appName,
|
||||||
Version: appVersion,
|
Version: appVersion,
|
||||||
|
|
@ -72,7 +72,7 @@ var showAppCmd = &cobra.Command{
|
||||||
Short: "Show details of an Edge Connect application",
|
Short: "Show details of an Edge Connect application",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
c := newSDKClient()
|
c := newSDKClient()
|
||||||
appKey := client.AppKey{
|
appKey := edgeconnect.AppKey{
|
||||||
Organization: organization,
|
Organization: organization,
|
||||||
Name: appName,
|
Name: appName,
|
||||||
Version: appVersion,
|
Version: appVersion,
|
||||||
|
|
@ -92,7 +92,7 @@ var listAppsCmd = &cobra.Command{
|
||||||
Short: "List Edge Connect applications",
|
Short: "List Edge Connect applications",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
c := newSDKClient()
|
c := newSDKClient()
|
||||||
appKey := client.AppKey{
|
appKey := edgeconnect.AppKey{
|
||||||
Organization: organization,
|
Organization: organization,
|
||||||
Name: appName,
|
Name: appName,
|
||||||
Version: appVersion,
|
Version: appVersion,
|
||||||
|
|
@ -115,7 +115,7 @@ var deleteAppCmd = &cobra.Command{
|
||||||
Short: "Delete an Edge Connect application",
|
Short: "Delete an Edge Connect application",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
c := newSDKClient()
|
c := newSDKClient()
|
||||||
appKey := client.AppKey{
|
appKey := edgeconnect.AppKey{
|
||||||
Organization: organization,
|
Organization: organization,
|
||||||
Name: appName,
|
Name: appName,
|
||||||
Version: appVersion,
|
Version: appVersion,
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/client"
|
"edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/edgeconnect"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -27,23 +27,23 @@ var createInstanceCmd = &cobra.Command{
|
||||||
Short: "Create a new Edge Connect application instance",
|
Short: "Create a new Edge Connect application instance",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
c := newSDKClient()
|
c := newSDKClient()
|
||||||
input := &client.NewAppInstanceInput{
|
input := &edgeconnect.NewAppInstanceInput{
|
||||||
Region: region,
|
Region: region,
|
||||||
AppInst: client.AppInstance{
|
AppInst: edgeconnect.AppInstance{
|
||||||
Key: client.AppInstanceKey{
|
Key: edgeconnect.AppInstanceKey{
|
||||||
Organization: organization,
|
Organization: organization,
|
||||||
Name: instanceName,
|
Name: instanceName,
|
||||||
CloudletKey: client.CloudletKey{
|
CloudletKey: edgeconnect.CloudletKey{
|
||||||
Organization: cloudletOrg,
|
Organization: cloudletOrg,
|
||||||
Name: cloudletName,
|
Name: cloudletName,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
AppKey: client.AppKey{
|
AppKey: edgeconnect.AppKey{
|
||||||
Organization: organization,
|
Organization: organization,
|
||||||
Name: appName,
|
Name: appName,
|
||||||
Version: appVersion,
|
Version: appVersion,
|
||||||
},
|
},
|
||||||
Flavor: client.Flavor{
|
Flavor: edgeconnect.Flavor{
|
||||||
Name: flavorName,
|
Name: flavorName,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -63,10 +63,10 @@ var showInstanceCmd = &cobra.Command{
|
||||||
Short: "Show details of an Edge Connect application instance",
|
Short: "Show details of an Edge Connect application instance",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
c := newSDKClient()
|
c := newSDKClient()
|
||||||
instanceKey := client.AppInstanceKey{
|
instanceKey := edgeconnect.AppInstanceKey{
|
||||||
Organization: organization,
|
Organization: organization,
|
||||||
Name: instanceName,
|
Name: instanceName,
|
||||||
CloudletKey: client.CloudletKey{
|
CloudletKey: edgeconnect.CloudletKey{
|
||||||
Organization: cloudletOrg,
|
Organization: cloudletOrg,
|
||||||
Name: cloudletName,
|
Name: cloudletName,
|
||||||
},
|
},
|
||||||
|
|
@ -86,10 +86,10 @@ var listInstancesCmd = &cobra.Command{
|
||||||
Short: "List Edge Connect application instances",
|
Short: "List Edge Connect application instances",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
c := newSDKClient()
|
c := newSDKClient()
|
||||||
instanceKey := client.AppInstanceKey{
|
instanceKey := edgeconnect.AppInstanceKey{
|
||||||
Organization: organization,
|
Organization: organization,
|
||||||
Name: instanceName,
|
Name: instanceName,
|
||||||
CloudletKey: client.CloudletKey{
|
CloudletKey: edgeconnect.CloudletKey{
|
||||||
Organization: cloudletOrg,
|
Organization: cloudletOrg,
|
||||||
Name: cloudletName,
|
Name: cloudletName,
|
||||||
},
|
},
|
||||||
|
|
@ -112,10 +112,10 @@ var deleteInstanceCmd = &cobra.Command{
|
||||||
Short: "Delete an Edge Connect application instance",
|
Short: "Delete an Edge Connect application instance",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
c := newSDKClient()
|
c := newSDKClient()
|
||||||
instanceKey := client.AppInstanceKey{
|
instanceKey := edgeconnect.AppInstanceKey{
|
||||||
Organization: organization,
|
Organization: organization,
|
||||||
Name: instanceName,
|
Name: instanceName,
|
||||||
CloudletKey: client.CloudletKey{
|
CloudletKey: edgeconnect.CloudletKey{
|
||||||
Organization: cloudletOrg,
|
Organization: cloudletOrg,
|
||||||
Name: cloudletName,
|
Name: cloudletName,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
package: client
|
|
||||||
output: sdk/client/types_generated.go
|
|
||||||
generate:
|
|
||||||
models: true
|
|
||||||
client: false
|
|
||||||
embedded-spec: false
|
|
||||||
output-options:
|
|
||||||
skip-prune: true
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// ABOUTME: Application instance lifecycle management APIs for EdgeXR Master Controller
|
// ABOUTME: Application instance lifecycle management APIs for EdgeXR Master Controller
|
||||||
// ABOUTME: Provides typed methods for creating, querying, and deleting application instances
|
// ABOUTME: Provides typed methods for creating, querying, and deleting application instances
|
||||||
|
|
||||||
package client
|
package edgeconnect
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// ABOUTME: Unit tests for AppInstance management APIs using httptest mock server
|
// ABOUTME: Unit tests for AppInstance management APIs using httptest mock server
|
||||||
// ABOUTME: Tests create, show, list, refresh, and delete operations with error conditions
|
// ABOUTME: Tests create, show, list, refresh, and delete operations with error conditions
|
||||||
|
|
||||||
package client
|
package edgeconnect
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// ABOUTME: Application lifecycle management APIs for EdgeXR Master Controller
|
// ABOUTME: Application lifecycle management APIs for EdgeXR Master Controller
|
||||||
// ABOUTME: Provides typed methods for creating, querying, and deleting applications
|
// ABOUTME: Provides typed methods for creating, querying, and deleting applications
|
||||||
|
|
||||||
package client
|
package edgeconnect
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// ABOUTME: Unit tests for App management APIs using httptest mock server
|
// ABOUTME: Unit tests for App management APIs using httptest mock server
|
||||||
// ABOUTME: Tests create, show, list, and delete operations with error conditions
|
// ABOUTME: Tests create, show, list, and delete operations with error conditions
|
||||||
|
|
||||||
package client
|
package edgeconnect
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// ABOUTME: Authentication providers for EdgeXR Master Controller API
|
// ABOUTME: Authentication providers for EdgeXR Master Controller API
|
||||||
// ABOUTME: Supports Bearer token authentication with pluggable provider interface
|
// ABOUTME: Supports Bearer token authentication with pluggable provider interface
|
||||||
|
|
||||||
package client
|
package edgeconnect
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
@ -181,4 +181,4 @@ func NewNoAuthProvider() *NoAuthProvider {
|
||||||
// Attach does nothing (no authentication)
|
// Attach does nothing (no authentication)
|
||||||
func (n *NoAuthProvider) Attach(ctx context.Context, req *http.Request) error {
|
func (n *NoAuthProvider) Attach(ctx context.Context, req *http.Request) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// ABOUTME: Unit tests for authentication providers including username/password token flow
|
// ABOUTME: Unit tests for authentication providers including username/password token flow
|
||||||
// ABOUTME: Tests token caching, login flow, and error conditions with mock servers
|
// ABOUTME: Tests token caching, login flow, and error conditions with mock servers
|
||||||
|
|
||||||
package client
|
package edgeconnect
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
@ -223,4 +223,4 @@ func TestNewClientWithCredentials(t *testing.T) {
|
||||||
assert.Equal(t, "testuser", authProvider.Username)
|
assert.Equal(t, "testuser", authProvider.Username)
|
||||||
assert.Equal(t, "testpass", authProvider.Password)
|
assert.Equal(t, "testpass", authProvider.Password)
|
||||||
assert.Equal(t, "https://example.com", authProvider.BaseURL)
|
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: Core EdgeXR Master Controller SDK client with HTTP transport and auth
|
||||||
// ABOUTME: Provides typed APIs for app, instance, and cloudlet management operations
|
// ABOUTME: Provides typed APIs for app, instance, and cloudlet management operations
|
||||||
|
|
||||||
package client
|
package edgeconnect
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -20,10 +20,10 @@ type Client struct {
|
||||||
|
|
||||||
// RetryOptions configures retry behavior for API calls
|
// RetryOptions configures retry behavior for API calls
|
||||||
type RetryOptions struct {
|
type RetryOptions struct {
|
||||||
MaxRetries int
|
MaxRetries int
|
||||||
InitialDelay time.Duration
|
InitialDelay time.Duration
|
||||||
MaxDelay time.Duration
|
MaxDelay time.Duration
|
||||||
Multiplier float64
|
Multiplier float64
|
||||||
RetryableHTTPStatusCodes []int
|
RetryableHTTPStatusCodes []int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,4 +119,4 @@ func (c *Client) logf(format string, v ...interface{}) {
|
||||||
if c.Logger != nil {
|
if c.Logger != nil {
|
||||||
c.Logger.Printf(format, v...)
|
c.Logger.Printf(format, v...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// ABOUTME: Cloudlet management APIs for EdgeXR Master Controller
|
// ABOUTME: Cloudlet management APIs for EdgeXR Master Controller
|
||||||
// ABOUTME: Provides typed methods for creating, querying, and managing edge cloudlets
|
// ABOUTME: Provides typed methods for creating, querying, and managing edge cloudlets
|
||||||
|
|
||||||
package client
|
package edgeconnect
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// ABOUTME: Unit tests for Cloudlet management APIs using httptest mock server
|
// ABOUTME: Unit tests for Cloudlet management APIs using httptest mock server
|
||||||
// ABOUTME: Tests create, show, list, delete, manifest, and resource usage operations
|
// ABOUTME: Tests create, show, list, delete, manifest, and resource usage operations
|
||||||
|
|
||||||
package client
|
package edgeconnect
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// ABOUTME: Core type definitions for EdgeXR Master Controller SDK
|
// ABOUTME: Core type definitions for EdgeXR Master Controller SDK
|
||||||
// ABOUTME: These types are based on the swagger API specification and existing client patterns
|
// ABOUTME: These types are based on the swagger API specification and existing client patterns
|
||||||
|
|
||||||
package client
|
package edgeconnect
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/client"
|
"edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/edgeconnect"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
@ -24,20 +24,20 @@ func main() {
|
||||||
username := getEnvOrDefault("EDGEXR_USERNAME", "")
|
username := getEnvOrDefault("EDGEXR_USERNAME", "")
|
||||||
password := getEnvOrDefault("EDGEXR_PASSWORD", "")
|
password := getEnvOrDefault("EDGEXR_PASSWORD", "")
|
||||||
|
|
||||||
var edgeClient *client.Client
|
var client *edgeconnect.Client
|
||||||
|
|
||||||
if token != "" {
|
if token != "" {
|
||||||
fmt.Println("🔐 Using Bearer token authentication")
|
fmt.Println("🔐 Using Bearer token authentication")
|
||||||
edgeClient = client.NewClient(baseURL,
|
client = edgeconnect.NewClient(baseURL,
|
||||||
client.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
||||||
client.WithAuthProvider(client.NewStaticTokenProvider(token)),
|
edgeconnect.WithAuthProvider(edgeconnect.NewStaticTokenProvider(token)),
|
||||||
client.WithLogger(log.Default()),
|
edgeconnect.WithLogger(log.Default()),
|
||||||
)
|
)
|
||||||
} else if username != "" && password != "" {
|
} else if username != "" && password != "" {
|
||||||
fmt.Println("🔐 Using username/password authentication")
|
fmt.Println("🔐 Using username/password authentication")
|
||||||
edgeClient = client.NewClientWithCredentials(baseURL, username, password,
|
client = edgeconnect.NewClientWithCredentials(baseURL, username, password,
|
||||||
client.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
||||||
client.WithLogger(log.Default()),
|
edgeconnect.WithLogger(log.Default()),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
log.Fatal("Authentication required: Set either EDGEXR_TOKEN or both EDGEXR_USERNAME and EDGEXR_PASSWORD")
|
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)
|
fmt.Printf("Organization: %s, Region: %s\n\n", config.Organization, config.Region)
|
||||||
|
|
||||||
// Run the complete workflow
|
// 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)
|
log.Fatalf("Workflow failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,15 +85,15 @@ type WorkflowConfig struct {
|
||||||
FlavorName string
|
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 ═══")
|
fmt.Println("═══ Phase 1: Application Management ═══")
|
||||||
|
|
||||||
// 1. Create Application
|
// 1. Create Application
|
||||||
fmt.Println("\n1️⃣ Creating application...")
|
fmt.Println("\n1️⃣ Creating application...")
|
||||||
app := &client.NewAppInput{
|
app := &edgeconnect.NewAppInput{
|
||||||
Region: config.Region,
|
Region: config.Region,
|
||||||
App: client.App{
|
App: edgeconnect.App{
|
||||||
Key: client.AppKey{
|
Key: edgeconnect.AppKey{
|
||||||
Organization: config.Organization,
|
Organization: config.Organization,
|
||||||
Name: config.AppName,
|
Name: config.AppName,
|
||||||
Version: config.AppVersion,
|
Version: config.AppVersion,
|
||||||
|
|
@ -101,10 +101,10 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work
|
||||||
Deployment: "kubernetes",
|
Deployment: "kubernetes",
|
||||||
ImageType: "ImageTypeDocker",
|
ImageType: "ImageTypeDocker",
|
||||||
ImagePath: "https://registry-1.docker.io/library/nginx:latest",
|
ImagePath: "https://registry-1.docker.io/library/nginx:latest",
|
||||||
DefaultFlavor: client.Flavor{Name: config.FlavorName},
|
DefaultFlavor: edgeconnect.Flavor{Name: config.FlavorName},
|
||||||
ServerlessConfig: struct{}{},
|
ServerlessConfig: struct{}{},
|
||||||
AllowServerless: true,
|
AllowServerless: true,
|
||||||
RequiredOutboundConnections: []client.SecurityRule{
|
RequiredOutboundConnections: []edgeconnect.SecurityRule{
|
||||||
{
|
{
|
||||||
Protocol: "tcp",
|
Protocol: "tcp",
|
||||||
PortRangeMin: 80,
|
PortRangeMin: 80,
|
||||||
|
|
@ -128,7 +128,7 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work
|
||||||
|
|
||||||
// 2. Show Application Details
|
// 2. Show Application Details
|
||||||
fmt.Println("\n2️⃣ Querying application details...")
|
fmt.Println("\n2️⃣ Querying application details...")
|
||||||
appKey := client.AppKey{
|
appKey := edgeconnect.AppKey{
|
||||||
Organization: config.Organization,
|
Organization: config.Organization,
|
||||||
Name: config.AppName,
|
Name: config.AppName,
|
||||||
Version: config.AppVersion,
|
Version: config.AppVersion,
|
||||||
|
|
@ -146,7 +146,7 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work
|
||||||
|
|
||||||
// 3. List Applications in Organization
|
// 3. List Applications in Organization
|
||||||
fmt.Println("\n3️⃣ Listing 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)
|
apps, err := c.ShowApps(ctx, filter, config.Region)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to list apps: %w", err)
|
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
|
// 4. Create Application Instance
|
||||||
fmt.Println("\n4️⃣ Creating application instance...")
|
fmt.Println("\n4️⃣ Creating application instance...")
|
||||||
instance := &client.NewAppInstanceInput{
|
instance := &edgeconnect.NewAppInstanceInput{
|
||||||
Region: config.Region,
|
Region: config.Region,
|
||||||
AppInst: client.AppInstance{
|
AppInst: edgeconnect.AppInstance{
|
||||||
Key: client.AppInstanceKey{
|
Key: edgeconnect.AppInstanceKey{
|
||||||
Organization: config.Organization,
|
Organization: config.Organization,
|
||||||
Name: config.InstanceName,
|
Name: config.InstanceName,
|
||||||
CloudletKey: client.CloudletKey{
|
CloudletKey: edgeconnect.CloudletKey{
|
||||||
Organization: config.CloudletOrg,
|
Organization: config.CloudletOrg,
|
||||||
Name: config.CloudletName,
|
Name: config.CloudletName,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
AppKey: appKey,
|
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
|
// 5. Wait for Application Instance to be Ready
|
||||||
fmt.Println("\n5️⃣ Waiting 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,
|
Organization: config.Organization,
|
||||||
Name: config.InstanceName,
|
Name: config.InstanceName,
|
||||||
CloudletKey: client.CloudletKey{
|
CloudletKey: edgeconnect.CloudletKey{
|
||||||
Organization: config.CloudletOrg,
|
Organization: config.CloudletOrg,
|
||||||
Name: config.CloudletName,
|
Name: config.CloudletName,
|
||||||
},
|
},
|
||||||
|
|
@ -207,7 +207,7 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work
|
||||||
|
|
||||||
// 6. List Application Instances
|
// 6. List Application Instances
|
||||||
fmt.Println("\n6️⃣ Listing 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 {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to list app instances: %w", err)
|
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
|
// 8. Show Cloudlet Details
|
||||||
fmt.Println("\n8️⃣ Querying cloudlet information...")
|
fmt.Println("\n8️⃣ Querying cloudlet information...")
|
||||||
cloudletKey := client.CloudletKey{
|
cloudletKey := edgeconnect.CloudletKey{
|
||||||
Organization: config.CloudletOrg,
|
Organization: config.CloudletOrg,
|
||||||
Name: config.CloudletName,
|
Name: config.CloudletName,
|
||||||
}
|
}
|
||||||
|
|
@ -287,7 +287,7 @@ func runComprehensiveWorkflow(ctx context.Context, c *client.Client, config Work
|
||||||
// 13. Verify Cleanup
|
// 13. Verify Cleanup
|
||||||
fmt.Println("\n1️⃣3️⃣ Verifying cleanup...")
|
fmt.Println("\n1️⃣3️⃣ Verifying cleanup...")
|
||||||
_, err = c.ShowApp(ctx, appKey, config.Region)
|
_, 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")
|
fmt.Printf("✅ Cleanup verified - app no longer exists\n")
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
fmt.Printf("✅ Cleanup appears successful (verification returned: %v)\n", err)
|
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
|
// 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)
|
timeoutCtx, cancel := context.WithTimeout(ctx, timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
|
@ -318,7 +318,7 @@ func waitForInstanceReady(ctx context.Context, c *client.Client, instanceKey cli
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-timeoutCtx.Done():
|
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:
|
case <-ticker.C:
|
||||||
instance, err := c.ShowAppInstance(timeoutCtx, instanceKey, region)
|
instance, err := c.ShowAppInstance(timeoutCtx, instanceKey, region)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/client"
|
"edp.buildth.ing/DevFW-CICD/edge-connect-client/sdk/edgeconnect"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
@ -24,22 +24,22 @@ func main() {
|
||||||
username := getEnvOrDefault("EDGEXR_USERNAME", "")
|
username := getEnvOrDefault("EDGEXR_USERNAME", "")
|
||||||
password := getEnvOrDefault("EDGEXR_PASSWORD", "")
|
password := getEnvOrDefault("EDGEXR_PASSWORD", "")
|
||||||
|
|
||||||
var edgeClient *client.Client
|
var edgeClient *edgeconnect.Client
|
||||||
|
|
||||||
if token != "" {
|
if token != "" {
|
||||||
// Use static token authentication
|
// Use static token authentication
|
||||||
fmt.Println("🔐 Using Bearer token authentication")
|
fmt.Println("🔐 Using Bearer token authentication")
|
||||||
edgeClient = client.NewClient(baseURL,
|
edgeClient = edgeconnect.NewClient(baseURL,
|
||||||
client.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
||||||
client.WithAuthProvider(client.NewStaticTokenProvider(token)),
|
edgeconnect.WithAuthProvider(edgeconnect.NewStaticTokenProvider(token)),
|
||||||
client.WithLogger(log.Default()),
|
edgeconnect.WithLogger(log.Default()),
|
||||||
)
|
)
|
||||||
} else if username != "" && password != "" {
|
} else if username != "" && password != "" {
|
||||||
// Use username/password authentication (matches existing client pattern)
|
// Use username/password authentication (matches existing client pattern)
|
||||||
fmt.Println("🔐 Using username/password authentication")
|
fmt.Println("🔐 Using username/password authentication")
|
||||||
edgeClient = client.NewClientWithCredentials(baseURL, username, password,
|
edgeClient = edgeconnect.NewClientWithCredentials(baseURL, username, password,
|
||||||
client.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
|
||||||
client.WithLogger(log.Default()),
|
edgeconnect.WithLogger(log.Default()),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
log.Fatal("Authentication required: Set either EDGEXR_TOKEN or both EDGEXR_USERNAME and EDGEXR_PASSWORD")
|
log.Fatal("Authentication required: Set either EDGEXR_TOKEN or both EDGEXR_USERNAME and EDGEXR_PASSWORD")
|
||||||
|
|
@ -48,10 +48,10 @@ func main() {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
// Example application to deploy
|
// Example application to deploy
|
||||||
app := &client.NewAppInput{
|
app := &edgeconnect.NewAppInput{
|
||||||
Region: "EU",
|
Region: "EU",
|
||||||
App: client.App{
|
App: edgeconnect.App{
|
||||||
Key: client.AppKey{
|
Key: edgeconnect.AppKey{
|
||||||
Organization: "edp2",
|
Organization: "edp2",
|
||||||
Name: "my-edge-app",
|
Name: "my-edge-app",
|
||||||
Version: "1.0.0",
|
Version: "1.0.0",
|
||||||
|
|
@ -59,7 +59,7 @@ func main() {
|
||||||
Deployment: "docker",
|
Deployment: "docker",
|
||||||
ImageType: "ImageTypeDocker",
|
ImageType: "ImageTypeDocker",
|
||||||
ImagePath: "https://registry-1.docker.io/library/nginx:latest",
|
ImagePath: "https://registry-1.docker.io/library/nginx:latest",
|
||||||
DefaultFlavor: client.Flavor{Name: "EU.small"},
|
DefaultFlavor: edgeconnect.Flavor{Name: "EU.small"},
|
||||||
ServerlessConfig: struct{}{},
|
ServerlessConfig: struct{}{},
|
||||||
AllowServerless: false,
|
AllowServerless: false,
|
||||||
},
|
},
|
||||||
|
|
@ -73,7 +73,7 @@ func main() {
|
||||||
fmt.Println("✅ SDK example completed successfully!")
|
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
|
appKey := input.App.Key
|
||||||
region := input.Region
|
region := input.Region
|
||||||
|
|
||||||
|
|
@ -98,7 +98,7 @@ func demonstrateAppLifecycle(ctx context.Context, edgeClient *client.Client, inp
|
||||||
|
|
||||||
// Step 3: List applications in the organization
|
// Step 3: List applications in the organization
|
||||||
fmt.Println("\n3. Listing applications...")
|
fmt.Println("\n3. Listing applications...")
|
||||||
filter := client.AppKey{Organization: appKey.Organization}
|
filter := edgeconnect.AppKey{Organization: appKey.Organization}
|
||||||
apps, err := edgeClient.ShowApps(ctx, filter, region)
|
apps, err := edgeClient.ShowApps(ctx, filter, region)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to list apps: %w", err)
|
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...")
|
fmt.Println("\n5. Verifying deletion...")
|
||||||
_, err = edgeClient.ShowApp(ctx, appKey, region)
|
_, err = edgeClient.ShowApp(ctx, appKey, region)
|
||||||
if err != nil {
|
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")
|
fmt.Printf("✅ App successfully deleted (not found)\n")
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("unexpected error verifying deletion: %w", err)
|
return fmt.Errorf("unexpected error verifying deletion: %w", err)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue