OpenID Connect (OIDC) identity and OAuth 2.0 provider with pluggable connectors
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

150 lines
4.9 KiB

// Code generated by ent, DO NOT EDIT.
package db
import (
"encoding/json"
"fmt"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/dexidp/dex/storage/ent/db/connector"
)
// Connector is the model entity for the Connector schema.
type Connector struct {
config `json:"-"`
// ID of the ent.
ID string `json:"id,omitempty"`
// Type holds the value of the "type" field.
Type string `json:"type,omitempty"`
// Name holds the value of the "name" field.
Name string `json:"name,omitempty"`
// ResourceVersion holds the value of the "resource_version" field.
ResourceVersion string `json:"resource_version,omitempty"`
// Config holds the value of the "config" field.
Config []byte `json:"config,omitempty"`
// GrantTypes holds the value of the "grant_types" field.
GrantTypes []string `json:"grant_types,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Connector) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case connector.FieldConfig, connector.FieldGrantTypes:
values[i] = new([]byte)
case connector.FieldID, connector.FieldType, connector.FieldName, connector.FieldResourceVersion:
values[i] = new(sql.NullString)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Connector fields.
func (_m *Connector) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case connector.FieldID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field id", values[i])
} else if value.Valid {
_m.ID = value.String
}
case connector.FieldType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field type", values[i])
} else if value.Valid {
_m.Type = value.String
}
case connector.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
_m.Name = value.String
}
case connector.FieldResourceVersion:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field resource_version", values[i])
} else if value.Valid {
_m.ResourceVersion = value.String
}
case connector.FieldConfig:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field config", values[i])
} else if value != nil {
_m.Config = *value
}
case connector.FieldGrantTypes:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field grant_types", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &_m.GrantTypes); err != nil {
return fmt.Errorf("unmarshal field grant_types: %w", err)
}
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Connector.
// This includes values selected through modifiers, order, etc.
func (_m *Connector) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this Connector.
// Note that you need to call Connector.Unwrap() before calling this method if this Connector
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *Connector) Update() *ConnectorUpdateOne {
return NewConnectorClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the Connector entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *Connector) Unwrap() *Connector {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("db: Connector is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *Connector) String() string {
var builder strings.Builder
builder.WriteString("Connector(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("type=")
builder.WriteString(_m.Type)
builder.WriteString(", ")
builder.WriteString("name=")
builder.WriteString(_m.Name)
builder.WriteString(", ")
builder.WriteString("resource_version=")
builder.WriteString(_m.ResourceVersion)
builder.WriteString(", ")
builder.WriteString("config=")
builder.WriteString(fmt.Sprintf("%v", _m.Config))
builder.WriteString(", ")
builder.WriteString("grant_types=")
builder.WriteString(fmt.Sprintf("%v", _m.GrantTypes))
builder.WriteByte(')')
return builder.String()
}
// Connectors is a parsable slice of Connector.
type Connectors []*Connector