Skip to content

Commit bdb107b

Browse files
committed
Merge branch 'master' into CLOUDP-305055
2 parents 164ebe4 + 871bc2e commit bdb107b

File tree

5 files changed

+59
-356
lines changed

5 files changed

+59
-356
lines changed

.github/workflows/autoupdate-spec.yaml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,31 @@ jobs:
1717
go-version-file: 'go.mod'
1818
- run: make update-openapi-spec
1919
- name: Verify Changed files
20-
uses: tj-actions/verify-changed-files@9437562cb29a5a1120dd9f02cc760ec9e5d4651a
21-
id: verify-changed-files
22-
with:
23-
files: |
24-
./tools/internal/specs/spec.yaml
20+
run: |
21+
FILES_CHANGED=false
22+
if git diff --name-only | grep -qE '^tools/internal/specs/spec\.yaml'; then
23+
FILES_CHANGED=true
24+
fi
25+
echo "FILES_CHANGED=${FILES_CHANGED}" >> "$GITHUB_ENV"
2526
- run: make gen-api-commands
26-
if: steps.verify-changed-files.outputs.files_changed == 'true'
27+
if: env.FILES_CHANGED == 'true'
2728
- run: make gen-docs
28-
if: steps.verify-changed-files.outputs.files_changed == 'true'
29+
if: env.FILES_CHANGED == 'true'
2930
- name: Find JIRA ticket
3031
id: find
31-
if: steps.verify-changed-files.outputs.files_changed == 'true'
32+
if: env.FILES_CHANGED == 'true'
3233
uses: mongodb/apix-action/find-jira@dd1d8b713effb9ac4972a3318b8e2f03b8a6d8ce
3334
with:
3435
token: ${{ secrets.JIRA_API_TOKEN }}
3536
jql: project = CLOUDP AND status NOT IN (Closed, Resolved) AND summary ~ "Update Autogenerated Commands"
3637
- name: Set JIRA ticket (find)
37-
if: (steps.verify-changed-files.outputs.files_changed == 'true') && (steps.find.outputs.found == 'true')
38+
if: (env.FILES_CHANGED == 'true') && (steps.find.outputs.found == 'true')
3839
run: |
3940
echo "JIRA_KEY=${{steps.find.outputs.issue-key}}" >> "$GITHUB_ENV"
4041
- name: Create JIRA ticket
4142
uses: mongodb/apix-action/create-jira@dd1d8b713effb9ac4972a3318b8e2f03b8a6d8ce
4243
id: create
43-
if: (steps.verify-changed-files.outputs.files_changed == 'true') && (steps.find.outputs.found == 'false')
44+
if: (env.FILES_CHANGED == 'true') && (steps.find.outputs.found == 'false')
4445
with:
4546
token: ${{ secrets.JIRA_API_TOKEN }}
4647
project-key: CLOUDP
@@ -68,19 +69,19 @@ jobs:
6869
}
6970
}
7071
- name: Set JIRA ticket (create)
71-
if: (steps.verify-changed-files.outputs.files_changed == 'true') && (steps.find.outputs.found == 'false')
72+
if: (env.FILES_CHANGED == 'true') && (steps.find.outputs.found == 'false')
7273
run: |
7374
echo "JIRA_KEY=${{steps.create.outputs.issue-key}}" >> "$GITHUB_ENV"
7475
- name: set Apix Bot token
75-
if: steps.verify-changed-files.outputs.files_changed == 'true'
76+
if: env.FILES_CHANGED == 'true'
7677
id: app-token
7778
uses: mongodb/apix-action/token@dd1d8b713effb9ac4972a3318b8e2f03b8a6d8ce
7879
with:
7980
app-id: ${{ secrets.APIXBOT_APP_ID }}
8081
private-key: ${{ secrets.APIXBOT_APP_PEM }}
8182
- uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e
8283
id: pr
83-
if: steps.verify-changed-files.outputs.files_changed == 'true'
84+
if: env.FILES_CHANGED == 'true'
8485
with:
8586
token: ${{ steps.app-token.outputs.token }}
8687
title: "${{ env.JIRA_KEY }}: Update Autogenerated Commands"

internal/plugin/plugin.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func GetDefaultPluginDirectory() (string, error) {
115115
type Command struct {
116116
Name string
117117
Description string
118+
Aliases []string
118119
}
119120

120121
type Github struct {
@@ -182,7 +183,8 @@ func (p *Plugin) GetCobraCommands() []*cobra.Command {
182183
sourceType: PluginSourceType,
183184
sourcePluginName: p.Name,
184185
},
185-
RunE: p.Run,
186+
RunE: p.Run,
187+
Aliases: pluginCmd.Aliases,
186188
}
187189

188190
// Disable the default cobra help function.
@@ -241,7 +243,7 @@ func createPluginFromManifest(manifest *Manifest) (*Plugin, error) {
241243
}
242244

243245
for cmdName, value := range manifest.Commands {
244-
plugin.Commands = append(plugin.Commands, &Command{Name: cmdName, Description: value.Description})
246+
plugin.Commands = append(plugin.Commands, &Command{Name: cmdName, Description: value.Description, Aliases: value.Aliases})
245247
}
246248

247249
return &plugin, nil

internal/plugin/plugin_manifest.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ type ManifestGithubValues struct {
3737
}
3838

3939
type ManifestCommand struct {
40-
Description string `yaml:"description,omitempty"`
40+
Aliases []string `yaml:"aliases,omitempty"`
41+
Description string `yaml:"description,omitempty"`
4142
}
4243

4344
type Manifest struct {
@@ -258,10 +259,15 @@ func getUniqueManifests(manifests []*Manifest, existingCommandsSet set.Set[strin
258259
}
259260

260261
func (m *Manifest) HasDuplicateCommand(existingCommandsSet set.Set[string]) bool {
261-
for cmdName := range m.Commands {
262+
for cmdName, cmd := range m.Commands {
262263
if existingCommandsSet.Contains(cmdName) {
263264
return true
264265
}
266+
for _, alias := range cmd.Aliases {
267+
if existingCommandsSet.Contains(alias) {
268+
return true
269+
}
270+
}
265271
}
266272
return false
267273
}

0 commit comments

Comments
 (0)