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

Commit

Permalink
Add inline plugins for the groups (#52)
Browse files Browse the repository at this point in the history
* Add inline plugin

So we can mix existing groups with inline definition

* Rebased
  • Loading branch information
Gsantomaggio authored Nov 2, 2020
1 parent fbf4d40 commit 6ef1b36
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 12 deletions.
8 changes: 8 additions & 0 deletions cmd/tools/cli/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ func applyGroup(config kctl.Config, groupName string) error {
}
}
}

for _, inlinePlugin := range group.InlinePlugins {
err = kctl.Apply(config, inlinePlugin, nil)
if err != nil {
return err
}
}

}

return nil
Expand Down
7 changes: 7 additions & 0 deletions cmd/tools/cli/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ func deleteGroup(config kctl.Config, groupName string) error {
}
}
}

for _, inlinePlugin := range group.InlinePlugins {
err = kctl.Delete(config, inlinePlugin)
if err != nil {
return err
}
}
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/tools/cli/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestLocalDelete(t *testing.T) {

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

func TestLocalGroupDelete(t *testing.T) {
cmd, out := setUp()
cmd.SetArgs([]string{"delete", "-g", "argo", "--kubectl", "--group-repo", joinWithRootData("groups")})
cmd.SetArgs([]string{"delete", "-g", "argo-workflow", "--kubectl", "--group-repo", joinWithRootData("groups")})
if err := cmd.Execute(); err != nil {
t.Fatalf("unexpected error %v", err)
}
Expand Down
7 changes: 4 additions & 3 deletions internal/plugins/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ type PluginGroup struct {

//Group is the specification of each k3ai plugins group
type Group struct {
PluginType string `yaml:"plugin-type"`
GroupName string `yaml:"group-name"`
Plugins []PluginGroup `yaml:"plugins,flow"`
PluginType string `yaml:"plugin-type"`
GroupName string `yaml:"group-name"`
Plugins []PluginGroup `yaml:"plugins,flow"`
InlinePlugins []Plugin `yaml:"inline-plugins,flow"`
}

//Groups is the specification of each k3ai plugins group
Expand Down
2 changes: 1 addition & 1 deletion internal/plugins/groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

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

if err != nil {
t.Fatalf("failed to unmarshal test file: %s", err)
Expand Down
2 changes: 1 addition & 1 deletion internal/plugins/remote_contents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestPluginYamls(t *testing.T) {
}

func TestGroupsYamls(t *testing.T) {
var server = mockPluginsServer(t, joinWithRootData("groups/argo/group.yaml"), GroupType)
var server = mockPluginsServer(t, joinWithRootData("groups/argo-workflow/group.yaml"), GroupType)
defer server.Close()
var groups Groups
r, err := groups.Encode(server.URL, "/test")
Expand Down
11 changes: 11 additions & 0 deletions local_repo/core/groups/argo-workflow/group.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugin-type: group
group-name: argo-workflow
plugins:
- name: test
enabled: false
- name: argo-workflow
enabled: true
inline-plugins:
- plugin-name: Argo-bind-traefik
yaml:
- url: "https://raw.githubusercontent.com/kf5i/k3ai-plugins/main/common/traefik/argo-bind.yaml"
5 changes: 0 additions & 5 deletions local_repo/core/groups/argo/group.yaml

This file was deleted.

0 comments on commit 6ef1b36

Please sign in to comment.