From b1627c071df76507b6ccf52e8136bbd5fbb98627 Mon Sep 17 00:00:00 2001 From: Gabriele Santomaggio Date: Sat, 31 Oct 2020 18:45:53 +0100 Subject: [PATCH] Add inline plugin So we can mix existing groups with inline definition --- cmd/tools/cli/apply.go | 8 ++++++++ cmd/tools/cli/delete.go | 7 +++++++ internal/plugins/groups.go | 7 ++++--- internal/plugins/testdata/groups/two_plugins/group.yaml | 8 ++++++-- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/cmd/tools/cli/apply.go b/cmd/tools/cli/apply.go index fe5105e..b693556 100644 --- a/cmd/tools/cli/apply.go +++ b/cmd/tools/cli/apply.go @@ -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 diff --git a/cmd/tools/cli/delete.go b/cmd/tools/cli/delete.go index 059ed06..1accb02 100644 --- a/cmd/tools/cli/delete.go +++ b/cmd/tools/cli/delete.go @@ -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 } diff --git a/internal/plugins/groups.go b/internal/plugins/groups.go index 0800b3e..4e07bd3 100644 --- a/internal/plugins/groups.go +++ b/internal/plugins/groups.go @@ -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 diff --git a/internal/plugins/testdata/groups/two_plugins/group.yaml b/internal/plugins/testdata/groups/two_plugins/group.yaml index b19fdf5..a95260c 100644 --- a/internal/plugins/testdata/groups/two_plugins/group.yaml +++ b/internal/plugins/testdata/groups/two_plugins/group.yaml @@ -2,6 +2,10 @@ plugin-type: group group-name: test_two_plugins plugins: - name: test + enabled: false + - name: argo-workflow enabled: true - - name: argo - enabled: true +inline-plugins: + - plugin-name: Argo-bind-traefik + yaml: + - url: "https://raw.githubusercontent.com/kf5i/k3ai-plugins/main/common/traefik/argo-bind.yaml" \ No newline at end of file