feat(api): Added AppKey to ShowAppInstances
This commit is contained in:
parent
a51e2ae454
commit
ece2955a2a
10 changed files with 19 additions and 15 deletions
|
|
@ -149,7 +149,8 @@ var listInstancesCmd = &cobra.Command{
|
||||||
Name: cloudletName,
|
Name: cloudletName,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
instances, err := c.ShowAppInstances(context.Background(), instanceKey, region)
|
appKey := edgeconnect.AppKey{Name: appId}
|
||||||
|
instances, err := c.ShowAppInstances(context.Background(), instanceKey, appKey, region)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error listing app instances: %v\n", err)
|
fmt.Printf("Error listing app instances: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
@ -168,7 +169,8 @@ var listInstancesCmd = &cobra.Command{
|
||||||
Name: cloudletName,
|
Name: cloudletName,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
instances, err := c.ShowAppInstances(context.Background(), instanceKey, region)
|
appKey := v2.AppKey{Name: appId}
|
||||||
|
instances, err := c.ShowAppInstances(context.Background(), instanceKey, appKey, region)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error listing app instances: %v\n", err)
|
fmt.Printf("Error listing app instances: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import (
|
||||||
// EdgeConnectClientInterface defines the methods needed for deletion planning
|
// EdgeConnectClientInterface defines the methods needed for deletion planning
|
||||||
type EdgeConnectClientInterface interface {
|
type EdgeConnectClientInterface interface {
|
||||||
ShowApp(ctx context.Context, appKey edgeconnect.AppKey, region string) (edgeconnect.App, error)
|
ShowApp(ctx context.Context, appKey edgeconnect.AppKey, region string) (edgeconnect.App, error)
|
||||||
ShowAppInstances(ctx context.Context, instanceKey edgeconnect.AppInstanceKey, region string) ([]edgeconnect.AppInstance, error)
|
ShowAppInstances(ctx context.Context, instanceKey edgeconnect.AppInstanceKey, appKey edgeconnect.AppKey, region string) ([]edgeconnect.AppInstance, error)
|
||||||
DeleteApp(ctx context.Context, appKey edgeconnect.AppKey, region string) error
|
DeleteApp(ctx context.Context, appKey edgeconnect.AppKey, region string) error
|
||||||
DeleteAppInstance(ctx context.Context, instanceKey edgeconnect.AppInstanceKey, region string) error
|
DeleteAppInstance(ctx context.Context, instanceKey edgeconnect.AppInstanceKey, region string) error
|
||||||
}
|
}
|
||||||
|
|
@ -154,8 +154,9 @@ func (p *EdgeConnectPlanner) findInstancesToDelete(ctx context.Context, config *
|
||||||
Name: infra.CloudletName,
|
Name: infra.CloudletName,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
appKey := edgeconnect.AppKey{Name: config.Metadata.Name}
|
||||||
|
|
||||||
instances, err := p.client.ShowAppInstances(ctx, instanceKey, infra.Region)
|
instances, err := p.client.ShowAppInstances(ctx, instanceKey, appKey, infra.Region)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If it's a not found error, just continue
|
// If it's a not found error, just continue
|
||||||
if isNotFoundError(err) {
|
if isNotFoundError(err) {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ func (m *MockResourceClient) ShowApp(ctx context.Context, appKey v2.AppKey, regi
|
||||||
return args.Get(0).(v2.App), args.Error(1)
|
return args.Get(0).(v2.App), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockResourceClient) ShowAppInstances(ctx context.Context, instanceKey v2.AppInstanceKey, region string) ([]v2.AppInstance, error) {
|
func (m *MockResourceClient) ShowAppInstances(ctx context.Context, instanceKey v2.AppInstanceKey, appKey v2.AppKey, region string) ([]v2.AppInstance, error) {
|
||||||
args := m.Called(ctx, instanceKey, region)
|
args := m.Called(ctx, instanceKey, region)
|
||||||
if args.Get(0) == nil {
|
if args.Get(0) == nil {
|
||||||
return nil, args.Error(1)
|
return nil, args.Error(1)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import (
|
||||||
// EdgeConnectClientInterface defines the methods needed for deletion planning
|
// EdgeConnectClientInterface defines the methods needed for deletion planning
|
||||||
type EdgeConnectClientInterface interface {
|
type EdgeConnectClientInterface interface {
|
||||||
ShowApp(ctx context.Context, appKey v2.AppKey, region string) (v2.App, error)
|
ShowApp(ctx context.Context, appKey v2.AppKey, region string) (v2.App, error)
|
||||||
ShowAppInstances(ctx context.Context, instanceKey v2.AppInstanceKey, region string) ([]v2.AppInstance, error)
|
ShowAppInstances(ctx context.Context, instanceKey v2.AppInstanceKey, appKey v2.AppKey, region string) ([]v2.AppInstance, error)
|
||||||
DeleteApp(ctx context.Context, appKey v2.AppKey, region string) error
|
DeleteApp(ctx context.Context, appKey v2.AppKey, region string) error
|
||||||
DeleteAppInstance(ctx context.Context, instanceKey v2.AppInstanceKey, region string) error
|
DeleteAppInstance(ctx context.Context, instanceKey v2.AppInstanceKey, region string) error
|
||||||
}
|
}
|
||||||
|
|
@ -154,8 +154,9 @@ func (p *EdgeConnectPlanner) findInstancesToDelete(ctx context.Context, config *
|
||||||
Name: infra.CloudletName,
|
Name: infra.CloudletName,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
appKey := v2.AppKey{Name: config.Metadata.Name}
|
||||||
|
|
||||||
instances, err := p.client.ShowAppInstances(ctx, instanceKey, infra.Region)
|
instances, err := p.client.ShowAppInstances(ctx, instanceKey, appKey, infra.Region)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If it's a not found error, just continue
|
// If it's a not found error, just continue
|
||||||
if isNotFoundError(err) {
|
if isNotFoundError(err) {
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ func (m *MockEdgeConnectClient) ShowApp(ctx context.Context, appKey v2.AppKey, r
|
||||||
return args.Get(0).(v2.App), args.Error(1)
|
return args.Get(0).(v2.App), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockEdgeConnectClient) ShowAppInstances(ctx context.Context, instanceKey v2.AppInstanceKey, region string) ([]v2.AppInstance, error) {
|
func (m *MockEdgeConnectClient) ShowAppInstances(ctx context.Context, instanceKey v2.AppInstanceKey, appKey v2.AppKey, region string) ([]v2.AppInstance, error) {
|
||||||
args := m.Called(ctx, instanceKey, region)
|
args := m.Called(ctx, instanceKey, region)
|
||||||
if args.Get(0) == nil {
|
if args.Get(0) == nil {
|
||||||
return nil, args.Error(1)
|
return nil, args.Error(1)
|
||||||
|
|
|
||||||
|
|
@ -87,12 +87,12 @@ func (c *Client) ShowAppInstance(ctx context.Context, appInstKey AppInstanceKey,
|
||||||
|
|
||||||
// ShowAppInstances retrieves all application instances matching the filter criteria
|
// ShowAppInstances retrieves all application instances matching the filter criteria
|
||||||
// Maps to POST /auth/ctrl/ShowAppInst
|
// Maps to POST /auth/ctrl/ShowAppInst
|
||||||
func (c *Client) ShowAppInstances(ctx context.Context, appInstKey AppInstanceKey, region string) ([]AppInstance, error) {
|
func (c *Client) ShowAppInstances(ctx context.Context, appInstKey AppInstanceKey, appKey AppKey, region string) ([]AppInstance, error) {
|
||||||
transport := c.getTransport()
|
transport := c.getTransport()
|
||||||
url := c.BaseURL + "/api/v1/auth/ctrl/ShowAppInst"
|
url := c.BaseURL + "/api/v1/auth/ctrl/ShowAppInst"
|
||||||
|
|
||||||
filter := AppInstanceFilter{
|
filter := AppInstanceFilter{
|
||||||
AppInstance: AppInstance{Key: appInstKey},
|
AppInstance: AppInstance{Key: appInstKey, AppKey: appKey},
|
||||||
Region: region,
|
Region: region,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,7 @@ func TestShowAppInstances(t *testing.T) {
|
||||||
client := NewClient(server.URL)
|
client := NewClient(server.URL)
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
appInstances, err := client.ShowAppInstances(ctx, AppInstanceKey{Organization: "testorg"}, "us-west")
|
appInstances, err := client.ShowAppInstances(ctx, AppInstanceKey{Organization: "testorg"}, AppKey{}, "us-west")
|
||||||
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Len(t, appInstances, 2)
|
assert.Len(t, appInstances, 2)
|
||||||
|
|
|
||||||
|
|
@ -89,12 +89,12 @@ func (c *Client) ShowAppInstance(ctx context.Context, appInstKey AppInstanceKey,
|
||||||
|
|
||||||
// ShowAppInstances retrieves all application instances matching the filter criteria
|
// ShowAppInstances retrieves all application instances matching the filter criteria
|
||||||
// Maps to POST /auth/ctrl/ShowAppInst
|
// Maps to POST /auth/ctrl/ShowAppInst
|
||||||
func (c *Client) ShowAppInstances(ctx context.Context, appInstKey AppInstanceKey, region string) ([]AppInstance, error) {
|
func (c *Client) ShowAppInstances(ctx context.Context, appInstKey AppInstanceKey, appKey AppKey, region string) ([]AppInstance, error) {
|
||||||
transport := c.getTransport()
|
transport := c.getTransport()
|
||||||
url := c.BaseURL + "/api/v1/auth/ctrl/ShowAppInst"
|
url := c.BaseURL + "/api/v1/auth/ctrl/ShowAppInst"
|
||||||
|
|
||||||
filter := AppInstanceFilter{
|
filter := AppInstanceFilter{
|
||||||
AppInstance: AppInstance{Key: appInstKey},
|
AppInstance: AppInstance{Key: appInstKey, AppKey: appKey},
|
||||||
Region: region,
|
Region: region,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,7 @@ func TestShowAppInstances(t *testing.T) {
|
||||||
client := NewClient(server.URL)
|
client := NewClient(server.URL)
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
appInstances, err := client.ShowAppInstances(ctx, AppInstanceKey{Organization: "testorg"}, "us-west")
|
appInstances, err := client.ShowAppInstances(ctx, AppInstanceKey{Organization: "testorg"}, AppKey{}, "us-west")
|
||||||
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Len(t, appInstances, 2)
|
assert.Len(t, appInstances, 2)
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ func runComprehensiveWorkflow(ctx context.Context, c *v2.Client, config Workflow
|
||||||
|
|
||||||
// 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, v2.AppInstanceKey{Organization: config.Organization}, config.Region)
|
instances, err := c.ShowAppInstances(ctx, v2.AppInstanceKey{Organization: config.Organization}, v2.AppKey{}, 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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue