grim/convey

b412c2b5fc64
Parents bd445f33e472
Children 3351eae5b1d5
move metaplans/MetaPlan to the runtime package
--- a/config/config.go Thu Dec 23 08:56:02 2021 -0600
+++ b/config/config.go Thu Dec 23 09:08:12 2021 -0600
@@ -22,7 +22,6 @@
log "github.com/sirupsen/logrus"
- "keep.imfreedom.org/grim/convey/metaplans"
"keep.imfreedom.org/grim/convey/plans"
"keep.imfreedom.org/grim/convey/runtime"
)
@@ -31,7 +30,7 @@
type Config struct {
Tasks map[string]runtime.Task
Plans map[string]plans.Plan
- MetaPlans map[string]metaplans.MetaPlan
+ MetaPlans map[string]runtime.MetaPlan
Environment []string
}
--- a/config/raw.go Thu Dec 23 08:56:02 2021 -0600
+++ b/config/raw.go Thu Dec 23 09:08:12 2021 -0600
@@ -5,7 +5,6 @@
"gopkg.in/yaml.v2"
- "keep.imfreedom.org/grim/convey/metaplans"
"keep.imfreedom.org/grim/convey/plans"
"keep.imfreedom.org/grim/convey/runtime"
"keep.imfreedom.org/grim/convey/tasks"
@@ -15,7 +14,7 @@
Environment []string
Tasks map[string]yaml.MapSlice
Plans map[string]plans.Plan
- MetaPlans map[string]metaplans.MetaPlan `yaml:"meta-plans"`
+ MetaPlans map[string]runtime.MetaPlan `yaml:"meta-plans"`
}
func (r *rawConfig) processTasks() (map[string]runtime.Task, error) {
--- a/metaplans/metaplans.go Thu Dec 23 08:56:02 2021 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-// Convey
-// Copyright 2016-2018 Gary Kramlich <grim@reaperworld.com>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-package metaplans
-
-import (
- "fmt"
-)
-
-// MetaPlan is a representation of a meta plan.
-type MetaPlan struct {
- Plans []string `yaml:"plans"`
-}
-
-// UnmarshalYAML is a custom yaml unmarshaller for MetaPlan's.
-func (m *MetaPlan) UnmarshalYAML(unmarshal func(interface{}) error) error {
- type rawMetaPlan MetaPlan
- raw := rawMetaPlan{}
-
- if err := unmarshal(&raw); err != nil {
- return err
- }
-
- if len(raw.Plans) == 0 {
- return fmt.Errorf("no plans specified")
- }
-
- *m = MetaPlan(raw)
-
- return nil
-}
--- a/runner/cmd.go Thu Dec 23 08:56:02 2021 -0600
+++ b/runner/cmd.go Thu Dec 23 09:08:12 2021 -0600
@@ -45,6 +45,7 @@
env := environment.New(c.Environment...)
rt := runtime.New(env, configPath, c.ForceSequential, c.KeepWorkspace, c.Timeout)
rt.Tasks = cfg.Tasks
+ rt.MetaPlans = cfg.MetaPlans
defer rt.Shutdown()
if c.CpuShares != "" {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/runtime/metaplans.go Thu Dec 23 09:08:12 2021 -0600
@@ -0,0 +1,44 @@
+// Convey
+// Copyright 2016-2018 Gary Kramlich <grim@reaperworld.com>
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package runtime
+
+import (
+ "fmt"
+)
+
+// MetaPlan is a representation of a meta plan.
+type MetaPlan struct {
+ Plans []string `yaml:"plans"`
+}
+
+// UnmarshalYAML is a custom yaml unmarshaller for MetaPlan's.
+func (m *MetaPlan) UnmarshalYAML(unmarshal func(interface{}) error) error {
+ type rawMetaPlan MetaPlan
+ raw := rawMetaPlan{}
+
+ if err := unmarshal(&raw); err != nil {
+ return err
+ }
+
+ if len(raw.Plans) == 0 {
+ return fmt.Errorf("no plans specified")
+ }
+
+ *m = MetaPlan(raw)
+
+ return nil
+}
--- a/runtime/runtime.go Thu Dec 23 08:56:02 2021 -0600
+++ b/runtime/runtime.go Thu Dec 23 09:08:12 2021 -0600
@@ -37,7 +37,8 @@
Memory string
Timeout time.Duration
- Tasks map[string]Task
+ MetaPlans map[string]MetaPlan
+ Tasks map[string]Task
workspace *fs.Directory
}
@@ -49,7 +50,9 @@
ForceSequential: forceSequential,
KeepWorkspace: keepWorkspace,
Timeout: timeout,
- Tasks: map[string]Task{},
+
+ MetaPlans: map[string]MetaPlan{},
+ Tasks: map[string]Task{},
}
rt.Environment.LoadDefaults(configPath)