devops tenant api

Signed-off-by: runzexia <runzexia@yunify.com>
This commit is contained in:
runzexia
2019-04-23 20:47:47 +08:00
committed by zryfish
parent 78f2dab18c
commit 5a6f51d775
143 changed files with 19533 additions and 341 deletions

24
vendor/github.com/gocraft/dbr/dialect/dialect.go generated vendored Normal file
View File

@@ -0,0 +1,24 @@
package dialect
import "strings"
var (
// MySQL dialect
MySQL = mysql{}
// PostgreSQL dialect
PostgreSQL = postgreSQL{}
// SQLite3 dialect
SQLite3 = sqlite3{}
)
const (
timeFormat = "2006-01-02 15:04:05.000000"
)
func quoteIdent(s, quote string) string {
part := strings.SplitN(s, ".", 2)
if len(part) == 2 {
return quoteIdent(part[0], quote) + "." + quoteIdent(part[1], quote)
}
return quote + s + quote
}

66
vendor/github.com/gocraft/dbr/dialect/mysql.go generated vendored Normal file
View File

@@ -0,0 +1,66 @@
package dialect
import (
"bytes"
"fmt"
"time"
)
type mysql struct{}
func (d mysql) QuoteIdent(s string) string {
return quoteIdent(s, "`")
}
func (d mysql) EncodeString(s string) string {
buf := new(bytes.Buffer)
buf.WriteRune('\'')
// https://dev.mysql.com/doc/refman/5.7/en/string-literals.html
for i := 0; i < len(s); i++ {
switch s[i] {
case 0:
buf.WriteString(`\0`)
case '\'':
buf.WriteString(`\'`)
case '"':
buf.WriteString(`\"`)
case '\b':
buf.WriteString(`\b`)
case '\n':
buf.WriteString(`\n`)
case '\r':
buf.WriteString(`\r`)
case '\t':
buf.WriteString(`\t`)
case 26:
buf.WriteString(`\Z`)
case '\\':
buf.WriteString(`\\`)
default:
buf.WriteByte(s[i])
}
}
buf.WriteRune('\'')
return buf.String()
}
func (d mysql) EncodeBool(b bool) string {
if b {
return "1"
}
return "0"
}
func (d mysql) EncodeTime(t time.Time) string {
return `'` + t.UTC().Format(timeFormat) + `'`
}
func (d mysql) EncodeBytes(b []byte) string {
return fmt.Sprintf(`0x%x`, b)
}
func (d mysql) Placeholder(_ int) string {
return "?"
}

37
vendor/github.com/gocraft/dbr/dialect/postgresql.go generated vendored Normal file
View File

@@ -0,0 +1,37 @@
package dialect
import (
"fmt"
"strings"
"time"
)
type postgreSQL struct{}
func (d postgreSQL) QuoteIdent(s string) string {
return quoteIdent(s, `"`)
}
func (d postgreSQL) EncodeString(s string) string {
// http://www.postgresql.org/docs/9.2/static/sql-syntax-lexical.html
return `'` + strings.Replace(s, `'`, `''`, -1) + `'`
}
func (d postgreSQL) EncodeBool(b bool) string {
if b {
return "TRUE"
}
return "FALSE"
}
func (d postgreSQL) EncodeTime(t time.Time) string {
return MySQL.EncodeTime(t)
}
func (d postgreSQL) EncodeBytes(b []byte) string {
return fmt.Sprintf(`E'\\x%x'`, b)
}
func (d postgreSQL) Placeholder(n int) string {
return fmt.Sprintf("$%d", n+1)
}

40
vendor/github.com/gocraft/dbr/dialect/sqlite3.go generated vendored Normal file
View File

@@ -0,0 +1,40 @@
package dialect
import (
"fmt"
"strings"
"time"
)
type sqlite3 struct{}
func (d sqlite3) QuoteIdent(s string) string {
return quoteIdent(s, `"`)
}
func (d sqlite3) EncodeString(s string) string {
// https://www.sqlite.org/faq.html
return `'` + strings.Replace(s, `'`, `''`, -1) + `'`
}
func (d sqlite3) EncodeBool(b bool) string {
// https://www.sqlite.org/lang_expr.html
if b {
return "1"
}
return "0"
}
func (d sqlite3) EncodeTime(t time.Time) string {
// https://www.sqlite.org/lang_datefunc.html
return MySQL.EncodeTime(t)
}
func (d sqlite3) EncodeBytes(b []byte) string {
// https://www.sqlite.org/lang_expr.html
return fmt.Sprintf(`X'%x'`, b)
}
func (d sqlite3) Placeholder(_ int) string {
return "?"
}