Skip to content

Commit 7e79367

Browse files
feat: support extension apply command after breaking change (#216)
1 parent d58a374 commit 7e79367

File tree

8 files changed

+129
-122
lines changed

8 files changed

+129
-122
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
- update go version to 1.22.5
1919
- `marketplace list-versions` command removed from alpha build
2020

21+
### BREAKING
22+
23+
- updated `extension apply` command to support new request body schema. The older version of miactl will not be compatible with the Console version upper or equal to 13.2.0.
24+
2125
## [v0.14.0] - 2024-07-25
2226

2327
### Added

docs/30_commands.md

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ miactl extensions list [flags]
624624
Available flags for the command:
625625

626626
- `--company-id` to set the ID of the desired Company
627+
- `--resolve-details` to evaluate all the extension details including `visibilities`, `menu`, `category` and `permissions`
627628

628629
### get
629630

@@ -652,29 +653,26 @@ It accepts an Extension Manifest either in `yaml` or `json` format
652653

653654
```json
654655
{
655-
"name": "Extension 1",
656-
"description": "My extension 1",
657-
"entry": "https://example.com/",
658-
"contexts": [
659-
"project"
660-
],
661-
"routes": [
662-
{
663-
"id": "extension-1",
664-
"parentId": "workloads",
665-
"locationId": "runtime",
666-
"renderType": "menu",
667-
"labelIntl": {
668-
"en": "SomeLabel",
669-
"it": "SomeLabelInItalian"
670-
},
671-
"destinationPath": "/",
672-
"order": 200.0,
673-
"icon": {
674-
"name": "PiHardDrives"
675-
}
676-
}
677-
]
656+
"name": "Extension 1",
657+
"description": "My extension 1",
658+
"entry": "https://example.com/",
659+
"activationContexts": ["project"],
660+
"destination": {
661+
"id": "runtime",
662+
"path": "/"
663+
},
664+
"iconName": "PiHardDrives",
665+
"menu": {
666+
"id": "extension-1",
667+
"labelIntl": {
668+
"en": "SomeLabel",
669+
"it": "SomeLabelInItalian"
670+
},
671+
"order": 200.0,
672+
},
673+
"category": {
674+
"id": "workloads",
675+
}
678676
}
679677
```
680678

@@ -684,23 +682,23 @@ It accepts an Extension Manifest either in `yaml` or `json` format
684682
<summary>Example YAML Manifest</summary>
685683

686684
```yaml
687-
name: "Extension 1"
688-
description: "My extension 1"
689-
entry: "https://example.com/"
690-
contexts:
685+
name: Extension 1
686+
description: My extension 1
687+
entry: https://example.com/
688+
activationContexts:
691689
- project
692-
routes:
693-
- id: "extension-1"
694-
parentId: "workloads"
695-
locationId: "runtime"
696-
labelIntl:
697-
en: "SomeLabel"
698-
it: "SomeLabelInItalian"
699-
destinationPath: "/"
700-
renderType: "menu"
701-
order: 200
702-
icon:
703-
name: "PiHardDrives"
690+
destination:
691+
id: runtime
692+
path: "/"
693+
iconName: PiHardDrives
694+
menu:
695+
id: extension-1
696+
labelIntl:
697+
en: SomeLabel
698+
it: SomeLabelInItalian
699+
order: 200
700+
category:
701+
id: workloads
704702
```
705703
706704
</details>

internal/cmd/extensions/apply.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ If an extension-id is found an updated is performed, if not instead a new extens
6060
extensionData.ExtensionID = o.EntityID
6161
}
6262

63-
if extensionData.ExtensionType == "" {
64-
extensionData.ExtensionType = IFrameExtensionType
63+
if extensionData.Type == "" {
64+
extensionData.Type = IFrameExtensionType
6565
}
6666

6767
extensibilityClient := New(client)

internal/cmd/extensions/apply_test.go

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,27 @@ import (
2323
)
2424

2525
func TestReadExtensionFromFile(t *testing.T) {
26-
order := 200.0
26+
var order extensibility.Order = 200.0
2727
expectedRecord := &extensibility.Extension{
28-
Name: "Extension 1",
29-
Description: "My extension 1",
30-
Entry: "https://example.com/",
31-
Contexts: []string{"project"},
32-
Routes: []*extensibility.ExtensionRoute{
33-
{
34-
ID: "extension-1",
35-
ParentID: "workloads",
36-
LocationID: "runtime",
37-
LabelIntl: map[string]string{
38-
"en": "SomeLabel",
39-
"it": "SomeLabelInItalian",
40-
},
41-
DestinationPath: "/",
42-
RenderType: "menu",
43-
Order: &order,
44-
Icon: &extensibility.Icon{Name: "PiHardDrives"},
28+
Name: "Extension 1",
29+
Description: "My extension 1",
30+
Entry: "https://example.com/",
31+
ActivationContexts: []extensibility.Context{"project"},
32+
Destination: extensibility.DestinationArea{
33+
ID: "runtime",
34+
Path: "/",
35+
},
36+
IconName: "PiHardDrives",
37+
Menu: extensibility.Menu{
38+
ID: "extension-1",
39+
LabelIntl: extensibility.IntlMessages{
40+
extensibility.En: "SomeLabel",
41+
extensibility.It: "SomeLabelInItalian",
4542
},
43+
Order: &order,
44+
},
45+
Category: &extensibility.Category{
46+
ID: "workloads",
4647
},
4748
}
4849

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
{
22
"name": "Extension 1",
3-
"description": "My extension 1",
43
"entry": "https://example.com/",
5-
"contexts": [
4+
"description": "My extension 1",
5+
"activationContexts": [
66
"project"
77
],
8-
"routes": [
9-
{
10-
"id": "extension-1",
11-
"parentId": "workloads",
12-
"locationId": "runtime",
13-
"renderType": "menu",
14-
"labelIntl": {
15-
"en": "SomeLabel",
16-
"it": "SomeLabelInItalian"
17-
},
18-
"destinationPath": "/",
19-
"order": 200.0,
20-
"icon": {
21-
"name": "PiHardDrives"
22-
}
23-
}
24-
]
8+
"iconName": "PiHardDrives",
9+
"destination": {
10+
"id": "runtime",
11+
"path": "/"
12+
},
13+
"menu": {
14+
"id": "extension-1",
15+
"labelIntl": {
16+
"en": "SomeLabel",
17+
"it": "SomeLabelInItalian"
18+
},
19+
"order": 200.0
20+
},
21+
"category": {
22+
"id": "workloads"
23+
}
2524
}
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
name: "Extension 1"
2-
description: "My extension 1"
3-
entry: "https://example.com/"
4-
contexts:
1+
name: Extension 1
2+
entry: https://example.com/
3+
description: My extension 1
4+
activationContexts:
55
- project
6-
routes:
7-
- id: "extension-1"
8-
parentId: "workloads"
9-
locationId: "runtime"
10-
labelIntl:
11-
en: "SomeLabel"
12-
it: "SomeLabelInItalian"
13-
destinationPath: "/"
14-
renderType: "menu"
15-
order: 200
16-
icon:
17-
name: "PiHardDrives"
6+
iconName: PiHardDrives
7+
destination:
8+
id: runtime
9+
path: "/"
10+
menu:
11+
id: extension-1
12+
labelIntl:
13+
en: SomeLabel
14+
it: SomeLabelInItalian
15+
order: 200
16+
category:
17+
id: workloads

internal/resources/extensibility/extensionInfo.go

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ type Order float64
2020
type Context string
2121

2222
type DestinationArea struct {
23-
ID string `json:"id" yaml:"id"`
23+
ID string `yaml:"id" json:"id" `
24+
Path string `yaml:"path" json:"path"`
2425
}
2526
type Languages string
2627

@@ -33,32 +34,33 @@ const (
3334
type IntlMessages map[Languages]string
3435

3536
type Visibility struct {
36-
ContextType Context `json:"contextType" yaml:"contextType"`
37-
ContextID string `json:"contextId" yaml:"contextId"`
37+
ContextType Context `yaml:"contextType" json:"contextType"`
38+
ContextID string `yaml:"contextId" json:"contextId"`
3839
}
3940

4041
type Category struct {
41-
ID string `json:"id" yaml:"id"`
42-
LabelIntl IntlMessages `json:"labelIntl,omitempty" yaml:"labelIntl,omitempty"`
42+
ID string `yaml:"id" json:"id" `
43+
LabelIntl IntlMessages `yaml:"labelIntl,omitempty" json:"labelIntl,omitempty"`
44+
Order *Order `yaml:"order,omitempty" json:"order,omitempty"`
4345
}
4446

4547
type Menu struct {
46-
ID string `json:"id" yaml:"id"`
47-
LabelIntl IntlMessages `json:"labelIntl" yaml:"labelIntl"`
48-
Order *Order `json:"order,omitempty" yaml:"order,omitempty"`
48+
ID string `yaml:"id" json:"id"`
49+
LabelIntl IntlMessages `yaml:"labelIntl" json:"labelIntl"`
50+
Order *Order `yaml:"order,omitempty" json:"order,omitempty"`
4951
}
5052

5153
type ExtensionInfo struct {
52-
ExtensionID string `json:"extensionId" yaml:"extensionId"`
53-
Name string `json:"name" yaml:"name"`
54-
Entry string `json:"entry" yaml:"entry"`
55-
Type string `json:"type" yaml:"type"`
56-
Destination DestinationArea `json:"destination" yaml:"destination"`
57-
Description string `json:"description,omitempty" yaml:"description,omitempty"`
58-
IconName string `json:"iconName,omitempty" yaml:"iconName,omitempty"`
59-
ActivationContexts []Context `json:"activationContexts" yaml:"activationContexts"`
60-
Permissions []string `json:"permissions,omitempty" yaml:"permissions,omitempty"`
61-
Visibilities []Visibility `json:"visibilities,omitempty" yaml:"visibilities,omitempty"`
62-
Category *Category `json:"category,omitempty" yaml:"category,omitempty"`
63-
Menu *Menu `json:"menu,omitempty" yaml:"menu"`
54+
ExtensionID string `yaml:"extensionId" json:"extensionId"`
55+
Name string `yaml:"name" json:"name"`
56+
Entry string `yaml:"entry" json:"entry"`
57+
Type string `yaml:"type" json:"type"`
58+
Destination DestinationArea `yaml:"destination" json:"destination"`
59+
Description string `yaml:"description,omitempty" json:"description,omitempty"`
60+
IconName string `yaml:"iconName,omitempty" json:"iconName,omitempty"`
61+
ActivationContexts []Context `yaml:"activationContexts" json:"activationContexts"`
62+
Permissions []string `yaml:"permissions,omitempty" json:"permissions,omitempty"`
63+
Visibilities []Visibility `yaml:"visibilities,omitempty" json:"visibilities,omitempty"`
64+
Category *Category `yaml:"category,omitempty" json:"category,omitempty"`
65+
Menu *Menu `yaml:"menu" json:"menu,omitempty"`
6466
}

internal/resources/extensibility/extensions.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@
1616
package extensibility
1717

1818
type Extension struct {
19-
ExtensionID string `yaml:"extensionId,omitempty" json:"extensionId,omitempty"`
20-
ExtensionType string `yaml:"extensionType,omitempty" json:"extensionType,omitempty"`
21-
Name string `yaml:"name" json:"name"`
22-
Description string `yaml:"description" json:"description"`
23-
Entry string `yaml:"entry" json:"entry"`
24-
Contexts []string `yaml:"contexts" json:"contexts"`
25-
Permissions []string `yaml:"permissions,omitempty" json:"permissions,omitempty"`
26-
Routes []*ExtensionRoute `yaml:"routes,omitempty" json:"routes,omitempty"`
19+
ExtensionID string `yaml:"extensionId,omitempty" json:"extensionId,omitempty"`
20+
Name string `yaml:"name" json:"name"`
21+
Entry string `yaml:"entry" json:"entry"`
22+
Type string `yaml:"type" json:"type"`
23+
Destination DestinationArea `yaml:"destination" json:"destination"`
24+
Description string `yaml:"description,omitempty" json:"description,omitempty"`
25+
IconName string `yaml:"iconName,omitempty" json:"iconName,omitempty"`
26+
ActivationContexts []Context `yaml:"activationContexts" json:"activationContexts"`
27+
Permissions []string `yaml:"permissions,omitempty" json:"permissions,omitempty"`
28+
Category *Category `yaml:"category,omitempty" json:"category,omitempty"`
29+
Menu Menu `yaml:"menu" json:"menu"`
2730
}
2831

2932
type Icon struct {

0 commit comments

Comments
 (0)