checkIDPOrgSync inspects the server flags and the runtime config. It's based on the OrganizationSyncEnabled function from enterprise/coderd/enidpsync/organizations.go. It has one distinct difference: it doesn't check if the license entitles to the feature, it only checks if the feature is configured
(ctx context.Context, db database.Store, values *codersdk.DeploymentValues)
| 395 | // |
| 396 | // See https://github.com/coder/coder/pull/16323 for more details. |
| 397 | func checkIDPOrgSync(ctx context.Context, db database.Store, values *codersdk.DeploymentValues) (bool, error) { |
| 398 | // key based on https://github.com/coder/coder/blob/5c6578d84e2940b9cfd04798c45e7c8042c3fe0e/coderd/idpsync/idpsync.go#L168 |
| 399 | syncConfigRaw, err := db.GetRuntimeConfig(ctx, "organization-sync-settings") |
| 400 | if err != nil { |
| 401 | if errors.Is(err, sql.ErrNoRows) { |
| 402 | // If the runtime config is not set, we check if the deployment config |
| 403 | // has the organization field set. |
| 404 | return values != nil && values.OIDC.OrganizationField != "", nil |
| 405 | } |
| 406 | return false, xerrors.Errorf("get runtime config: %w", err) |
| 407 | } |
| 408 | syncConfig := idpOrgSyncConfig{} |
| 409 | if err := json.Unmarshal([]byte(syncConfigRaw), &syncConfig); err != nil { |
| 410 | return false, xerrors.Errorf("unmarshal runtime config: %w", err) |
| 411 | } |
| 412 | return syncConfig.Field != "", nil |
| 413 | } |
| 414 | |
| 415 | // createSnapshot collects a full snapshot from the database. |
| 416 | func (r *remoteReporter) createSnapshot() (*Snapshot, error) { |
no test coverage detected