test: Tokens should always have a colon
This commit is contained in:
18
etcd/etcd.go
18
etcd/etcd.go
@@ -1086,7 +1086,7 @@ func (obj *EmbdEtcd) rawAddWatcher(ctx context.Context, aw *AW) (func(), error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err == nil { // watch from latest good revision
|
if err == nil { // watch from latest good revision
|
||||||
rev = response.Header.Revision // TODO +1 ?
|
rev = response.Header.Revision // TODO: +1 ?
|
||||||
useRev = true
|
useRev = true
|
||||||
if !locked {
|
if !locked {
|
||||||
retry = false
|
retry = false
|
||||||
@@ -1400,7 +1400,7 @@ func (obj *EmbdEtcd) nominateCallback(re *RE) error {
|
|||||||
if global.DEBUG {
|
if global.DEBUG {
|
||||||
log.Printf("Etcd: nominateCallback(): newCluster: %v; exists: %v; obj.server == nil: %t", newCluster, exists, obj.server == nil)
|
log.Printf("Etcd: nominateCallback(): newCluster: %v; exists: %v; obj.server == nil: %t", newCluster, exists, obj.server == nil)
|
||||||
}
|
}
|
||||||
// XXX check if i have actually volunteered first of all...
|
// XXX: check if i have actually volunteered first of all...
|
||||||
if obj.server == nil && (newCluster || exists) {
|
if obj.server == nil && (newCluster || exists) {
|
||||||
|
|
||||||
log.Printf("Etcd: StartServer(newCluster: %t): %+v", newCluster, obj.nominated)
|
log.Printf("Etcd: StartServer(newCluster: %t): %+v", newCluster, obj.nominated)
|
||||||
@@ -1431,7 +1431,7 @@ func (obj *EmbdEtcd) nominateCallback(re *RE) error {
|
|||||||
// XXX: just put this wherever for now so we don't block
|
// XXX: just put this wherever for now so we don't block
|
||||||
// nominate self so "member" list is correct for peers to see
|
// nominate self so "member" list is correct for peers to see
|
||||||
EtcdNominate(obj, obj.hostname, obj.serverURLs)
|
EtcdNominate(obj, obj.hostname, obj.serverURLs)
|
||||||
// XXX if this fails, where will we retry this part ?
|
// XXX: if this fails, where will we retry this part ?
|
||||||
}
|
}
|
||||||
|
|
||||||
// advertise client urls
|
// advertise client urls
|
||||||
@@ -1439,7 +1439,7 @@ func (obj *EmbdEtcd) nominateCallback(re *RE) error {
|
|||||||
// XXX: don't advertise local addresses! 127.0.0.1:2381 doesn't really help remote hosts
|
// XXX: don't advertise local addresses! 127.0.0.1:2381 doesn't really help remote hosts
|
||||||
// XXX: but sometimes this is what we want... hmmm how do we decide? filter on callback?
|
// XXX: but sometimes this is what we want... hmmm how do we decide? filter on callback?
|
||||||
EtcdAdvertiseEndpoints(obj, curls)
|
EtcdAdvertiseEndpoints(obj, curls)
|
||||||
// XXX if this fails, where will we retry this part ?
|
// XXX: if this fails, where will we retry this part ?
|
||||||
|
|
||||||
// force this to remove sentinel before we reconnect...
|
// force this to remove sentinel before we reconnect...
|
||||||
obj.endpointCallback(nil)
|
obj.endpointCallback(nil)
|
||||||
@@ -1655,7 +1655,7 @@ func (obj *EmbdEtcd) StartServer(newCluster bool, peerURLsMap etcdtypes.URLsMap)
|
|||||||
} else {
|
} else {
|
||||||
cfg.ClusterState = embed.ClusterStateFlagExisting
|
cfg.ClusterState = embed.ClusterStateFlagExisting
|
||||||
}
|
}
|
||||||
//cfg.ForceNewCluster = newCluster // TODO ?
|
//cfg.ForceNewCluster = newCluster // TODO: ?
|
||||||
|
|
||||||
log.Printf("Etcd: StartServer: Starting server...")
|
log.Printf("Etcd: StartServer: Starting server...")
|
||||||
obj.server, err = embed.StartEtcd(cfg)
|
obj.server, err = embed.StartEtcd(cfg)
|
||||||
@@ -1959,7 +1959,7 @@ func EtcdGetClusterSize(obj *EmbdEtcd) (uint16, error) {
|
|||||||
|
|
||||||
// EtcdMemberAdd adds a member to the cluster.
|
// EtcdMemberAdd adds a member to the cluster.
|
||||||
func EtcdMemberAdd(obj *EmbdEtcd, peerURLs etcdtypes.URLs) (*etcd.MemberAddResponse, error) {
|
func EtcdMemberAdd(obj *EmbdEtcd, peerURLs etcdtypes.URLs) (*etcd.MemberAddResponse, error) {
|
||||||
//obj.Connect(false) // TODO ?
|
//obj.Connect(false) // TODO: ?
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
var response *etcd.MemberAddResponse
|
var response *etcd.MemberAddResponse
|
||||||
var err error
|
var err error
|
||||||
@@ -1984,7 +1984,7 @@ func EtcdMemberAdd(obj *EmbdEtcd, peerURLs etcdtypes.URLs) (*etcd.MemberAddRespo
|
|||||||
// if there was an error. This is because it might have run without error, but
|
// if there was an error. This is because it might have run without error, but
|
||||||
// the member wasn't found, for example.
|
// the member wasn't found, for example.
|
||||||
func EtcdMemberRemove(obj *EmbdEtcd, mID uint64) (bool, error) {
|
func EtcdMemberRemove(obj *EmbdEtcd, mID uint64) (bool, error) {
|
||||||
//obj.Connect(false) // TODO ?
|
//obj.Connect(false) // TODO: ?
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
for {
|
for {
|
||||||
if obj.exiting { // the exit signal has been sent!
|
if obj.exiting { // the exit signal has been sent!
|
||||||
@@ -2010,7 +2010,7 @@ func EtcdMemberRemove(obj *EmbdEtcd, mID uint64) (bool, error) {
|
|||||||
// The member ID's are the keys, because an empty names means unstarted!
|
// The member ID's are the keys, because an empty names means unstarted!
|
||||||
// TODO: consider queueing this through the main loop with CtxError(ctx, err)
|
// TODO: consider queueing this through the main loop with CtxError(ctx, err)
|
||||||
func EtcdMembers(obj *EmbdEtcd) (map[uint64]string, error) {
|
func EtcdMembers(obj *EmbdEtcd) (map[uint64]string, error) {
|
||||||
//obj.Connect(false) // TODO ?
|
//obj.Connect(false) // TODO: ?
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
var response *etcd.MemberListResponse
|
var response *etcd.MemberListResponse
|
||||||
var err error
|
var err error
|
||||||
@@ -2041,7 +2041,7 @@ func EtcdMembers(obj *EmbdEtcd) (map[uint64]string, error) {
|
|||||||
|
|
||||||
// EtcdLeader returns the current leader of the etcd server cluster
|
// EtcdLeader returns the current leader of the etcd server cluster
|
||||||
func EtcdLeader(obj *EmbdEtcd) (string, error) {
|
func EtcdLeader(obj *EmbdEtcd) (string, error) {
|
||||||
//obj.Connect(false) // TODO ?
|
//obj.Connect(false) // TODO: ?
|
||||||
var err error
|
var err error
|
||||||
membersMap := make(map[uint64]string)
|
membersMap := make(map[uint64]string)
|
||||||
if membersMap, err = EtcdMembers(obj); err != nil {
|
if membersMap, err = EtcdMembers(obj); err != nil {
|
||||||
|
|||||||
@@ -792,7 +792,7 @@ func (g *Graph) Worker(v *Vertex) error {
|
|||||||
// TODO: resources could have a separate exit channel to avoid this complexity!?
|
// TODO: resources could have a separate exit channel to avoid this complexity!?
|
||||||
case event := <-obj.Events():
|
case event := <-obj.Events():
|
||||||
// NOTE: this code should match the similar Res code!
|
// NOTE: this code should match the similar Res code!
|
||||||
//cuuid.SetConverged(false) // TODO ?
|
//cuuid.SetConverged(false) // TODO: ?
|
||||||
if exit, send := obj.ReadEvent(&event); exit {
|
if exit, send := obj.ReadEvent(&event); exit {
|
||||||
return nil // exit
|
return nil // exit
|
||||||
} else if send {
|
} else if send {
|
||||||
|
|||||||
@@ -96,11 +96,11 @@ func (obj *RecWatcher) Init() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//func (obj *RecWatcher) Add(path string) error { // XXX implement me or not?
|
//func (obj *RecWatcher) Add(path string) error { // XXX: implement me or not?
|
||||||
//
|
//
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func (obj *RecWatcher) Remove(path string) error { // XXX implement me or not?
|
//func (obj *RecWatcher) Remove(path string) error { // XXX: implement me or not?
|
||||||
//
|
//
|
||||||
//}
|
//}
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ func (obj *RecWatcher) Watch() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// TODO different watchers get each others events!
|
// TODO: different watchers get each others events!
|
||||||
// https://github.com/go-fsnotify/fsnotify/issues/95
|
// https://github.com/go-fsnotify/fsnotify/issues/95
|
||||||
// this happened with two values such as:
|
// this happened with two values such as:
|
||||||
// event.Name: /tmp/mgmt/f3 and current: /tmp/mgmt/f2
|
// event.Name: /tmp/mgmt/f3 and current: /tmp/mgmt/f2
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ func (obj *ExecRes) BufioChanScanner(scanner *bufio.Scanner) (chan string, chan
|
|||||||
ch <- scanner.Text() // blocks here ?
|
ch <- scanner.Text() // blocks here ?
|
||||||
if e := scanner.Err(); e != nil {
|
if e := scanner.Err(); e != nil {
|
||||||
errch <- e // send any misc errors we encounter
|
errch <- e // send any misc errors we encounter
|
||||||
//break // TODO ?
|
//break // TODO: ?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(ch)
|
close(ch)
|
||||||
@@ -236,8 +236,8 @@ func (obj *ExecRes) CheckApply(apply bool) (checkok bool, err error) {
|
|||||||
//} else if obj.IfCmd != "" && obj.WatchCmd != "" {
|
//} else if obj.IfCmd != "" && obj.WatchCmd != "" {
|
||||||
|
|
||||||
if obj.PollInt > 0 { // && obj.WatchCmd == ""
|
if obj.PollInt > 0 { // && obj.WatchCmd == ""
|
||||||
// XXX have the Watch() command output onlyif poll events...
|
// XXX: have the Watch() command output onlyif poll events...
|
||||||
// XXX we can optimize by saving those results for returning here
|
// XXX: we can optimize by saving those results for returning here
|
||||||
// return XXX
|
// return XXX
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -365,7 +365,7 @@ func (obj *FileRes) fileCheckApply(apply bool, src io.ReadSeeker, dst string, sh
|
|||||||
// hash comparison (efficient because we can cache hash of content str)
|
// hash comparison (efficient because we can cache hash of content str)
|
||||||
if sha256sum == "" { // cache is invalid
|
if sha256sum == "" { // cache is invalid
|
||||||
hash := sha256.New()
|
hash := sha256.New()
|
||||||
// TODO file existence test?
|
// TODO: file existence test?
|
||||||
if _, err := io.Copy(hash, src); err != nil {
|
if _, err := io.Copy(hash, src); err != nil {
|
||||||
return "", false, err
|
return "", false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ func (obj *MsgRes) isAllStateOK() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// JournalPriority converts a string description to a numeric priority.
|
// JournalPriority converts a string description to a numeric priority.
|
||||||
// XXX Have Validate() make sure it actually is one of these.
|
// XXX: Have Validate() make sure it actually is one of these.
|
||||||
func (obj *MsgRes) journalPriority() journal.Priority {
|
func (obj *MsgRes) journalPriority() journal.Priority {
|
||||||
switch obj.Priority {
|
switch obj.Priority {
|
||||||
case "Emerg":
|
case "Emerg":
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ type AutoEdge interface {
|
|||||||
|
|
||||||
// MetaParams is a struct will all params that apply to every resource.
|
// MetaParams is a struct will all params that apply to every resource.
|
||||||
type MetaParams struct {
|
type MetaParams struct {
|
||||||
AutoEdge bool `yaml:"autoedge"` // metaparam, should we generate auto edges? // XXX should default to true
|
AutoEdge bool `yaml:"autoedge"` // metaparam, should we generate auto edges? // XXX: should default to true
|
||||||
AutoGroup bool `yaml:"autogroup"` // metaparam, should we auto group? // XXX should default to true
|
AutoGroup bool `yaml:"autogroup"` // metaparam, should we auto group? // XXX: should default to true
|
||||||
Noop bool `yaml:"noop"`
|
Noop bool `yaml:"noop"`
|
||||||
// NOTE: there are separate Watch and CheckApply retry and delay values,
|
// NOTE: there are separate Watch and CheckApply retry and delay values,
|
||||||
// but I've decided to use the same ones for both until there's a proper
|
// but I've decided to use the same ones for both until there's a proper
|
||||||
@@ -253,7 +253,7 @@ func (obj *BaseRes) DoSend(processChan chan event.Event, comment string) (bool,
|
|||||||
// }
|
// }
|
||||||
//case event := <-obj.events:
|
//case event := <-obj.events:
|
||||||
// // NOTE: this code should match the similar code below!
|
// // NOTE: this code should match the similar code below!
|
||||||
// //cuuid.SetConverged(false) // TODO ?
|
// //cuuid.SetConverged(false) // TODO: ?
|
||||||
// if exit, send := obj.ReadEvent(&event); exit {
|
// if exit, send := obj.ReadEvent(&event); exit {
|
||||||
// return true, nil // exit, without error
|
// return true, nil // exit, without error
|
||||||
// } else if send {
|
// } else if send {
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ func (obj *SvcRes) Watch(processChan chan event.Event) error {
|
|||||||
var notFound = (loadstate.Value == dbus.MakeVariant("not-found"))
|
var notFound = (loadstate.Value == dbus.MakeVariant("not-found"))
|
||||||
if notFound { // XXX: in the loop we'll handle changes better...
|
if notFound { // XXX: in the loop we'll handle changes better...
|
||||||
log.Printf("Failed to find svc: %v", svc)
|
log.Printf("Failed to find svc: %v", svc)
|
||||||
invalid = true // XXX ?
|
invalid = true // XXX: ?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ func (obj *SvcRes) Watch(processChan chan event.Event) error {
|
|||||||
|
|
||||||
obj.SetState(ResStateWatching) // reset
|
obj.SetState(ResStateWatching) // reset
|
||||||
select {
|
select {
|
||||||
case <-buschan: // XXX wait for new units event to unstick
|
case <-buschan: // XXX: wait for new units event to unstick
|
||||||
cuuid.SetConverged(false)
|
cuuid.SetConverged(false)
|
||||||
// loop so that we can see the changed invalid signal
|
// loop so that we can see the changed invalid signal
|
||||||
log.Printf("Svc[%v]->DaemonReload()", svc)
|
log.Printf("Svc[%v]->DaemonReload()", svc)
|
||||||
@@ -299,7 +299,7 @@ func (obj *SvcRes) CheckApply(apply bool) (checkok bool, err error) {
|
|||||||
|
|
||||||
var running = (activestate.Value == dbus.MakeVariant("active"))
|
var running = (activestate.Value == dbus.MakeVariant("active"))
|
||||||
var stateOK = ((obj.State == "") || (obj.State == "running" && running) || (obj.State == "stopped" && !running))
|
var stateOK = ((obj.State == "") || (obj.State == "running" && running) || (obj.State == "stopped" && !running))
|
||||||
var startupOK = true // XXX DETECT AND SET
|
var startupOK = true // XXX: DETECT AND SET
|
||||||
|
|
||||||
if stateOK && startupOK {
|
if stateOK && startupOK {
|
||||||
return true, nil // we are in the correct state
|
return true, nil // we are in the correct state
|
||||||
|
|||||||
@@ -8,4 +8,5 @@ for file in `find . -maxdepth 3 -type f -name '*.go' -not -path './old/*' -not -
|
|||||||
go vet "$file" && echo PASS || exit 1 # since it doesn't output an ok message on pass
|
go vet "$file" && echo PASS || exit 1 # since it doesn't output an ok message on pass
|
||||||
grep 'log.' "$file" | grep '\\n"' && echo 'no \n needed in log.Printf()' && exit 1 || echo PASS # no \n needed in log.Printf()
|
grep 'log.' "$file" | grep '\\n"' && echo 'no \n needed in log.Printf()' && exit 1 || echo PASS # no \n needed in log.Printf()
|
||||||
grep 'case _ = <-' "$file" && echo 'case _ = <- can be simplified to: case <-' && exit 1 || echo PASS # this can be simplified
|
grep 'case _ = <-' "$file" && echo 'case _ = <- can be simplified to: case <-' && exit 1 || echo PASS # this can be simplified
|
||||||
|
grep -Ei "[\/]+[\/]+[ ]*+(FIXME[^:]|TODO[^:]|XXX[^:])" "$file" && echo 'Token is missing a colon' && exit 1 || echo PASS # tokens must end with a colon
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user