[VOL-4023] openonuAdapterGo - Ani side configuration fails while waiting for FlowDeletion, and upgrade looplab/fsm
Signed-off-by: mpagenko <michael.pagenkopf@adtran.com>
Change-Id: I9053d2ee774ff46c6d3a9cff5743a141bf14ad58
diff --git a/vendor/github.com/looplab/fsm/.gitignore b/vendor/github.com/looplab/fsm/.gitignore
index 969bdaa..0d426a5 100644
--- a/vendor/github.com/looplab/fsm/.gitignore
+++ b/vendor/github.com/looplab/fsm/.gitignore
@@ -26,3 +26,6 @@
.DS_Store
.wercker
+
+# Testing
+.coverprofile
diff --git a/vendor/github.com/looplab/fsm/.travis.yml b/vendor/github.com/looplab/fsm/.travis.yml
index b9b0eda..38968bc 100644
--- a/vendor/github.com/looplab/fsm/.travis.yml
+++ b/vendor/github.com/looplab/fsm/.travis.yml
@@ -1,7 +1,7 @@
language: go
go:
- - "1.11"
+ - "1.13"
services:
- docker
diff --git a/vendor/github.com/looplab/fsm/fsm.go b/vendor/github.com/looplab/fsm/fsm.go
index 9da9db3..4ae869e 100644
--- a/vendor/github.com/looplab/fsm/fsm.go
+++ b/vendor/github.com/looplab/fsm/fsm.go
@@ -84,7 +84,7 @@
// Events is a shorthand for defining the transition map in NewFSM.
type Events []EventDesc
-// Callbacks is a shorthand for defining the callbacks in NewFSM.a
+// Callbacks is a shorthand for defining the callbacks in NewFSM.
type Callbacks map[string]Callback
// NewFSM constructs a FSM from events and callbacks.
@@ -318,8 +318,8 @@
// Perform the rest of the transition, if not asynchronous.
f.stateMu.RUnlock()
+ defer f.stateMu.RLock()
err = f.doTransition()
- f.stateMu.RLock()
if err != nil {
return InternalError{}
}
diff --git a/vendor/github.com/looplab/fsm/go.mod b/vendor/github.com/looplab/fsm/go.mod
index 4ae0575..ae00912 100644
--- a/vendor/github.com/looplab/fsm/go.mod
+++ b/vendor/github.com/looplab/fsm/go.mod
@@ -1 +1,3 @@
module github.com/looplab/fsm
+
+go 1.13
diff --git a/vendor/github.com/looplab/fsm/graphviz_visualizer.go b/vendor/github.com/looplab/fsm/graphviz_visualizer.go
new file mode 100644
index 0000000..4163529
--- /dev/null
+++ b/vendor/github.com/looplab/fsm/graphviz_visualizer.go
@@ -0,0 +1,58 @@
+package fsm
+
+import (
+ "bytes"
+ "fmt"
+)
+
+// Visualize outputs a visualization of a FSM in Graphviz format.
+func Visualize(fsm *FSM) string {
+ var buf bytes.Buffer
+
+ // we sort the key alphabetically to have a reproducible graph output
+ sortedEKeys := getSortedTransitionKeys(fsm.transitions)
+ sortedStateKeys, _ := getSortedStates(fsm.transitions)
+
+ writeHeaderLine(&buf)
+ writeTransitions(&buf, fsm.current, sortedEKeys, fsm.transitions)
+ writeStates(&buf, sortedStateKeys)
+ writeFooter(&buf)
+
+ return buf.String()
+}
+
+func writeHeaderLine(buf *bytes.Buffer) {
+ buf.WriteString(fmt.Sprintf(`digraph fsm {`))
+ buf.WriteString("\n")
+}
+
+func writeTransitions(buf *bytes.Buffer, current string, sortedEKeys []eKey, transitions map[eKey]string) {
+ // make sure the current state is at top
+ for _, k := range sortedEKeys {
+ if k.src == current {
+ v := transitions[k]
+ buf.WriteString(fmt.Sprintf(` "%s" -> "%s" [ label = "%s" ];`, k.src, v, k.event))
+ buf.WriteString("\n")
+ }
+ }
+ for _, k := range sortedEKeys {
+ if k.src != current {
+ v := transitions[k]
+ buf.WriteString(fmt.Sprintf(` "%s" -> "%s" [ label = "%s" ];`, k.src, v, k.event))
+ buf.WriteString("\n")
+ }
+ }
+
+ buf.WriteString("\n")
+}
+
+func writeStates(buf *bytes.Buffer, sortedStateKeys []string) {
+ for _, k := range sortedStateKeys {
+ buf.WriteString(fmt.Sprintf(` "%s";`, k))
+ buf.WriteString("\n")
+ }
+}
+
+func writeFooter(buf *bytes.Buffer) {
+ buf.WriteString(fmt.Sprintln("}"))
+}
diff --git a/vendor/github.com/looplab/fsm/mermaid_visualizer.go b/vendor/github.com/looplab/fsm/mermaid_visualizer.go
new file mode 100644
index 0000000..7f2887a
--- /dev/null
+++ b/vendor/github.com/looplab/fsm/mermaid_visualizer.go
@@ -0,0 +1,89 @@
+package fsm
+
+import (
+ "bytes"
+ "fmt"
+)
+
+const highlightingColor = "#00AA00"
+
+// MermaidDiagramType the type of the mermaid diagram type
+type MermaidDiagramType string
+
+const (
+ // FlowChart the diagram type for output in flowchart style (https://mermaid-js.github.io/mermaid/#/flowchart) (including current state)
+ FlowChart MermaidDiagramType = "flowChart"
+ // StateDiagram the diagram type for output in stateDiagram style (https://mermaid-js.github.io/mermaid/#/stateDiagram)
+ StateDiagram MermaidDiagramType = "stateDiagram"
+)
+
+// VisualizeForMermaidWithGraphType outputs a visualization of a FSM in Mermaid format as specified by the graphType.
+func VisualizeForMermaidWithGraphType(fsm *FSM, graphType MermaidDiagramType) (string, error) {
+ switch graphType {
+ case FlowChart:
+ return visualizeForMermaidAsFlowChart(fsm), nil
+ case StateDiagram:
+ return visualizeForMermaidAsStateDiagram(fsm), nil
+ default:
+ return "", fmt.Errorf("unknown MermaidDiagramType: %s", graphType)
+ }
+}
+
+func visualizeForMermaidAsStateDiagram(fsm *FSM) string {
+ var buf bytes.Buffer
+
+ sortedTransitionKeys := getSortedTransitionKeys(fsm.transitions)
+
+ buf.WriteString("stateDiagram\n")
+ buf.WriteString(fmt.Sprintln(` [*] -->`, fsm.current))
+
+ for _, k := range sortedTransitionKeys {
+ v := fsm.transitions[k]
+ buf.WriteString(fmt.Sprintf(` %s --> %s: %s`, k.src, v, k.event))
+ buf.WriteString("\n")
+ }
+
+ return buf.String()
+}
+
+// visualizeForMermaidAsFlowChart outputs a visualization of a FSM in Mermaid format (including highlighting of current state).
+func visualizeForMermaidAsFlowChart(fsm *FSM) string {
+ var buf bytes.Buffer
+
+ sortedTransitionKeys := getSortedTransitionKeys(fsm.transitions)
+ sortedStates, statesToIDMap := getSortedStates(fsm.transitions)
+
+ writeFlowChartGraphType(&buf)
+ writeFlowChartStates(&buf, sortedStates, statesToIDMap)
+ writeFlowChartTransitions(&buf, fsm.transitions, sortedTransitionKeys, statesToIDMap)
+ writeFlowChartHightlightCurrent(&buf, fsm.current, statesToIDMap)
+
+ return buf.String()
+}
+
+func writeFlowChartGraphType(buf *bytes.Buffer) {
+ buf.WriteString("graph LR\n")
+}
+
+func writeFlowChartStates(buf *bytes.Buffer, sortedStates []string, statesToIDMap map[string]string) {
+ for _, state := range sortedStates {
+ buf.WriteString(fmt.Sprintf(` %s[%s]`, statesToIDMap[state], state))
+ buf.WriteString("\n")
+ }
+
+ buf.WriteString("\n")
+}
+
+func writeFlowChartTransitions(buf *bytes.Buffer, transitions map[eKey]string, sortedTransitionKeys []eKey, statesToIDMap map[string]string) {
+ for _, transition := range sortedTransitionKeys {
+ target := transitions[transition]
+ buf.WriteString(fmt.Sprintf(` %s --> |%s| %s`, statesToIDMap[transition.src], transition.event, statesToIDMap[target]))
+ buf.WriteString("\n")
+ }
+ buf.WriteString("\n")
+}
+
+func writeFlowChartHightlightCurrent(buf *bytes.Buffer, current string, statesToIDMap map[string]string) {
+ buf.WriteString(fmt.Sprintf(` style %s fill:%s`, statesToIDMap[current], highlightingColor))
+ buf.WriteString("\n")
+}
diff --git a/vendor/github.com/looplab/fsm/utils.go b/vendor/github.com/looplab/fsm/utils.go
deleted file mode 100644
index e49892e..0000000
--- a/vendor/github.com/looplab/fsm/utils.go
+++ /dev/null
@@ -1,45 +0,0 @@
-package fsm
-
-import (
- "bytes"
- "fmt"
-)
-
-// Visualize outputs a visualization of a FSM in Graphviz format.
-func Visualize(fsm *FSM) string {
- var buf bytes.Buffer
-
- states := make(map[string]int)
-
- buf.WriteString(fmt.Sprintf(`digraph fsm {`))
- buf.WriteString("\n")
-
- // make sure the initial state is at top
- for k, v := range fsm.transitions {
- if k.src == fsm.current {
- states[k.src]++
- states[v]++
- buf.WriteString(fmt.Sprintf(` "%s" -> "%s" [ label = "%s" ];`, k.src, v, k.event))
- buf.WriteString("\n")
- }
- }
-
- for k, v := range fsm.transitions {
- if k.src != fsm.current {
- states[k.src]++
- states[v]++
- buf.WriteString(fmt.Sprintf(` "%s" -> "%s" [ label = "%s" ];`, k.src, v, k.event))
- buf.WriteString("\n")
- }
- }
-
- buf.WriteString("\n")
-
- for k := range states {
- buf.WriteString(fmt.Sprintf(` "%s";`, k))
- buf.WriteString("\n")
- }
- buf.WriteString(fmt.Sprintln("}"))
-
- return buf.String()
-}
diff --git a/vendor/github.com/looplab/fsm/visualizer.go b/vendor/github.com/looplab/fsm/visualizer.go
new file mode 100644
index 0000000..4314c25
--- /dev/null
+++ b/vendor/github.com/looplab/fsm/visualizer.go
@@ -0,0 +1,77 @@
+package fsm
+
+import (
+ "fmt"
+ "sort"
+)
+
+// VisualizeType the type of the visualization
+type VisualizeType string
+
+const (
+ // GRAPHVIZ the type for graphviz output (http://www.webgraphviz.com/)
+ GRAPHVIZ VisualizeType = "graphviz"
+ // MERMAID the type for mermaid output (https://mermaid-js.github.io/mermaid/#/stateDiagram) in the stateDiagram form
+ MERMAID VisualizeType = "mermaid"
+ // MERMAID the type for mermaid output (https://mermaid-js.github.io/mermaid/#/stateDiagram) in the stateDiagram form
+ MermaidStateDiagram VisualizeType = "mermaid-state-diagram"
+ // MERMAID the type for mermaid output (https://mermaid-js.github.io/mermaid/#/flowchart) in the flow chart form
+ MermaidFlowChart VisualizeType = "mermaid-flow-chart"
+)
+
+// VisualizeWithType outputs a visualization of a FSM in the desired format.
+// If the type is not given it defaults to GRAPHVIZ
+func VisualizeWithType(fsm *FSM, visualizeType VisualizeType) (string, error) {
+ switch visualizeType {
+ case GRAPHVIZ:
+ return Visualize(fsm), nil
+ case MERMAID:
+ return VisualizeForMermaidWithGraphType(fsm, StateDiagram)
+ case MermaidStateDiagram:
+ return VisualizeForMermaidWithGraphType(fsm, StateDiagram)
+ case MermaidFlowChart:
+ return VisualizeForMermaidWithGraphType(fsm, FlowChart)
+ default:
+ return "", fmt.Errorf("unknown VisualizeType: %s", visualizeType)
+ }
+}
+
+func getSortedTransitionKeys(transitions map[eKey]string) []eKey {
+ // we sort the key alphabetically to have a reproducible graph output
+ sortedTransitionKeys := make([]eKey, 0)
+
+ for transition := range transitions {
+ sortedTransitionKeys = append(sortedTransitionKeys, transition)
+ }
+ sort.Slice(sortedTransitionKeys, func(i, j int) bool {
+ if sortedTransitionKeys[i].src == sortedTransitionKeys[j].src {
+ return sortedTransitionKeys[i].event < sortedTransitionKeys[j].event
+ }
+ return sortedTransitionKeys[i].src < sortedTransitionKeys[j].src
+ })
+
+ return sortedTransitionKeys
+}
+
+func getSortedStates(transitions map[eKey]string) ([]string, map[string]string) {
+ statesToIDMap := make(map[string]string)
+ for transition, target := range transitions {
+ if _, ok := statesToIDMap[transition.src]; !ok {
+ statesToIDMap[transition.src] = ""
+ }
+ if _, ok := statesToIDMap[target]; !ok {
+ statesToIDMap[target] = ""
+ }
+ }
+
+ sortedStates := make([]string, 0, len(statesToIDMap))
+ for state := range statesToIDMap {
+ sortedStates = append(sortedStates, state)
+ }
+ sort.Strings(sortedStates)
+
+ for i, state := range sortedStates {
+ statesToIDMap[state] = fmt.Sprintf("id%d", i)
+ }
+ return sortedStates, statesToIDMap
+}