diff --git a/go.mod b/go.mod index bf4d8ccfd..b60bdbcdd 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,6 @@ require ( github.com/martini-contrib/render v0.0.0-20150707142108-ec18f8345a11 github.com/mattn/go-sqlite3 v1.14.22 github.com/montanaflynn/stats v0.7.1 - github.com/openark/golib v0.0.0-20210531070646-355f37940af8 github.com/outbrain/zookeepercli v1.0.12 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 @@ -54,7 +53,6 @@ require ( replace ( github.com/hashicorp/raft => github.com/openark/raft v0.0.0-20170918052300-fba9f909f7fe - github.com/openark/golib => ./go/golib golang.org/x/text v0.3.0 => golang.org/x/text v0.3.8 golang.org/x/text v0.3.7 => golang.org/x/text v0.3.8 ) diff --git a/go/agent/agent_dao.go b/go/agent/agent_dao.go index f8495b7c8..577ccf86a 100644 --- a/go/agent/agent_dao.go +++ b/go/agent/agent_dao.go @@ -28,8 +28,8 @@ import ( "sync" "time" - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/db" "github.com/openark/orchestrator/go/inst" diff --git a/go/agent/instance_topology_agent.go b/go/agent/instance_topology_agent.go index f4cd98028..18ecaf568 100644 --- a/go/agent/instance_topology_agent.go +++ b/go/agent/instance_topology_agent.go @@ -20,7 +20,7 @@ import ( "encoding/json" "fmt" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "github.com/openark/orchestrator/go/inst" ) diff --git a/go/app/cli.go b/go/app/cli.go index 71f3ecbbe..749441084 100644 --- a/go/app/cli.go +++ b/go/app/cli.go @@ -26,8 +26,8 @@ import ( "strings" "time" - "github.com/openark/golib/log" - "github.com/openark/golib/util" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/util" "github.com/openark/orchestrator/go/agent" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/inst" diff --git a/go/app/cli_test.go b/go/app/cli_test.go index fc589c236..2e79ba5ee 100644 --- a/go/app/cli_test.go +++ b/go/app/cli_test.go @@ -1,8 +1,8 @@ package app import ( - "github.com/openark/golib/log" - test "github.com/openark/golib/tests" + "github.com/openark/orchestrator/go/golib/log" + test "github.com/openark/orchestrator/go/golib/tests" "github.com/openark/orchestrator/go/config" "testing" ) diff --git a/go/app/http.go b/go/app/http.go index d63f57e8b..c7502dfb9 100644 --- a/go/app/http.go +++ b/go/app/http.go @@ -35,7 +35,7 @@ import ( "github.com/martini-contrib/auth" "github.com/martini-contrib/gzip" "github.com/martini-contrib/render" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" ) const discoveryMetricsName = "DISCOVERY_METRICS" diff --git a/go/attributes/attributes_dao.go b/go/attributes/attributes_dao.go index e47d554a2..13e969c0f 100644 --- a/go/attributes/attributes_dao.go +++ b/go/attributes/attributes_dao.go @@ -23,8 +23,8 @@ import ( "net/http" "strings" - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/db" ) diff --git a/go/cmd/orchestrator/main.go b/go/cmd/orchestrator/main.go index 3eae13c49..edfb28be3 100644 --- a/go/cmd/orchestrator/main.go +++ b/go/cmd/orchestrator/main.go @@ -21,7 +21,7 @@ import ( "fmt" "os" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "github.com/openark/orchestrator/go/app" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/inst" diff --git a/go/collection/collection.go b/go/collection/collection.go index e9dfdf13f..e08f8dd00 100644 --- a/go/collection/collection.go +++ b/go/collection/collection.go @@ -64,7 +64,7 @@ import ( "sync" "time" - // "github.com/openark/golib/log" + // "github.com/openark/orchestrator/go/golib/log" "github.com/openark/orchestrator/go/config" ) diff --git a/go/config/config.go b/go/config/config.go index aa940c04a..7595a6046 100644 --- a/go/config/config.go +++ b/go/config/config.go @@ -26,7 +26,7 @@ import ( "gopkg.in/gcfg.v1" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" ) var ( diff --git a/go/config/config_test.go b/go/config/config_test.go index 6fe01b5d7..95c985240 100644 --- a/go/config/config_test.go +++ b/go/config/config_test.go @@ -3,8 +3,8 @@ package config import ( "testing" - "github.com/openark/golib/log" - test "github.com/openark/golib/tests" + "github.com/openark/orchestrator/go/golib/log" + test "github.com/openark/orchestrator/go/golib/tests" ) func init() { diff --git a/go/db/db.go b/go/db/db.go index 731383012..28b71de9e 100644 --- a/go/db/db.go +++ b/go/db/db.go @@ -26,8 +26,8 @@ import ( "sync" "time" - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/config" ) diff --git a/go/db/tls.go b/go/db/tls.go index 352d29e66..b07df9b76 100644 --- a/go/db/tls.go +++ b/go/db/tls.go @@ -24,8 +24,8 @@ import ( "time" "github.com/go-sql-driver/mysql" - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/patrickmn/go-cache" "github.com/rcrowley/go-metrics" diff --git a/go/discovery/queue.go b/go/discovery/queue.go index 9308cd345..8b52220e2 100644 --- a/go/discovery/queue.go +++ b/go/discovery/queue.go @@ -29,7 +29,7 @@ import ( "sync" "time" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/inst" ) diff --git a/go/discovery/queue_aggregated_stats.go b/go/discovery/queue_aggregated_stats.go index e8ee12813..077d47cc0 100644 --- a/go/discovery/queue_aggregated_stats.go +++ b/go/discovery/queue_aggregated_stats.go @@ -19,7 +19,7 @@ package discovery import ( "github.com/montanaflynn/stats" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" ) // AggregatedQueueMetrics contains aggregate information some part queue metrics diff --git a/go/golib/go.mod b/go/golib/go.mod deleted file mode 100644 index dc6361d75..000000000 --- a/go/golib/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module golib - -go 1.18 diff --git a/go/golib/sqlutils/sqlutils.go b/go/golib/sqlutils/sqlutils.go index c015854c2..7d2dcfa43 100644 --- a/go/golib/sqlutils/sqlutils.go +++ b/go/golib/sqlutils/sqlutils.go @@ -28,7 +28,7 @@ import ( _ "github.com/go-sql-driver/mysql" _ "github.com/mattn/go-sqlite3" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" ) const DateTimeFormat = "2006-01-02 15:04:05.999999" diff --git a/go/http/api.go b/go/http/api.go index bdc27597e..9299fb000 100644 --- a/go/http/api.go +++ b/go/http/api.go @@ -30,8 +30,8 @@ import ( "github.com/martini-contrib/auth" "github.com/martini-contrib/render" - "github.com/openark/golib/log" - "github.com/openark/golib/util" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/util" fqdn "github.com/Showmax/go-fqdn" "github.com/openark/orchestrator/go/agent" diff --git a/go/http/api_test.go b/go/http/api_test.go index ef72f69a6..95598887d 100644 --- a/go/http/api_test.go +++ b/go/http/api_test.go @@ -6,8 +6,8 @@ import ( "github.com/go-martini/martini" - "github.com/openark/golib/log" - test "github.com/openark/golib/tests" + "github.com/openark/orchestrator/go/golib/log" + test "github.com/openark/orchestrator/go/golib/tests" "github.com/openark/orchestrator/go/config" ) diff --git a/go/http/raft_reverse_proxy.go b/go/http/raft_reverse_proxy.go index c9ba0568f..cc1400b1f 100644 --- a/go/http/raft_reverse_proxy.go +++ b/go/http/raft_reverse_proxy.go @@ -5,7 +5,7 @@ import ( "net/http/httputil" "net/url" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "github.com/go-martini/martini" "github.com/openark/orchestrator/go/raft" diff --git a/go/inst/analysis_dao.go b/go/inst/analysis_dao.go index e7b85a203..48d6e8de2 100644 --- a/go/inst/analysis_dao.go +++ b/go/inst/analysis_dao.go @@ -27,8 +27,8 @@ import ( orcraft "github.com/openark/orchestrator/go/raft" "github.com/openark/orchestrator/go/util" - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/patrickmn/go-cache" "github.com/rcrowley/go-metrics" ) diff --git a/go/inst/analysis_test.go b/go/inst/analysis_test.go index 715725f28..ba3e59c0a 100644 --- a/go/inst/analysis_test.go +++ b/go/inst/analysis_test.go @@ -19,8 +19,8 @@ package inst import ( "testing" - "github.com/openark/golib/log" - test "github.com/openark/golib/tests" + "github.com/openark/orchestrator/go/golib/log" + test "github.com/openark/orchestrator/go/golib/tests" "github.com/openark/orchestrator/go/config" ) diff --git a/go/inst/audit_dao.go b/go/inst/audit_dao.go index 629b6e8d1..3814dd91e 100644 --- a/go/inst/audit_dao.go +++ b/go/inst/audit_dao.go @@ -22,8 +22,8 @@ import ( "os" "time" - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/db" "github.com/rcrowley/go-metrics" diff --git a/go/inst/binlog_test.go b/go/inst/binlog_test.go index 3efb66d83..7ca4021ea 100644 --- a/go/inst/binlog_test.go +++ b/go/inst/binlog_test.go @@ -1,8 +1,8 @@ package inst import ( - "github.com/openark/golib/log" - test "github.com/openark/golib/tests" + "github.com/openark/orchestrator/go/golib/log" + test "github.com/openark/orchestrator/go/golib/tests" "github.com/openark/orchestrator/go/config" "testing" ) diff --git a/go/inst/candidate_database_instance_dao.go b/go/inst/candidate_database_instance_dao.go index d10178fb9..afd893035 100644 --- a/go/inst/candidate_database_instance_dao.go +++ b/go/inst/candidate_database_instance_dao.go @@ -19,8 +19,8 @@ package inst import ( "fmt" - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/db" diff --git a/go/inst/cluster_alias_dao.go b/go/inst/cluster_alias_dao.go index f165669c0..9afa5d228 100644 --- a/go/inst/cluster_alias_dao.go +++ b/go/inst/cluster_alias_dao.go @@ -19,8 +19,8 @@ package inst import ( "fmt" - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/db" ) diff --git a/go/inst/cluster_domain_dao.go b/go/inst/cluster_domain_dao.go index dad9f8df8..c81f95211 100644 --- a/go/inst/cluster_domain_dao.go +++ b/go/inst/cluster_domain_dao.go @@ -17,7 +17,7 @@ package inst import ( - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/db" ) diff --git a/go/inst/cluster_test.go b/go/inst/cluster_test.go index 72028af08..d97a1d9e8 100644 --- a/go/inst/cluster_test.go +++ b/go/inst/cluster_test.go @@ -19,8 +19,8 @@ package inst import ( "fmt" - "github.com/openark/golib/log" - test "github.com/openark/golib/tests" + "github.com/openark/orchestrator/go/golib/log" + test "github.com/openark/orchestrator/go/golib/tests" "github.com/openark/orchestrator/go/config" "testing" ) diff --git a/go/inst/dead_instance_filter.go b/go/inst/dead_instance_filter.go index eea967a81..e851542f0 100644 --- a/go/inst/dead_instance_filter.go +++ b/go/inst/dead_instance_filter.go @@ -4,7 +4,7 @@ import ( "sync" "time" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "github.com/openark/orchestrator/go/config" "github.com/rcrowley/go-metrics" ) diff --git a/go/inst/downtime_dao.go b/go/inst/downtime_dao.go index f3519608b..4e797d561 100644 --- a/go/inst/downtime_dao.go +++ b/go/inst/downtime_dao.go @@ -20,8 +20,8 @@ import ( "fmt" "time" - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/db" ) diff --git a/go/inst/instance.go b/go/inst/instance.go index 0a9822e53..34ee31fd6 100644 --- a/go/inst/instance.go +++ b/go/inst/instance.go @@ -24,7 +24,7 @@ import ( "strings" "time" - "github.com/openark/golib/math" + "github.com/openark/orchestrator/go/golib/math" "github.com/openark/orchestrator/go/config" ) diff --git a/go/inst/instance_binlog.go b/go/inst/instance_binlog.go index a6027dfd0..d1286d2cc 100644 --- a/go/inst/instance_binlog.go +++ b/go/inst/instance_binlog.go @@ -21,7 +21,7 @@ import ( "regexp" "strings" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "github.com/openark/orchestrator/go/config" ) diff --git a/go/inst/instance_binlog_dao.go b/go/inst/instance_binlog_dao.go index 814078555..841150d0f 100644 --- a/go/inst/instance_binlog_dao.go +++ b/go/inst/instance_binlog_dao.go @@ -22,9 +22,9 @@ import ( "strings" "time" - "github.com/openark/golib/log" - "github.com/openark/golib/math" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/math" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/db" "github.com/patrickmn/go-cache" diff --git a/go/inst/instance_dao.go b/go/inst/instance_dao.go index 5d0ea3884..d15ac5e8b 100644 --- a/go/inst/instance_dao.go +++ b/go/inst/instance_dao.go @@ -31,9 +31,9 @@ import ( "github.com/go-sql-driver/mysql" - "github.com/openark/golib/log" - "github.com/openark/golib/math" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/math" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/patrickmn/go-cache" "github.com/rcrowley/go-metrics" "github.com/sjmudd/stopwatch" diff --git a/go/inst/instance_dao_test.go b/go/inst/instance_dao_test.go index a0b1a6ba7..8bf6cdcc8 100644 --- a/go/inst/instance_dao_test.go +++ b/go/inst/instance_dao_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - test "github.com/openark/golib/tests" + test "github.com/openark/orchestrator/go/golib/tests" ) var ( diff --git a/go/inst/instance_key_map_test.go b/go/inst/instance_key_map_test.go index e0fb1dd92..761a8b762 100644 --- a/go/inst/instance_key_map_test.go +++ b/go/inst/instance_key_map_test.go @@ -20,8 +20,8 @@ import ( "math/rand" "testing" - "github.com/openark/golib/log" - test "github.com/openark/golib/tests" + "github.com/openark/orchestrator/go/golib/log" + test "github.com/openark/orchestrator/go/golib/tests" "github.com/openark/orchestrator/go/config" ) diff --git a/go/inst/instance_key_test.go b/go/inst/instance_key_test.go index ae6407193..3e2b8ba8e 100644 --- a/go/inst/instance_key_test.go +++ b/go/inst/instance_key_test.go @@ -19,8 +19,8 @@ package inst import ( "testing" - "github.com/openark/golib/log" - test "github.com/openark/golib/tests" + "github.com/openark/orchestrator/go/golib/log" + test "github.com/openark/orchestrator/go/golib/tests" "github.com/openark/orchestrator/go/config" ) diff --git a/go/inst/instance_test.go b/go/inst/instance_test.go index 77a5fc9b5..b1718abb0 100644 --- a/go/inst/instance_test.go +++ b/go/inst/instance_test.go @@ -17,8 +17,8 @@ package inst import ( - "github.com/openark/golib/log" - test "github.com/openark/golib/tests" + "github.com/openark/orchestrator/go/golib/log" + test "github.com/openark/orchestrator/go/golib/tests" "github.com/openark/orchestrator/go/config" "testing" ) diff --git a/go/inst/instance_topology.go b/go/inst/instance_topology.go index a415c9c80..5d03a7cbc 100644 --- a/go/inst/instance_topology.go +++ b/go/inst/instance_topology.go @@ -24,9 +24,9 @@ import ( "sync" "time" - "github.com/openark/golib/log" - "github.com/openark/golib/math" - "github.com/openark/golib/util" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/math" + "github.com/openark/orchestrator/go/golib/util" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/os" ) diff --git a/go/inst/instance_topology_dao.go b/go/inst/instance_topology_dao.go index f75edcf7a..f16bffb9c 100644 --- a/go/inst/instance_topology_dao.go +++ b/go/inst/instance_topology_dao.go @@ -24,8 +24,8 @@ import ( "strings" "time" - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/db" "github.com/openark/orchestrator/go/util" diff --git a/go/inst/instance_topology_dao_test.go b/go/inst/instance_topology_dao_test.go index dce235734..55bed1b5b 100644 --- a/go/inst/instance_topology_dao_test.go +++ b/go/inst/instance_topology_dao_test.go @@ -1,8 +1,8 @@ package inst import ( - "github.com/openark/golib/log" - test "github.com/openark/golib/tests" + "github.com/openark/orchestrator/go/golib/log" + test "github.com/openark/orchestrator/go/golib/tests" "github.com/openark/orchestrator/go/config" "testing" ) diff --git a/go/inst/instance_topology_test.go b/go/inst/instance_topology_test.go index 615dd37b1..9495dc14f 100644 --- a/go/inst/instance_topology_test.go +++ b/go/inst/instance_topology_test.go @@ -3,8 +3,8 @@ package inst import ( "math/rand" - "github.com/openark/golib/log" - test "github.com/openark/golib/tests" + "github.com/openark/orchestrator/go/golib/log" + test "github.com/openark/orchestrator/go/golib/tests" "github.com/openark/orchestrator/go/config" "testing" ) diff --git a/go/inst/maintenance_dao.go b/go/inst/maintenance_dao.go index ea17f12e0..9e563cd7a 100644 --- a/go/inst/maintenance_dao.go +++ b/go/inst/maintenance_dao.go @@ -19,8 +19,8 @@ package inst import ( "fmt" - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/db" "github.com/openark/orchestrator/go/process" diff --git a/go/inst/master_equivalence_dao.go b/go/inst/master_equivalence_dao.go index a7eceb785..188aa83dd 100644 --- a/go/inst/master_equivalence_dao.go +++ b/go/inst/master_equivalence_dao.go @@ -17,8 +17,8 @@ package inst import ( - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/db" ) diff --git a/go/inst/oracle_gtid_set_test.go b/go/inst/oracle_gtid_set_test.go index 168f3ce1f..2981a4f8b 100644 --- a/go/inst/oracle_gtid_set_test.go +++ b/go/inst/oracle_gtid_set_test.go @@ -3,7 +3,7 @@ package inst import ( "testing" - test "github.com/openark/golib/tests" + test "github.com/openark/orchestrator/go/golib/tests" ) func TestNewOracleGtidSetEntry(t *testing.T) { diff --git a/go/inst/pool.go b/go/inst/pool.go index cd83046d5..d067a0af8 100644 --- a/go/inst/pool.go +++ b/go/inst/pool.go @@ -22,7 +22,7 @@ import ( "github.com/openark/orchestrator/go/config" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" ) // PoolInstancesMap lists instance keys per pool name diff --git a/go/inst/pool_dao.go b/go/inst/pool_dao.go index d3641f97d..f93490e37 100644 --- a/go/inst/pool_dao.go +++ b/go/inst/pool_dao.go @@ -19,8 +19,8 @@ package inst import ( "fmt" - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/db" ) diff --git a/go/inst/postponed_functions.go b/go/inst/postponed_functions.go index 805a50bb8..89cd9cf55 100644 --- a/go/inst/postponed_functions.go +++ b/go/inst/postponed_functions.go @@ -19,7 +19,7 @@ package inst import ( "sync" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" ) type PostponedFunctionsContainer struct { diff --git a/go/inst/resolve.go b/go/inst/resolve.go index 548e964bc..c5003a6b7 100644 --- a/go/inst/resolve.go +++ b/go/inst/resolve.go @@ -25,7 +25,7 @@ import ( "sync" "time" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "github.com/openark/orchestrator/go/config" "github.com/patrickmn/go-cache" ) diff --git a/go/inst/resolve_dao.go b/go/inst/resolve_dao.go index 82f48986f..f5a0beded 100644 --- a/go/inst/resolve_dao.go +++ b/go/inst/resolve_dao.go @@ -17,8 +17,8 @@ package inst import ( - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/db" "github.com/rcrowley/go-metrics" diff --git a/go/inst/tag_dao.go b/go/inst/tag_dao.go index cb81af4f8..3e422a446 100644 --- a/go/inst/tag_dao.go +++ b/go/inst/tag_dao.go @@ -19,8 +19,8 @@ package inst import ( "fmt" - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/db" ) diff --git a/go/inst/tag_test.go b/go/inst/tag_test.go index 8a10d9d72..b930c7b9e 100644 --- a/go/inst/tag_test.go +++ b/go/inst/tag_test.go @@ -3,7 +3,7 @@ package inst import ( "testing" - test "github.com/openark/golib/tests" + test "github.com/openark/orchestrator/go/golib/tests" ) func TestParseTag(t *testing.T) { diff --git a/go/kv/consul.go b/go/kv/consul.go index 4b3c3b3cc..36f24444b 100644 --- a/go/kv/consul.go +++ b/go/kv/consul.go @@ -28,7 +28,7 @@ import ( consulapi "github.com/armon/consul-api" "github.com/patrickmn/go-cache" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" ) // getConsulKVCacheKey returns a Consul KV cache key for a given datacenter diff --git a/go/kv/consul_txn.go b/go/kv/consul_txn.go index 06e064a85..307570468 100644 --- a/go/kv/consul_txn.go +++ b/go/kv/consul_txn.go @@ -29,7 +29,7 @@ import ( consulapi "github.com/hashicorp/consul/api" "github.com/patrickmn/go-cache" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" ) // groupKVPairsByKeyPrefix groups Consul Transaction operations by KV key prefix. This diff --git a/go/kv/internal.go b/go/kv/internal.go index e9083cadd..bdf8c89e1 100644 --- a/go/kv/internal.go +++ b/go/kv/internal.go @@ -17,8 +17,8 @@ package kv import ( - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/db" ) diff --git a/go/logic/command_applier.go b/go/logic/command_applier.go index 73f67fbc9..74ccf2b07 100644 --- a/go/logic/command_applier.go +++ b/go/logic/command_applier.go @@ -23,7 +23,7 @@ import ( "github.com/openark/orchestrator/go/kv" "github.com/openark/orchestrator/go/raft" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" ) // AsyncRequest represents an entry in the async_request table diff --git a/go/logic/disable_recovery.go b/go/logic/disable_recovery.go index ff88a21c1..64f14d8d2 100644 --- a/go/logic/disable_recovery.go +++ b/go/logic/disable_recovery.go @@ -30,8 +30,8 @@ package logic // go to the database each time. import ( - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/db" ) diff --git a/go/logic/orchestrator.go b/go/logic/orchestrator.go index bfa1afaab..944d08e3b 100644 --- a/go/logic/orchestrator.go +++ b/go/logic/orchestrator.go @@ -26,7 +26,7 @@ import ( "syscall" "time" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "github.com/openark/orchestrator/go/agent" "github.com/openark/orchestrator/go/collection" "github.com/openark/orchestrator/go/config" diff --git a/go/logic/snapshot_data.go b/go/logic/snapshot_data.go index 58db37451..9521b6700 100644 --- a/go/logic/snapshot_data.go +++ b/go/logic/snapshot_data.go @@ -25,8 +25,8 @@ import ( "github.com/openark/orchestrator/go/db" "github.com/openark/orchestrator/go/inst" - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" orcraft "github.com/openark/orchestrator/go/raft" ) diff --git a/go/logic/topology_recovery.go b/go/logic/topology_recovery.go index 973239c44..d6de69e77 100644 --- a/go/logic/topology_recovery.go +++ b/go/logic/topology_recovery.go @@ -27,7 +27,7 @@ import ( "sync/atomic" "time" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "github.com/openark/orchestrator/go/attributes" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/inst" diff --git a/go/logic/topology_recovery_dao.go b/go/logic/topology_recovery_dao.go index 4a7e15d97..9a0833841 100644 --- a/go/logic/topology_recovery_dao.go +++ b/go/logic/topology_recovery_dao.go @@ -20,8 +20,8 @@ import ( "fmt" "strings" - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/db" "github.com/openark/orchestrator/go/inst" diff --git a/go/metrics/graphite.go b/go/metrics/graphite.go index 249651d53..73d5e84df 100644 --- a/go/metrics/graphite.go +++ b/go/metrics/graphite.go @@ -18,7 +18,7 @@ package metrics import ( "github.com/cyberdelia/go-metrics-graphite" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/process" "github.com/rcrowley/go-metrics" diff --git a/go/os/process.go b/go/os/process.go index e365900b2..b0570a32a 100644 --- a/go/os/process.go +++ b/go/os/process.go @@ -24,7 +24,7 @@ import ( "strings" "syscall" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "github.com/openark/orchestrator/go/config" ) diff --git a/go/os/unixcheck.go b/go/os/unixcheck.go index 4eeb8d4e2..5a43dc867 100644 --- a/go/os/unixcheck.go +++ b/go/os/unixcheck.go @@ -20,7 +20,7 @@ import ( "os/user" "strings" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" ) // UserInGroups checks if the given username is in the given unix diff --git a/go/process/access_token_dao.go b/go/process/access_token_dao.go index 9472455ec..e58ab7131 100644 --- a/go/process/access_token_dao.go +++ b/go/process/access_token_dao.go @@ -17,8 +17,8 @@ package process import ( - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/db" "github.com/openark/orchestrator/go/util" diff --git a/go/process/election_dao.go b/go/process/election_dao.go index 6e6f2b57a..04a3cf1c5 100644 --- a/go/process/election_dao.go +++ b/go/process/election_dao.go @@ -17,8 +17,8 @@ package process import ( - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/db" "github.com/openark/orchestrator/go/raft" diff --git a/go/process/health.go b/go/process/health.go index deaef2ca8..32a355b79 100644 --- a/go/process/health.go +++ b/go/process/health.go @@ -24,7 +24,7 @@ import ( "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/util" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "github.com/openark/orchestrator/go/raft" "github.com/patrickmn/go-cache" ) diff --git a/go/process/health_dao.go b/go/process/health_dao.go index e40482398..34d30dbcc 100644 --- a/go/process/health_dao.go +++ b/go/process/health_dao.go @@ -20,8 +20,8 @@ import ( "time" "fmt" - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/db" ) diff --git a/go/process/host.go b/go/process/host.go index b872a5f40..a231fb931 100644 --- a/go/process/host.go +++ b/go/process/host.go @@ -17,7 +17,7 @@ package process import ( - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "os" ) diff --git a/go/raft/file_snapshot.go b/go/raft/file_snapshot.go index 5e9f652eb..fa2d75eb4 100644 --- a/go/raft/file_snapshot.go +++ b/go/raft/file_snapshot.go @@ -5,7 +5,7 @@ import ( "bytes" "encoding/json" "fmt" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "hash" "hash/crc64" "io" diff --git a/go/raft/fsm.go b/go/raft/fsm.go index a1cd0387a..14fcfbd77 100644 --- a/go/raft/fsm.go +++ b/go/raft/fsm.go @@ -21,7 +21,7 @@ import ( "io" "strings" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "github.com/hashicorp/raft" ) diff --git a/go/raft/http_client.go b/go/raft/http_client.go index 3bb1694dd..58ac14963 100644 --- a/go/raft/http_client.go +++ b/go/raft/http_client.go @@ -28,7 +28,7 @@ import ( "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/ssl" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" ) var ( diff --git a/go/raft/raft.go b/go/raft/raft.go index dcb8cca2d..8a5cb34e6 100644 --- a/go/raft/raft.go +++ b/go/raft/raft.go @@ -26,7 +26,7 @@ import ( "sync/atomic" "time" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "github.com/openark/orchestrator/go/config" "github.com/openark/orchestrator/go/util" diff --git a/go/raft/rel_store.go b/go/raft/rel_store.go index ac32237a0..4d3cb43c1 100644 --- a/go/raft/rel_store.go +++ b/go/raft/rel_store.go @@ -22,8 +22,8 @@ import ( "path/filepath" "sync" - "github.com/openark/golib/log" - "github.com/openark/golib/sqlutils" + "github.com/openark/orchestrator/go/golib/log" + "github.com/openark/orchestrator/go/golib/sqlutils" "github.com/hashicorp/raft" ) diff --git a/go/raft/store.go b/go/raft/store.go index fb0257771..d275fa4ef 100644 --- a/go/raft/store.go +++ b/go/raft/store.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "github.com/hashicorp/raft" ) diff --git a/go/ssl/ssl.go b/go/ssl/ssl.go index 979b5c791..f95f347fe 100644 --- a/go/ssl/ssl.go +++ b/go/ssl/ssl.go @@ -12,7 +12,7 @@ import ( "github.com/go-martini/martini" "github.com/howeyc/gopass" - "github.com/openark/golib/log" + "github.com/openark/orchestrator/go/golib/log" "github.com/openark/orchestrator/go/config" ) diff --git a/go/util/token_test.go b/go/util/token_test.go index 7a1e446cb..3187bb9ed 100644 --- a/go/util/token_test.go +++ b/go/util/token_test.go @@ -1,7 +1,7 @@ package util import ( - test "github.com/openark/golib/tests" + test "github.com/openark/orchestrator/go/golib/tests" "testing" ) diff --git a/vendor/github.com/openark/golib/log/log.go b/vendor/github.com/openark/golib/log/log.go deleted file mode 100644 index 26d33c997..000000000 --- a/vendor/github.com/openark/golib/log/log.go +++ /dev/null @@ -1,268 +0,0 @@ -/* - Copyright 2014 Outbrain Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package log - -import ( - "errors" - "fmt" - "log/syslog" - "os" - "runtime/debug" - "time" -) - -// LogLevel indicates the severity of a log entry -type LogLevel int - -func (this LogLevel) String() string { - switch this { - case FATAL: - return "FATAL" - case CRITICAL: - return "CRITICAL" - case ERROR: - return "ERROR" - case WARNING: - return "WARNING" - case NOTICE: - return "NOTICE" - case INFO: - return "INFO" - case DEBUG: - return "DEBUG" - } - return "unknown" -} - -func LogLevelFromString(logLevelName string) (LogLevel, error) { - switch logLevelName { - case "FATAL": - return FATAL, nil - case "CRITICAL": - return CRITICAL, nil - case "ERROR": - return ERROR, nil - case "WARNING": - return WARNING, nil - case "NOTICE": - return NOTICE, nil - case "INFO": - return INFO, nil - case "DEBUG": - return DEBUG, nil - } - return 0, fmt.Errorf("Unknown LogLevel name: %+v", logLevelName) -} - -const ( - FATAL LogLevel = iota - CRITICAL - ERROR - WARNING - NOTICE - INFO - DEBUG -) - -const TimeFormat = "2006-01-02 15:04:05" - -// globalLogLevel indicates the global level filter for all logs (only entries with level equals or higher -// than this value will be logged) -var globalLogLevel LogLevel = DEBUG -var printStackTrace bool = false - -// syslogWriter is optional, and defaults to nil (disabled) -var syslogLevel LogLevel = ERROR -var syslogWriter *syslog.Writer - -// SetPrintStackTrace enables/disables dumping the stack upon error logging -func SetPrintStackTrace(shouldPrintStackTrace bool) { - printStackTrace = shouldPrintStackTrace -} - -// SetLevel sets the global log level. Only entries with level equals or higher than -// this value will be logged -func SetLevel(logLevel LogLevel) { - globalLogLevel = logLevel -} - -// GetLevel returns current global log level -func GetLevel() LogLevel { - return globalLogLevel -} - -// EnableSyslogWriter enables, if possible, writes to syslog. These will execute _in addition_ to normal logging -func EnableSyslogWriter(tag string) (err error) { - syslogWriter, err = syslog.New(syslog.LOG_ERR, tag) - if err != nil { - syslogWriter = nil - } - return err -} - -// SetSyslogLevel sets the minimal syslog level. Only entries with level equals or higher than -// this value will be logged. However, this is also capped by the global log level. That is, -// messages with lower level than global-log-level will be discarded at any case. -func SetSyslogLevel(logLevel LogLevel) { - syslogLevel = logLevel -} - -// logFormattedEntry nicely formats and emits a log entry -func logFormattedEntry(logLevel LogLevel, message string, args ...interface{}) string { - if logLevel > globalLogLevel { - return "" - } - // if TZ env variable is set, update the timestamp timezone - localizedTime := time.Now() - tzLocation := os.Getenv("TZ") - if tzLocation != "" { - location, err := time.LoadLocation(tzLocation) - if err == nil { // if invalid tz location was provided, just leave it as the default - localizedTime = time.Now().In(location) - } - } - - msgArgs := fmt.Sprintf(message, args...) - entryString := fmt.Sprintf("%s %s %s", localizedTime.Format(TimeFormat), logLevel, msgArgs) - fmt.Fprintln(os.Stderr, entryString) - - if syslogWriter != nil { - go func() error { - if logLevel > syslogLevel { - return nil - } - switch logLevel { - case FATAL: - return syslogWriter.Emerg(msgArgs) - case CRITICAL: - return syslogWriter.Crit(msgArgs) - case ERROR: - return syslogWriter.Err(msgArgs) - case WARNING: - return syslogWriter.Warning(msgArgs) - case NOTICE: - return syslogWriter.Notice(msgArgs) - case INFO: - return syslogWriter.Info(msgArgs) - case DEBUG: - return syslogWriter.Debug(msgArgs) - } - return nil - }() - } - return entryString -} - -// logEntry emits a formatted log entry -func logEntry(logLevel LogLevel, message string, args ...interface{}) string { - entryString := message - for _, s := range args { - entryString += fmt.Sprintf(" %s", s) - } - return logFormattedEntry(logLevel, entryString) -} - -// logErrorEntry emits a log entry based on given error object -func logErrorEntry(logLevel LogLevel, err error) error { - if err == nil { - // No error - return nil - } - entryString := fmt.Sprintf("%+v", err) - logEntry(logLevel, entryString) - if printStackTrace { - debug.PrintStack() - } - return err -} - -func Debug(message string, args ...interface{}) string { - return logEntry(DEBUG, message, args...) -} - -func Debugf(message string, args ...interface{}) string { - return logFormattedEntry(DEBUG, message, args...) -} - -func Info(message string, args ...interface{}) string { - return logEntry(INFO, message, args...) -} - -func Infof(message string, args ...interface{}) string { - return logFormattedEntry(INFO, message, args...) -} - -func Notice(message string, args ...interface{}) string { - return logEntry(NOTICE, message, args...) -} - -func Noticef(message string, args ...interface{}) string { - return logFormattedEntry(NOTICE, message, args...) -} - -func Warning(message string, args ...interface{}) error { - return errors.New(logEntry(WARNING, message, args...)) -} - -func Warningf(message string, args ...interface{}) error { - return errors.New(logFormattedEntry(WARNING, message, args...)) -} - -func Error(message string, args ...interface{}) error { - return errors.New(logEntry(ERROR, message, args...)) -} - -func Errorf(message string, args ...interface{}) error { - return errors.New(logFormattedEntry(ERROR, message, args...)) -} - -func Errore(err error) error { - return logErrorEntry(ERROR, err) -} - -func Critical(message string, args ...interface{}) error { - return errors.New(logEntry(CRITICAL, message, args...)) -} - -func Criticalf(message string, args ...interface{}) error { - return errors.New(logFormattedEntry(CRITICAL, message, args...)) -} - -func Criticale(err error) error { - return logErrorEntry(CRITICAL, err) -} - -// Fatal emits a FATAL level entry and exists the program -func Fatal(message string, args ...interface{}) error { - logEntry(FATAL, message, args...) - os.Exit(1) - return errors.New(logEntry(CRITICAL, message, args...)) -} - -// Fatalf emits a FATAL level entry and exists the program -func Fatalf(message string, args ...interface{}) error { - logFormattedEntry(FATAL, message, args...) - os.Exit(1) - return errors.New(logFormattedEntry(CRITICAL, message, args...)) -} - -// Fatale emits a FATAL level entry and exists the program -func Fatale(err error) error { - logErrorEntry(FATAL, err) - os.Exit(1) - return err -} diff --git a/vendor/github.com/openark/golib/math/math.go b/vendor/github.com/openark/golib/math/math.go deleted file mode 100644 index f1f2068e4..000000000 --- a/vendor/github.com/openark/golib/math/math.go +++ /dev/null @@ -1,119 +0,0 @@ -/* - Copyright 2014 Shlomi Noach. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package math - -func MinInt(i1, i2 int) int { - if i1 < i2 { - return i1 - } - return i2 -} - -func MaxInt(i1, i2 int) int { - if i1 > i2 { - return i1 - } - return i2 -} - -func MinInt64(i1, i2 int64) int64 { - if i1 < i2 { - return i1 - } - return i2 -} - -func MaxInt64(i1, i2 int64) int64 { - if i1 > i2 { - return i1 - } - return i2 -} - -func MinUInt(i1, i2 uint) uint { - if i1 < i2 { - return i1 - } - return i2 -} - -func MaxUInt(i1, i2 uint) uint { - if i1 > i2 { - return i1 - } - return i2 -} - -func MinUInt64(i1, i2 uint64) uint64 { - if i1 < i2 { - return i1 - } - return i2 -} - -func MaxUInt64(i1, i2 uint64) uint64 { - if i1 > i2 { - return i1 - } - return i2 -} - -func MinString(i1, i2 string) string { - if i1 < i2 { - return i1 - } - return i2 -} - -func MaxString(i1, i2 string) string { - if i1 > i2 { - return i1 - } - return i2 -} - -// TernaryString acts like a "? :" C-style ternary operator for strings -func TernaryString(condition bool, resTrue string, resFalse string) string { - if condition { - return resTrue - } - return resFalse -} - -// TernaryString acts like a "? :" C-style ternary operator for ints -func TernaryInt(condition bool, resTrue int, resFalse int) int { - if condition { - return resTrue - } - return resFalse -} - -// AbsInt is an ABS function for int type -func AbsInt(i int) int { - if i >= 0 { - return i - } - return -i -} - -// AbsInt64 is an ABS function for int64 type -func AbsInt64(i int64) int64 { - if i >= 0 { - return i - } - return -i -} diff --git a/vendor/github.com/openark/golib/sqlutils/dialect.go b/vendor/github.com/openark/golib/sqlutils/dialect.go deleted file mode 100644 index 19cb55d25..000000000 --- a/vendor/github.com/openark/golib/sqlutils/dialect.go +++ /dev/null @@ -1,49 +0,0 @@ -/* - Copyright 2017 GitHub Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package sqlutils - -import ( - "regexp" - "strings" -) - -type regexpMap struct { - r *regexp.Regexp - replacement string -} - -func (this *regexpMap) process(text string) (result string) { - return this.r.ReplaceAllString(text, this.replacement) -} - -func rmap(regexpExpression string, replacement string) regexpMap { - return regexpMap{ - r: regexp.MustCompile(regexpSpaces(regexpExpression)), - replacement: replacement, - } -} - -func regexpSpaces(statement string) string { - return strings.Replace(statement, " ", `[\s]+`, -1) -} - -func applyConversions(statement string, conversions []regexpMap) string { - for _, rmap := range conversions { - statement = rmap.process(statement) - } - return statement -} diff --git a/vendor/github.com/openark/golib/sqlutils/sqlite_dialect.go b/vendor/github.com/openark/golib/sqlutils/sqlite_dialect.go deleted file mode 100644 index 5937aa42a..000000000 --- a/vendor/github.com/openark/golib/sqlutils/sqlite_dialect.go +++ /dev/null @@ -1,130 +0,0 @@ -/* - Copyright 2017 GitHub Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -// What's this about? -// This is a brute-force regular-expression based conversion from MySQL syntax to sqlite3 syntax. -// It is NOT meant to be a general purpose solution and is only expected & confirmed to run on -// queries issued by orchestrator. There are known limitations to this design. -// It's not even pretty. -// In fact... -// Well, it gets the job done at this time. Call it debt. - -package sqlutils - -import ( - "regexp" -) - -var sqlite3CreateTableConversions = []regexpMap{ - rmap(`(?i) (character set|charset) [\S]+`, ``), - rmap(`(?i)int unsigned`, `int`), - rmap(`(?i)int[\s]*[(][\s]*([0-9]+)[\s]*[)] unsigned`, `int`), - rmap(`(?i)engine[\s]*=[\s]*(innodb|myisam|ndb|memory|tokudb)`, ``), - rmap(`(?i)DEFAULT CHARSET[\s]*=[\s]*[\S]+`, ``), - rmap(`(?i)[\S]*int( not null|) auto_increment`, `integer`), - rmap(`(?i)comment '[^']*'`, ``), - rmap(`(?i)after [\S]+`, ``), - rmap(`(?i)alter table ([\S]+) add (index|key) ([\S]+) (.+)`, `create index ${3}_${1} on $1 $4`), - rmap(`(?i)alter table ([\S]+) add unique (index|key) ([\S]+) (.+)`, `create unique index ${3}_${1} on $1 $4`), - rmap(`(?i)([\S]+) enum[\s]*([(].*?[)])`, `$1 text check($1 in $2)`), - rmap(`(?i)([\s\S]+[/][*] sqlite3-skip [*][/][\s\S]+)`, ``), - rmap(`(?i)timestamp default current_timestamp`, `timestamp default ('')`), - rmap(`(?i)timestamp not null default current_timestamp`, `timestamp not null default ('')`), - - rmap(`(?i)add column (.*int) not null[\s]*$`, `add column $1 not null default 0`), - rmap(`(?i)add column (.* text) not null[\s]*$`, `add column $1 not null default ''`), - rmap(`(?i)add column (.* varchar.*) not null[\s]*$`, `add column $1 not null default ''`), -} - -var sqlite3InsertConversions = []regexpMap{ - rmap(`(?i)insert ignore ([\s\S]+) on duplicate key update [\s\S]+`, `insert or ignore $1`), - rmap(`(?i)insert ignore`, `insert or ignore`), - rmap(`(?i)now[(][)]`, `datetime('now')`), - rmap(`(?i)insert into ([\s\S]+) on duplicate key update [\s\S]+`, `replace into $1`), -} - -var sqlite3GeneralConversions = []regexpMap{ - rmap(`(?i)now[(][)][\s]*[-][\s]*interval [?] ([\w]+)`, `datetime('now', printf('-%d $1', ?))`), - rmap(`(?i)now[(][)][\s]*[+][\s]*interval [?] ([\w]+)`, `datetime('now', printf('+%d $1', ?))`), - rmap(`(?i)now[(][)][\s]*[-][\s]*interval ([0-9.]+) ([\w]+)`, `datetime('now', '-${1} $2')`), - rmap(`(?i)now[(][)][\s]*[+][\s]*interval ([0-9.]+) ([\w]+)`, `datetime('now', '+${1} $2')`), - - rmap(`(?i)[=<>\s]([\S]+[.][\S]+)[\s]*[-][\s]*interval [?] ([\w]+)`, ` datetime($1, printf('-%d $2', ?))`), - rmap(`(?i)[=<>\s]([\S]+[.][\S]+)[\s]*[+][\s]*interval [?] ([\w]+)`, ` datetime($1, printf('+%d $2', ?))`), - - rmap(`(?i)unix_timestamp[(][)]`, `strftime('%s', 'now')`), - rmap(`(?i)unix_timestamp[(]([^)]+)[)]`, `strftime('%s', $1)`), - rmap(`(?i)now[(][)]`, `datetime('now')`), - rmap(`(?i)cast[(][\s]*([\S]+) as signed[\s]*[)]`, `cast($1 as integer)`), - - rmap(`(?i)\bconcat[(][\s]*([^,)]+)[\s]*,[\s]*([^,)]+)[\s]*[)]`, `($1 || $2)`), - rmap(`(?i)\bconcat[(][\s]*([^,)]+)[\s]*,[\s]*([^,)]+)[\s]*,[\s]*([^,)]+)[\s]*[)]`, `($1 || $2 || $3)`), - - rmap(`(?i) rlike `, ` like `), - - rmap(`(?i)create index([\s\S]+)[(][\s]*[0-9]+[\s]*[)]([\s\S]+)`, `create index ${1}${2}`), - rmap(`(?i)drop index ([\S]+) on ([\S]+)`, `drop index if exists $1`), -} - -var ( - sqlite3IdentifyCreateTableStatement = regexp.MustCompile(regexpSpaces(`(?i)^[\s]*create table`)) - sqlite3IdentifyCreateIndexStatement = regexp.MustCompile(regexpSpaces(`(?i)^[\s]*create( unique|) index`)) - sqlite3IdentifyDropIndexStatement = regexp.MustCompile(regexpSpaces(`(?i)^[\s]*drop index`)) - sqlite3IdentifyAlterTableStatement = regexp.MustCompile(regexpSpaces(`(?i)^[\s]*alter table`)) - sqlite3IdentifyInsertStatement = regexp.MustCompile(regexpSpaces(`(?i)^[\s]*(insert|replace)`)) -) - -func IsInsert(statement string) bool { - return sqlite3IdentifyInsertStatement.MatchString(statement) -} - -func IsCreateTable(statement string) bool { - return sqlite3IdentifyCreateTableStatement.MatchString(statement) -} - -func IsCreateIndex(statement string) bool { - return sqlite3IdentifyCreateIndexStatement.MatchString(statement) -} - -func IsDropIndex(statement string) bool { - return sqlite3IdentifyDropIndexStatement.MatchString(statement) -} - -func IsAlterTable(statement string) bool { - return sqlite3IdentifyAlterTableStatement.MatchString(statement) -} - -func ToSqlite3CreateTable(statement string) string { - return applyConversions(statement, sqlite3CreateTableConversions) -} - -func ToSqlite3Insert(statement string) string { - return applyConversions(statement, sqlite3InsertConversions) -} - -func ToSqlite3Dialect(statement string) (translated string) { - if IsCreateTable(statement) { - return ToSqlite3CreateTable(statement) - } - if IsAlterTable(statement) { - return ToSqlite3CreateTable(statement) - } - statement = applyConversions(statement, sqlite3GeneralConversions) - if IsInsert(statement) { - return ToSqlite3Insert(statement) - } - return statement -} diff --git a/vendor/github.com/openark/golib/sqlutils/sqlutils.go b/vendor/github.com/openark/golib/sqlutils/sqlutils.go deleted file mode 100644 index c015854c2..000000000 --- a/vendor/github.com/openark/golib/sqlutils/sqlutils.go +++ /dev/null @@ -1,470 +0,0 @@ -/* - Copyright 2014 Outbrain Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package sqlutils - -import ( - "database/sql" - "encoding/json" - "errors" - "fmt" - "strconv" - "strings" - "sync" - "time" - - _ "github.com/go-sql-driver/mysql" - _ "github.com/mattn/go-sqlite3" - "github.com/openark/golib/log" -) - -const DateTimeFormat = "2006-01-02 15:04:05.999999" - -// RowMap represents one row in a result set. Its objective is to allow -// for easy, typed getters by column name. -type RowMap map[string]CellData - -// Cell data is the result of a single (atomic) column in a single row -type CellData sql.NullString - -func (this *CellData) MarshalJSON() ([]byte, error) { - if this.Valid { - return json.Marshal(this.String) - } else { - return json.Marshal(nil) - } -} - -// UnmarshalJSON reds this object from JSON -func (this *CellData) UnmarshalJSON(b []byte) error { - var s string - if err := json.Unmarshal(b, &s); err != nil { - return err - } - (*this).String = s - (*this).Valid = true - - return nil -} - -func (this *CellData) NullString() *sql.NullString { - return (*sql.NullString)(this) -} - -// RowData is the result of a single row, in positioned array format -type RowData []CellData - -// MarshalJSON will marshal this map as JSON -func (this *RowData) MarshalJSON() ([]byte, error) { - cells := make([](*CellData), len(*this), len(*this)) - for i, val := range *this { - d := CellData(val) - cells[i] = &d - } - return json.Marshal(cells) -} - -func (this *RowData) Args() []interface{} { - result := make([]interface{}, len(*this)) - for i := range *this { - result[i] = (*(*this)[i].NullString()) - } - return result -} - -// ResultData is an ordered row set of RowData -type ResultData []RowData -type NamedResultData struct { - Columns []string - Data ResultData -} - -var EmptyResultData = ResultData{} - -func (this *RowMap) GetString(key string) string { - return (*this)[key].String -} - -// GetStringD returns a string from the map, or a default value if the key does not exist -func (this *RowMap) GetStringD(key string, def string) string { - if cell, ok := (*this)[key]; ok { - return cell.String - } - return def -} - -func (this *RowMap) GetInt64(key string) int64 { - res, _ := strconv.ParseInt(this.GetString(key), 10, 0) - return res -} - -func (this *RowMap) GetNullInt64(key string) sql.NullInt64 { - i, err := strconv.ParseInt(this.GetString(key), 10, 0) - if err == nil { - return sql.NullInt64{Int64: i, Valid: true} - } else { - return sql.NullInt64{Valid: false} - } -} - -func (this *RowMap) GetInt(key string) int { - res, _ := strconv.Atoi(this.GetString(key)) - return res -} - -func (this *RowMap) GetIntD(key string, def int) int { - res, err := strconv.Atoi(this.GetString(key)) - if err != nil { - return def - } - return res -} - -func (this *RowMap) GetUint(key string) uint { - res, _ := strconv.ParseUint(this.GetString(key), 10, 0) - return uint(res) -} - -func (this *RowMap) GetUintD(key string, def uint) uint { - res, err := strconv.Atoi(this.GetString(key)) - if err != nil { - return def - } - return uint(res) -} - -func (this *RowMap) GetUint64(key string) uint64 { - res, _ := strconv.ParseUint(this.GetString(key), 10, 0) - return res -} - -func (this *RowMap) GetUint64D(key string, def uint64) uint64 { - res, err := strconv.ParseUint(this.GetString(key), 10, 0) - if err != nil { - return def - } - return uint64(res) -} - -func (this *RowMap) GetBool(key string) bool { - return this.GetInt(key) != 0 -} - -func (this *RowMap) GetTime(key string) time.Time { - if t, err := time.Parse(DateTimeFormat, this.GetString(key)); err == nil { - return t - } - return time.Time{} -} - -func validateQuery(query string, db *sql.DB) { - // dev purposes only. Remove this return to call query validator function. - return - - knownDBsMutex.RLock() - defer knownDBsMutex.RUnlock() - - if logger, exists := DB2logger[db]; exists && logger != nil { - logger.ValidateQuery((query)) - } -} - -// knownDBs is a DB cache by uri -var knownDBs map[string]*sql.DB = make(map[string]*sql.DB) -var knownDBsMutex = &sync.RWMutex{} - -type Logger interface { - OnError(context string, query string, err error) error - ValidateQuery(query string) -} - -// it is also protected by knownDBsMutex -var DB2logger map[*sql.DB]Logger = make(map[*sql.DB]Logger) - -// GetDB returns a DB instance based on uri. -// logger parameter is optional. If nil, internal logging will be used. -// bool result indicates whether the DB was returned from cache; err -func GetGenericDB(driverName, dataSourceName string, logger Logger) (*sql.DB, bool, error) { - knownDBsMutex.Lock() - defer func() { - knownDBsMutex.Unlock() - }() - - var exists bool - if _, exists = knownDBs[dataSourceName]; !exists { - if db, err := sql.Open(driverName, dataSourceName); err == nil { - knownDBs[dataSourceName] = db - } else { - return db, exists, err - } - } - db := knownDBs[dataSourceName] - DB2logger[db] = logger - return db, exists, nil -} - -// GetDB returns a MySQL DB instance based on uri. -// logger parameter is optional. If nil, internal logging will be used. -// bool result indicates whether the DB was returned from cache; err -func GetDB(mysql_uri string, logger Logger) (*sql.DB, bool, error) { - return GetGenericDB("mysql", mysql_uri, logger) -} - -// GetDB returns a SQLite DB instance based on DB file name. -// logger parameter is optional. If nil, internal logging will be used. -// bool result indicates whether the DB was returned from cache; err -func GetSQLiteDB(dbFile string, logger Logger) (*sql.DB, bool, error) { - return GetGenericDB("sqlite3", dbFile, logger) -} - -// RowToArray is a convenience function, typically not called directly, which maps a -// single read database row into a NullString -func RowToArray(rows *sql.Rows, columns []string) []CellData { - buff := make([]interface{}, len(columns)) - data := make([]CellData, len(columns)) - for i := range buff { - buff[i] = data[i].NullString() - } - rows.Scan(buff...) - return data -} - -// ScanRowsToArrays is a convenience function, typically not called directly, which maps rows -// already read from the databse into arrays of NullString -func ScanRowsToArrays(rows *sql.Rows, on_row func([]CellData) error) error { - columns, _ := rows.Columns() - for rows.Next() { - arr := RowToArray(rows, columns) - err := on_row(arr) - if err != nil { - return err - } - } - return nil -} - -func rowToMap(row []CellData, columns []string) map[string]CellData { - m := make(map[string]CellData) - for k, data_col := range row { - m[columns[k]] = data_col - } - return m -} - -// ScanRowsToMaps is a convenience function, typically not called directly, which maps rows -// already read from the databse into RowMap entries. -func ScanRowsToMaps(rows *sql.Rows, on_row func(RowMap) error) error { - columns, _ := rows.Columns() - err := ScanRowsToArrays(rows, func(arr []CellData) error { - m := rowToMap(arr, columns) - err := on_row(m) - if err != nil { - return err - } - return nil - }) - return err -} - -func logErrorInternal(context string, db *sql.DB, query string, err error) error { - // find logger registered by the client - knownDBsMutex.RLock() - defer knownDBsMutex.RUnlock() - - if logger, exists := DB2logger[db]; exists && logger != nil { - return logger.OnError(context, query, err) - } - - return log.Errore(err) -} - -// QueryRowsMap is a convenience function allowing querying a result set while poviding a callback -// function activated per read row. -func QueryRowsMap(db *sql.DB, query string, on_row func(RowMap) error, args ...interface{}) (err error) { - validateQuery(query, db) - defer func() { - if derr := recover(); derr != nil { - err = fmt.Errorf("QueryRowsMap unexpected error: %+v", derr) - } - }() - - var rows *sql.Rows - rows, err = db.Query(query, args...) - if rows != nil { - defer rows.Close() - } - if err != nil && err != sql.ErrNoRows { - return logErrorInternal("QueryRowsMap", db, query, err) - } - err = ScanRowsToMaps(rows, on_row) - return -} - -// queryResultData returns a raw array of rows for a given query, optionally reading and returning column names -func queryResultData(db *sql.DB, query string, retrieveColumns bool, args ...interface{}) (resultData ResultData, columns []string, err error) { - validateQuery(query, db) - defer func() { - if derr := recover(); derr != nil { - err = errors.New(fmt.Sprintf("QueryRowsMap unexpected error: %+v", derr)) - } - }() - - var rows *sql.Rows - rows, err = db.Query(query, args...) - defer rows.Close() - if err != nil && err != sql.ErrNoRows { - return EmptyResultData, columns, logErrorInternal("queryResultData", db, query, err) - } - if retrieveColumns { - // Don't pay if you don't want to - columns, _ = rows.Columns() - } - resultData = ResultData{} - err = ScanRowsToArrays(rows, func(rowData []CellData) error { - resultData = append(resultData, rowData) - return nil - }) - return resultData, columns, err -} - -// QueryResultData returns a raw array of rows -func QueryResultData(db *sql.DB, query string, args ...interface{}) (ResultData, error) { - resultData, _, err := queryResultData(db, query, false, args...) - return resultData, err -} - -// QueryResultDataNamed returns a raw array of rows, with column names -func QueryNamedResultData(db *sql.DB, query string, args ...interface{}) (NamedResultData, error) { - resultData, columns, err := queryResultData(db, query, true, args...) - return NamedResultData{Columns: columns, Data: resultData}, err -} - -// QueryRowsMapBuffered reads data from the database into a buffer, and only then applies the given function per row. -// This allows the application to take its time with processing the data, albeit consuming as much memory as required by -// the result set. -func QueryRowsMapBuffered(db *sql.DB, query string, on_row func(RowMap) error, args ...interface{}) error { - resultData, columns, err := queryResultData(db, query, true, args...) - if err != nil { - // Already logged - return err - } - for _, row := range resultData { - err = on_row(rowToMap(row, columns)) - if err != nil { - return err - } - } - return nil -} - -// ExecNoPrepare executes given query using given args on given DB, without using prepared statements. -func ExecNoPrepare(db *sql.DB, query string, args ...interface{}) (res sql.Result, err error) { - validateQuery(query, db) - defer func() { - if derr := recover(); derr != nil { - err = errors.New(fmt.Sprintf("ExecNoPrepare unexpected error: %+v", derr)) - } - }() - - res, err = db.Exec(query, args...) - if err != nil { - logErrorInternal("ExecNoPrepare", db, query, err) - } - return res, err -} - -// ExecQuery executes given query using given args on given DB. It will safele prepare, execute and close -// the statement. -func execInternal(silent bool, db *sql.DB, query string, args ...interface{}) (res sql.Result, err error) { - validateQuery(query, db) - defer func() { - if derr := recover(); derr != nil { - err = errors.New(fmt.Sprintf("execInternal unexpected error: %+v", derr)) - } - }() - var stmt *sql.Stmt - stmt, err = db.Prepare(query) - if err != nil { - return nil, err - } - defer stmt.Close() - res, err = stmt.Exec(args...) - if err != nil && !silent { - logErrorInternal("execInternal", db, query, err) - } - return res, err -} - -// Exec executes given query using given args on given DB. It will safele prepare, execute and close -// the statement. -func Exec(db *sql.DB, query string, args ...interface{}) (sql.Result, error) { - return execInternal(false, db, query, args...) -} - -// ExecSilently acts like Exec but does not report any error -func ExecSilently(db *sql.DB, query string, args ...interface{}) (sql.Result, error) { - return execInternal(true, db, query, args...) -} - -func InClauseStringValues(terms []string) string { - quoted := []string{} - for _, s := range terms { - quoted = append(quoted, fmt.Sprintf("'%s'", strings.Replace(s, ",", "''", -1))) - } - return strings.Join(quoted, ", ") -} - -// Convert variable length arguments into arguments array -func Args(args ...interface{}) []interface{} { - return args -} - -func NilIfZero(i int64) interface{} { - if i == 0 { - return nil - } - return i -} - -func ScanTable(db *sql.DB, tableName string) (NamedResultData, error) { - query := fmt.Sprintf("select * from %s", tableName) - return QueryNamedResultData(db, query) -} - -func WriteTable(db *sql.DB, tableName string, data NamedResultData) (err error) { - if len(data.Data) == 0 { - return nil - } - if len(data.Columns) == 0 { - return nil - } - placeholders := make([]string, len(data.Columns)) - for i := range placeholders { - placeholders[i] = "?" - } - query := fmt.Sprintf( - `replace into %s (%s) values (%s)`, - tableName, - strings.Join(data.Columns, ","), - strings.Join(placeholders, ","), - ) - for _, rowData := range data.Data { - if _, execErr := db.Exec(query, rowData.Args()...); execErr != nil { - err = execErr - } - } - return err -} diff --git a/vendor/github.com/openark/golib/tests/spec.go b/vendor/github.com/openark/golib/tests/spec.go deleted file mode 100644 index a52c7291a..000000000 --- a/vendor/github.com/openark/golib/tests/spec.go +++ /dev/null @@ -1,76 +0,0 @@ -package tests - -import ( - "testing" -) - -// Spec is an access point to test Expections -type Spec struct { - t *testing.T -} - -// S generates a spec. You will want to use it once in a test file, once in a test or once per each check -func S(t *testing.T) *Spec { - return &Spec{t: t} -} - -// ExpectNil expects given value to be nil, or errors -func (spec *Spec) ExpectNil(actual interface{}) { - if actual == nil { - return - } - spec.t.Errorf("Expected %+v to be nil", actual) -} - -// ExpectNotNil expects given value to be not nil, or errors -func (spec *Spec) ExpectNotNil(actual interface{}) { - if actual != nil { - return - } - spec.t.Errorf("Expected %+v to be not nil", actual) -} - -// ExpectEquals expects given values to be equal (comparison via `==`), or errors -func (spec *Spec) ExpectEquals(actual, value interface{}) { - if actual == value { - return - } - spec.t.Errorf("Expected:\n[[[%+v]]]\n- got:\n[[[%+v]]]", value, actual) -} - -// ExpectNotEquals expects given values to be nonequal (comparison via `==`), or errors -func (spec *Spec) ExpectNotEquals(actual, value interface{}) { - if !(actual == value) { - return - } - spec.t.Errorf("Expected not %+v", value) -} - -// ExpectEqualsAny expects given actual to equal (comparison via `==`) at least one of given values, or errors -func (spec *Spec) ExpectEqualsAny(actual interface{}, values ...interface{}) { - for _, value := range values { - if actual == value { - return - } - } - spec.t.Errorf("Expected %+v to equal any of given values", actual) -} - -// ExpectNotEqualsAny expects given actual to be nonequal (comparison via `==`)tp any of given values, or errors -func (spec *Spec) ExpectNotEqualsAny(actual interface{}, values ...interface{}) { - for _, value := range values { - if actual == value { - spec.t.Errorf("Expected not %+v", value) - } - } -} - -// ExpectFalse expects given values to be false, or errors -func (spec *Spec) ExpectFalse(actual interface{}) { - spec.ExpectEquals(actual, false) -} - -// ExpectTrue expects given values to be true, or errors -func (spec *Spec) ExpectTrue(actual interface{}) { - spec.ExpectEquals(actual, true) -} diff --git a/vendor/github.com/openark/golib/util/text.go b/vendor/github.com/openark/golib/util/text.go deleted file mode 100644 index 2b0ae9a7e..000000000 --- a/vendor/github.com/openark/golib/util/text.go +++ /dev/null @@ -1,103 +0,0 @@ -/* - Copyright 2015 Shlomi Noach. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package util - -import ( - "errors" - "fmt" - "regexp" - "strconv" - "strings" -) - -const ( - TabulateLeft = 0 - TabulateRight = 1 -) - -// ParseSimpleTime parses input in the format 7s, 55m, 3h, 31d, 4w (second, minute, hour, day, week) -// The time.ParseDuration() function should have done this, but it does not support "d" and "w" extensions. -func SimpleTimeToSeconds(simpleTime string) (int, error) { - if matched, _ := regexp.MatchString("^[0-9]+s$", simpleTime); matched { - i, _ := strconv.Atoi(simpleTime[0 : len(simpleTime)-1]) - return i, nil - } - if matched, _ := regexp.MatchString("^[0-9]+m$", simpleTime); matched { - i, _ := strconv.Atoi(simpleTime[0 : len(simpleTime)-1]) - return i * 60, nil - } - if matched, _ := regexp.MatchString("^[0-9]+h$", simpleTime); matched { - i, _ := strconv.Atoi(simpleTime[0 : len(simpleTime)-1]) - return i * 60 * 60, nil - } - if matched, _ := regexp.MatchString("^[0-9]+d$", simpleTime); matched { - i, _ := strconv.Atoi(simpleTime[0 : len(simpleTime)-1]) - return i * 60 * 60 * 24, nil - } - if matched, _ := regexp.MatchString("^[0-9]+w$", simpleTime); matched { - i, _ := strconv.Atoi(simpleTime[0 : len(simpleTime)-1]) - return i * 60 * 60 * 24 * 7, nil - } - return 0, errors.New(fmt.Sprintf("Cannot parse simple time: %s", simpleTime)) -} - -func Tabulate(lines []string, separator string, outputSeparator string, directionFlags ...int) (result []string) { - tokens := make([][]string, 0) - widths := make([][]int, 0) - countColumns := 0 - for _, line := range lines { - lineTokens := strings.Split(line, separator) - lineWidths := make([]int, len(lineTokens)) - for i := range lineTokens { - lineWidths[i] = len(lineTokens[i]) - } - tokens = append(tokens, lineTokens) - widths = append(widths, lineWidths) - if len(lineTokens) > countColumns { - countColumns = len(lineTokens) - } - } - columnWidths := make([]int, countColumns) - for _, lineTokens := range tokens { - for col, token := range lineTokens { - if len(token) > columnWidths[col] { - columnWidths[col] = len(token) - } - } - } - for _, lineTokens := range tokens { - resultRow := "" - for col := 0; col < countColumns; col++ { - token := "" - if col < len(lineTokens) { - token = lineTokens[col] - } - format := fmt.Sprintf("%%-%ds", columnWidths[col]) // format left - if col < len(directionFlags) && directionFlags[col] == TabulateRight { - format = fmt.Sprintf("%%%ds", columnWidths[col]) - } - formattedToken := fmt.Sprintf(format, token) - if col == 0 { - resultRow = formattedToken - } else { - resultRow = fmt.Sprintf("%s%s%s", resultRow, outputSeparator, formattedToken) - } - } - result = append(result, resultRow) - } - return result -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 5e5f54fbe..27a05f921 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -89,13 +89,6 @@ github.com/mitchellh/mapstructure # github.com/montanaflynn/stats v0.7.1 ## explicit; go 1.13 github.com/montanaflynn/stats -# github.com/openark/golib v0.0.0-20210531070646-355f37940af8 => ./go/golib -## explicit; go 1.18 -github.com/openark/golib/log -github.com/openark/golib/math -github.com/openark/golib/sqlutils -github.com/openark/golib/tests -github.com/openark/golib/util # github.com/outbrain/golib v0.0.0-20200503083229-2531e5dbcc71 ## explicit github.com/outbrain/golib/log @@ -143,6 +136,5 @@ gopkg.in/gcfg.v1/types ## explicit gopkg.in/warnings.v0 # github.com/hashicorp/raft => github.com/openark/raft v0.0.0-20170918052300-fba9f909f7fe -# github.com/openark/golib => ./go/golib # golang.org/x/text v0.3.0 => golang.org/x/text v0.3.8 # golang.org/x/text v0.3.7 => golang.org/x/text v0.3.8