mirror of
https://github.com/gravitational/teleport.git
synced 2026-10-25 18:59:51 +08:00
* Add periodic import of database objects from supported databases. A single implementation is included: for Postgres, along with necessary changes. Also refactors SQLAdminClient interface to accept cert expiry instead of pulling that information from `tlsca.Identity`. * fix logging, imports * add missing license * review feedback - several minor changes - apply import rules for all registered object fetchers using wrapper type - refactor DAC to use object fetcher - adjust tests * add comment and missing log call * support config overrides through unstable env vars, including disabling the service entirely * refactoring and minor changes - be more specific about required API for ObjectFetcherConfig - measure scan time - bump default scan interval - call StopImporter from stopDatabase to fix issue with dynamic db resource updates - add comments * Refactor `connectAsAdmin`, add `withDefaultDatabase()` method for clarity of implementation. * Reduce surface area for fetcher config * make the not-implemented case less noisy by skipping the error * lint fix * decrease verbosity of reporting for unsupported configurations * make `reason` field private * move `unregisterObjectFetcher` to tests * avoid exceedingly long lines with log calls * correct formatting leftover from slog conversion * tighten logic around disabled importer if the scan interval is zero or less, the importer becomes disabled, which avoids panic from interval.New(). add some tests and comments for clarity. * drop unused method
41 lines
1.4 KiB
Go
41 lines
1.4 KiB
Go
// Teleport
|
|
// Copyright (C) 2024 Gravitational, Inc.
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
package objects
|
|
|
|
import "errors"
|
|
|
|
// ErrFetcherDisabled is a custom error that can be returned from fetcher constructor that will be reported with lower severity.
|
|
type ErrFetcherDisabled struct {
|
|
reason string
|
|
}
|
|
|
|
func (e ErrFetcherDisabled) Error() string {
|
|
return e.reason
|
|
}
|
|
|
|
// NewErrFetcherDisabled returns a new instance of ErrFetcherDisabled error.
|
|
func NewErrFetcherDisabled(reason string) *ErrFetcherDisabled {
|
|
return &ErrFetcherDisabled{reason: reason}
|
|
}
|
|
|
|
// IsErrFetcherDisabled returns true if the error is ErrFetcherDisabled.
|
|
func IsErrFetcherDisabled(err error) (bool, string) {
|
|
other := &ErrFetcherDisabled{}
|
|
matched := errors.As(err, &other)
|
|
return matched, other.reason
|
|
}
|