Skip to content
This repository was archived by the owner on Feb 21, 2023. It is now read-only.

Commit 6ef1b36

Browse files
authored
Add inline plugins for the groups (#52)
* Add inline plugin So we can mix existing groups with inline definition * Rebased
1 parent fbf4d40 commit 6ef1b36

File tree

8 files changed

+34
-12
lines changed

8 files changed

+34
-12
lines changed

cmd/tools/cli/apply.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ func applyGroup(config kctl.Config, groupName string) error {
4242
}
4343
}
4444
}
45+
46+
for _, inlinePlugin := range group.InlinePlugins {
47+
err = kctl.Apply(config, inlinePlugin, nil)
48+
if err != nil {
49+
return err
50+
}
51+
}
52+
4553
}
4654

4755
return nil

cmd/tools/cli/delete.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ func deleteGroup(config kctl.Config, groupName string) error {
4343
}
4444
}
4545
}
46+
47+
for _, inlinePlugin := range group.InlinePlugins {
48+
err = kctl.Delete(config, inlinePlugin)
49+
if err != nil {
50+
return err
51+
}
52+
}
4653
}
4754
return nil
4855
}

cmd/tools/cli/integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestLocalDelete(t *testing.T) {
6767

6868
func TestLocalGroupApply(t *testing.T) {
6969
cmd, out := setUp()
70-
cmd.SetArgs([]string{"apply", "-g", "argo", "--kubectl", "--group-repo", joinWithRootData("groups")})
70+
cmd.SetArgs([]string{"apply", "-g", "argo-workflow", "--kubectl", "--group-repo", joinWithRootData("groups")})
7171
if err := cmd.Execute(); err != nil {
7272
t.Fatalf("unexpected error %v", err)
7373
}
@@ -76,7 +76,7 @@ func TestLocalGroupApply(t *testing.T) {
7676

7777
func TestLocalGroupDelete(t *testing.T) {
7878
cmd, out := setUp()
79-
cmd.SetArgs([]string{"delete", "-g", "argo", "--kubectl", "--group-repo", joinWithRootData("groups")})
79+
cmd.SetArgs([]string{"delete", "-g", "argo-workflow", "--kubectl", "--group-repo", joinWithRootData("groups")})
8080
if err := cmd.Execute(); err != nil {
8181
t.Fatalf("unexpected error %v", err)
8282
}

internal/plugins/groups.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ type PluginGroup struct {
1414

1515
//Group is the specification of each k3ai plugins group
1616
type Group struct {
17-
PluginType string `yaml:"plugin-type"`
18-
GroupName string `yaml:"group-name"`
19-
Plugins []PluginGroup `yaml:"plugins,flow"`
17+
PluginType string `yaml:"plugin-type"`
18+
GroupName string `yaml:"group-name"`
19+
Plugins []PluginGroup `yaml:"plugins,flow"`
20+
InlinePlugins []Plugin `yaml:"inline-plugins,flow"`
2021
}
2122

2223
//Groups is the specification of each k3ai plugins group

internal/plugins/groups_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
func TestValidatePluginsGroupSpec(t *testing.T) {
99
var group Group
10-
testPluginsGroupsSpec, err := group.Encode(joinWithRootData("groups/argo/group.yaml"))
10+
testPluginsGroupsSpec, err := group.Encode(joinWithRootData("groups/argo-workflow/group.yaml"))
1111

1212
if err != nil {
1313
t.Fatalf("failed to unmarshal test file: %s", err)

internal/plugins/remote_contents_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func TestPluginYamls(t *testing.T) {
5555
}
5656

5757
func TestGroupsYamls(t *testing.T) {
58-
var server = mockPluginsServer(t, joinWithRootData("groups/argo/group.yaml"), GroupType)
58+
var server = mockPluginsServer(t, joinWithRootData("groups/argo-workflow/group.yaml"), GroupType)
5959
defer server.Close()
6060
var groups Groups
6161
r, err := groups.Encode(server.URL, "/test")
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
plugin-type: group
2+
group-name: argo-workflow
3+
plugins:
4+
- name: test
5+
enabled: false
6+
- name: argo-workflow
7+
enabled: true
8+
inline-plugins:
9+
- plugin-name: Argo-bind-traefik
10+
yaml:
11+
- url: "https://raw.githubusercontent.com/kf5i/k3ai-plugins/main/common/traefik/argo-bind.yaml"

local_repo/core/groups/argo/group.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)