Extra specs is an opaque valid JSON that can be set on a pool and which will be passed along to the provider as part of instance bootstrap params. This field is meant to allow operators to send extra configuration values to external or built-in providers. The extra specs is not interpreted or useful in any way to garm itself, but it may be useful to the provider which interacts with the IaaS. The extra specs are not meant to be used for secrets. Adding sensitive information to this field is highly discouraged. This field is meant as a means to add fine tuning knobs to the providers, on a per pool basis. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
77 lines
2.9 KiB
Go
77 lines
2.9 KiB
Go
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
|
|
//
|
|
// Copyright 2013 The Go-MySQL-Driver Authors. All rights reserved.
|
|
//
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
// You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package mysql
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
// Various errors the driver might return. Can change between driver versions.
|
|
var (
|
|
ErrInvalidConn = errors.New("invalid connection")
|
|
ErrMalformPkt = errors.New("malformed packet")
|
|
ErrNoTLS = errors.New("TLS requested but server does not support TLS")
|
|
ErrCleartextPassword = errors.New("this user requires clear text authentication. If you still want to use it, please add 'allowCleartextPasswords=1' to your DSN")
|
|
ErrNativePassword = errors.New("this user requires mysql native password authentication.")
|
|
ErrOldPassword = errors.New("this user requires old password authentication. If you still want to use it, please add 'allowOldPasswords=1' to your DSN. See also https://github.com/go-sql-driver/mysql/wiki/old_passwords")
|
|
ErrUnknownPlugin = errors.New("this authentication plugin is not supported")
|
|
ErrOldProtocol = errors.New("MySQL server does not support required protocol 41+")
|
|
ErrPktSync = errors.New("commands out of sync. You can't run this command now")
|
|
ErrPktSyncMul = errors.New("commands out of sync. Did you run multiple statements at once?")
|
|
ErrPktTooLarge = errors.New("packet for query is too large. Try adjusting the 'max_allowed_packet' variable on the server")
|
|
ErrBusyBuffer = errors.New("busy buffer")
|
|
|
|
// errBadConnNoWrite is used for connection errors where nothing was sent to the database yet.
|
|
// If this happens first in a function starting a database interaction, it should be replaced by driver.ErrBadConn
|
|
// to trigger a resend.
|
|
// See https://github.com/go-sql-driver/mysql/pull/302
|
|
errBadConnNoWrite = errors.New("bad connection")
|
|
)
|
|
|
|
var errLog = Logger(log.New(os.Stderr, "[mysql] ", log.Ldate|log.Ltime|log.Lshortfile))
|
|
|
|
// Logger is used to log critical error messages.
|
|
type Logger interface {
|
|
Print(v ...interface{})
|
|
}
|
|
|
|
// SetLogger is used to set the logger for critical errors.
|
|
// The initial logger is os.Stderr.
|
|
func SetLogger(logger Logger) error {
|
|
if logger == nil {
|
|
return errors.New("logger is nil")
|
|
}
|
|
errLog = logger
|
|
return nil
|
|
}
|
|
|
|
// MySQLError is an error type which represents a single MySQL error
|
|
type MySQLError struct {
|
|
Number uint16
|
|
SQLState [5]byte
|
|
Message string
|
|
}
|
|
|
|
func (me *MySQLError) Error() string {
|
|
if me.SQLState != [5]byte{} {
|
|
return fmt.Sprintf("Error %d (%s): %s", me.Number, me.SQLState, me.Message)
|
|
}
|
|
|
|
return fmt.Sprintf("Error %d: %s", me.Number, me.Message)
|
|
}
|
|
|
|
func (me *MySQLError) Is(err error) bool {
|
|
if merr, ok := err.(*MySQLError); ok {
|
|
return merr.Number == me.Number
|
|
}
|
|
return false
|
|
}
|