Skip to content

Commit

Permalink
Merge the kind pkg in path
Browse files Browse the repository at this point in the history
* kind.T uint8 => path.Kind string
* kind.Mask uint8 => path.Kinds map[path.Kind]any
* Remove the no longer necessary marshaler/unmarshaler
  • Loading branch information
cvaroqui committed Sep 27, 2023
1 parent 886d775 commit 51269f4
Show file tree
Hide file tree
Showing 30 changed files with 274 additions and 311 deletions.
52 changes: 26 additions & 26 deletions core/actioncontext/props.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package actioncontext

import (
"github.com/opensvc/om3/core/kind"
"github.com/opensvc/om3/core/ordering"
"github.com/opensvc/om3/core/path"
)

type (
Expand All @@ -16,7 +16,7 @@ type (
MustLock bool
LockGroup string
Freeze bool
Kinds []kind.T
Kinds path.Kinds
DisableNodeValidation bool
RelayToAny bool
Rollback bool
Expand All @@ -40,15 +40,15 @@ var (
MustLock: true,
Order: ordering.Desc,
LocalExpect: "",
Kinds: []kind.T{kind.Svc, kind.Vol},
Kinds: path.NewKinds(path.KindSvc, path.KindVol),
Freeze: true,
TimeoutKeywords: []string{"timeout"},
PG: true,
}
Decode = Properties{
Name: "decode",
RelayToAny: true,
Kinds: []kind.T{kind.Usr, kind.Sec, kind.Cfg},
Kinds: path.NewKinds(path.KindCfg, path.KindSec, path.KindUsr),
}
Delete = Properties{
Name: "delete",
Expand All @@ -58,7 +58,7 @@ var (
Local: true,
MustLock: true,
RelayToAny: true,
Kinds: []kind.T{kind.Svc, kind.Vol, kind.Usr, kind.Sec, kind.Cfg},
Kinds: path.NewKinds(path.KindSvc, path.KindVol, path.KindCfg, path.KindSec, path.KindUsr),
}
Eval = Properties{
Name: "eval",
Expand All @@ -70,14 +70,14 @@ var (
Progress: "freezing",
Local: true,
LocalExpect: "unset",
Kinds: []kind.T{kind.Svc, kind.Vol},
Kinds: path.NewKinds(path.KindSvc, path.KindVol),
PG: true,
}
SyncFull = Properties{
Name: "sync_full",
Local: true,
MustLock: true,
Kinds: []kind.T{kind.Svc, kind.Vol},
Kinds: path.NewKinds(path.KindSvc, path.KindVol),
PG: true,
}
GenCert = Properties{
Expand Down Expand Up @@ -119,7 +119,7 @@ var (
Target: "placed",
Progress: "placing",
LocalExpect: "unset",
Kinds: []kind.T{kind.Svc},
Kinds: path.NewKinds(path.KindSvc),
TimeoutKeywords: []string{"start_timeout", "timeout"},
}
Keys = Properties{
Expand All @@ -136,7 +136,7 @@ var (
Target: "placed@",
Progress: "placing@",
LocalExpect: "unset",
Kinds: []kind.T{kind.Svc},
Kinds: path.NewKinds(path.KindSvc),
TimeoutKeywords: []string{"start_timeout", "timeout"},
}
Provision = Properties{
Expand All @@ -146,28 +146,28 @@ var (
Local: true,
MustLock: true,
LocalExpect: "unset",
Kinds: []kind.T{kind.Svc, kind.Vol},
Kinds: path.NewKinds(path.KindSvc, path.KindVol),
Rollback: true,
TimeoutKeywords: []string{"unprovision_timeout", "timeout"},
PG: true,
}
PRStart = Properties{
Name: "prstart",
Local: true,
Kinds: []kind.T{kind.Svc, kind.Vol},
Kinds: path.NewKinds(path.KindSvc, path.KindVol),
Rollback: true,
PG: true,
}
PRStop = Properties{
Name: "prstop",
Local: true,
Kinds: []kind.T{kind.Svc, kind.Vol},
Kinds: path.NewKinds(path.KindSvc, path.KindVol),
PG: true,
}
PushResInfo = Properties{
Name: "push resinfo",
Local: true,
Kinds: []kind.T{kind.Svc, kind.Vol},
Kinds: path.NewKinds(path.KindSvc, path.KindVol),
PG: true,
}
Purge = Properties{
Expand All @@ -176,7 +176,7 @@ var (
Progress: "purging",
Order: ordering.Desc,
Local: true,
Kinds: []kind.T{kind.Svc, kind.Vol, kind.Usr, kind.Sec, kind.Cfg},
Kinds: path.NewKinds(path.KindSvc, path.KindVol, path.KindCfg, path.KindSec, path.KindUsr),
TimeoutKeywords: []string{"unprovision_timeout", "timeout"},
}
Restart = Properties{
Expand All @@ -185,14 +185,14 @@ var (
Progress: "restarting",
Local: true,
LocalExpect: "unset",
Kinds: []kind.T{kind.Svc, kind.Vol},
Kinds: path.NewKinds(path.KindSvc, path.KindVol),
TimeoutKeywords: []string{"start_timeout", "timeout"},
PG: true,
}
Run = Properties{
Name: "run",
Local: true,
Kinds: []kind.T{kind.Svc, kind.Vol},
Kinds: path.NewKinds(path.KindSvc, path.KindVol),
TimeoutKeywords: []string{"run_timeout", "timeout"},
PG: true,
}
Expand All @@ -202,7 +202,7 @@ var (
Progress: "shutting",
Local: true,
Order: ordering.Desc,
Kinds: []kind.T{kind.Svc, kind.Vol},
Kinds: path.NewKinds(path.KindSvc, path.KindVol),
TimeoutKeywords: []string{"stop_timeout", "timeout"},
PG: true,
}
Expand All @@ -212,7 +212,7 @@ var (
Progress: "starting",
Local: true,
LocalExpect: "unset",
Kinds: []kind.T{kind.Svc, kind.Vol},
Kinds: path.NewKinds(path.KindSvc, path.KindVol),
Rollback: true,
TimeoutKeywords: []string{"start_timeout", "timeout"},
PG: true,
Expand All @@ -222,7 +222,7 @@ var (
Progress: "starting",
Local: true,
LocalExpect: "unset",
Kinds: []kind.T{kind.Svc, kind.Vol},
Kinds: path.NewKinds(path.KindSvc, path.KindVol),
Rollback: true,
TimeoutKeywords: []string{"start_timeout", "timeout"},
PG: true,
Expand All @@ -235,7 +235,7 @@ var (
MustLock: true,
Order: ordering.Desc,
LocalExpect: "",
Kinds: []kind.T{kind.Svc, kind.Vol},
Kinds: path.NewKinds(path.KindSvc, path.KindVol),
Freeze: true,
TimeoutKeywords: []string{"stop_timeout", "timeout"},
PG: true,
Expand All @@ -245,22 +245,22 @@ var (
Target: "placed@",
Progress: "placing@",
LocalExpect: "unset",
Kinds: []kind.T{kind.Svc},
Kinds: path.NewKinds(path.KindSvc),
TimeoutKeywords: []string{"start_timeout", "timeout"},
}
SyncResync = Properties{
Name: "sync_resync",
Local: true,
MustLock: true,
Kinds: []kind.T{kind.Svc, kind.Vol},
Kinds: path.NewKinds(path.KindSvc, path.KindVol),
PG: true,
}
Takeover = Properties{
Name: "takeover",
Target: "placed@",
Progress: "placing@",
LocalExpect: "unset",
Kinds: []kind.T{kind.Svc},
Kinds: path.NewKinds(path.KindSvc),
TimeoutKeywords: []string{"start_timeout", "timeout"},
}
TOC = Properties{
Expand All @@ -275,7 +275,7 @@ var (
Progress: "thawing",
Local: true,
LocalExpect: "unset",
Kinds: []kind.T{kind.Svc, kind.Vol},
Kinds: path.NewKinds(path.KindSvc, path.KindVol),
PG: true,
}
Unprovision = Properties{
Expand All @@ -285,15 +285,15 @@ var (
Local: true,
MustLock: true,
Order: ordering.Desc,
Kinds: []kind.T{kind.Svc, kind.Vol},
Kinds: path.NewKinds(path.KindSvc, path.KindVol),
TimeoutKeywords: []string{"unprovision_timeout", "timeout"},
PG: true,
}
SyncUpdate = Properties{
Name: "sync_update",
Local: true,
MustLock: true,
Kinds: []kind.T{kind.Svc, kind.Vol},
Kinds: path.NewKinds(path.KindSvc, path.KindVol),
PG: true,
}
)
5 changes: 2 additions & 3 deletions core/commands/daemon_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/opensvc/om3/core/client"
"github.com/opensvc/om3/core/event"
"github.com/opensvc/om3/core/kind"
"github.com/opensvc/om3/core/object"
"github.com/opensvc/om3/core/path"
"github.com/opensvc/om3/daemon/api"
Expand Down Expand Up @@ -193,8 +192,8 @@ func (t *CmdDaemonJoin) onJoined(cli *client.T) (err error) {
filePaths := make(map[string]path.T)
toFetch := []path.T{
path.Cluster,
{Namespace: "system", Kind: kind.Sec, Name: "ca"},
{Namespace: "system", Kind: kind.Sec, Name: "cert"},
{Namespace: "system", Kind: path.KindSec, Name: "ca"},
{Namespace: "system", Kind: path.KindSec, Name: "cert"},
}
downloadedFiles := make([]string, 0)
defer func([]string) {
Expand Down
8 changes: 4 additions & 4 deletions core/keywords/keywords.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"

"github.com/opensvc/om3/core/keyop"
"github.com/opensvc/om3/core/kind"
"github.com/opensvc/om3/core/path"
"github.com/opensvc/om3/util/key"
"github.com/opensvc/om3/util/stringslice"
"github.com/ssrathi/go-attr"
Expand Down Expand Up @@ -63,7 +63,7 @@ type (
Depends []keyop.T

// Kind limits the scope of this keyword to the object with kind matching this mask.
Kind kind.Mask
Kind path.Kinds

// Provisioning is set to true for keywords only used for resource provisioning
Provisioning bool
Expand Down Expand Up @@ -132,11 +132,11 @@ func (t Store) Swap(i, j int) {
t[i], t[j] = t[j], t[i]
}

func (t Store) Lookup(k key.T, kd kind.T, sectionType string) Keyword {
func (t Store) Lookup(k key.T, kind path.Kind, sectionType string) Keyword {
driverGroup := strings.Split(k.Section, "#")[0]
baseOption := k.BaseOption()
for _, kw := range t {
if !kw.Kind.Has(kd) {
if !kw.Kind.Has(kind) {
continue
}
if baseOption != kw.Option && !stringslice.Has(baseOption, kw.Aliases) {
Expand Down
Loading

0 comments on commit 51269f4

Please sign in to comment.