NewPostgresOfflineStore creates a connection to a postgres database and initializes a table to track currently active Resource tables.
(config SQLOfflineStoreConfig)
| 78 | // NewPostgresOfflineStore creates a connection to a postgres database |
| 79 | // and initializes a table to track currently active Resource tables. |
| 80 | func NewSQLOfflineStore(config SQLOfflineStoreConfig) (*sqlOfflineStore, error) { |
| 81 | url := config.ConnectionURL |
| 82 | db, err := sql.Open(config.Driver, url) |
| 83 | if err != nil { |
| 84 | return nil, NewProviderError(Connection, config.ProviderType, ClientInitialization, err.Error()) |
| 85 | } |
| 86 | |
| 87 | return &sqlOfflineStore{ |
| 88 | db: db, |
| 89 | parent: config, |
| 90 | query: config.QueryImpl, |
| 91 | BaseProvider: BaseProvider{ |
| 92 | ProviderType: config.ProviderType, |
| 93 | ProviderConfig: config.Config, |
| 94 | }, |
| 95 | }, nil |
| 96 | } |
| 97 | |
| 98 | func checkName(id ResourceID) error { |
| 99 | if strings.Contains(id.Name, "__") || strings.Contains(id.Variant, "__") { |
no test coverage detected