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>
71 lines
1.8 KiB
Go
71 lines
1.8 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 (
|
|
"database/sql"
|
|
"database/sql/driver"
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
// NullTime represents a time.Time that may be NULL.
|
|
// NullTime implements the Scanner interface so
|
|
// it can be used as a scan destination:
|
|
//
|
|
// var nt NullTime
|
|
// err := db.QueryRow("SELECT time FROM foo WHERE id=?", id).Scan(&nt)
|
|
// ...
|
|
// if nt.Valid {
|
|
// // use nt.Time
|
|
// } else {
|
|
// // NULL value
|
|
// }
|
|
//
|
|
// # This NullTime implementation is not driver-specific
|
|
//
|
|
// Deprecated: NullTime doesn't honor the loc DSN parameter.
|
|
// NullTime.Scan interprets a time as UTC, not the loc DSN parameter.
|
|
// Use sql.NullTime instead.
|
|
type NullTime sql.NullTime
|
|
|
|
// Scan implements the Scanner interface.
|
|
// The value type must be time.Time or string / []byte (formatted time-string),
|
|
// otherwise Scan fails.
|
|
func (nt *NullTime) Scan(value interface{}) (err error) {
|
|
if value == nil {
|
|
nt.Time, nt.Valid = time.Time{}, false
|
|
return
|
|
}
|
|
|
|
switch v := value.(type) {
|
|
case time.Time:
|
|
nt.Time, nt.Valid = v, true
|
|
return
|
|
case []byte:
|
|
nt.Time, err = parseDateTime(v, time.UTC)
|
|
nt.Valid = (err == nil)
|
|
return
|
|
case string:
|
|
nt.Time, err = parseDateTime([]byte(v), time.UTC)
|
|
nt.Valid = (err == nil)
|
|
return
|
|
}
|
|
|
|
nt.Valid = false
|
|
return fmt.Errorf("Can't convert %T to time.Time", value)
|
|
}
|
|
|
|
// Value implements the driver Valuer interface.
|
|
func (nt NullTime) Value() (driver.Value, error) {
|
|
if !nt.Valid {
|
|
return nil, nil
|
|
}
|
|
return nt.Time, nil
|
|
}
|