ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Janady13/missionmatch / cmd/sync-tenant-identity/main.go

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/missionmatch / cmd/sync-tenant-identity/main.go
DateNot specified in source
RepositoryJanady13/missionmatch
Revision9bde0f9a74b89d01980fa658e5253acda7528d0c
Branchper-tenant-routing
Path or archive membercmd/sync-tenant-identity/main.go
Original SHA-256519aec843537de078d754411af08749f4756fa8c7eec73628b3be8501abfba52
Git blob SHAd8d80b2e2fed8e9f754ef4d1b892b43be0b0b32e
Reading-copy SHA-256519aec843537de078d754411af08749f4756fa8c7eec73628b3be8501abfba52

Original source ↗

Every recorded occurrence

These 3 records contain identical original source bytes. Their paths and revisions remain part of the archive.

Original recordBranch or archiveRevision / identifierOriginal location
Janady13/missionmatch / cmd/sync-tenant-identity/main.goper-tenant-routing9bde0f9a74b89d01980fa658e5253acda7528d0cOpen original
Janady13/missionmatch / cmd/sync-tenant-identity/main.godeploy-and-opsbdacd9d0b4d5998d25fc74bf4007f4c3ec538c7aOpen original
Janady13/missionmatch / cmd/sync-tenant-identity/main.goper-tenant-routing9bde0f9a74b89d01980fa658e5253acda7528d0cOpen original

Recovered source transcript

// Command sync-tenant-identity copies an organization and its users from the control plane into that // tenant's own database, so the tenant's business tables can reference its org and users. It is run at // onboarding (after provision-tenant creates the database and the directory row is registered) and again // whenever the org's users change (a new invite accepted). It is a migrator role operator tool and is // idempotent. // // Usage: // // sync-tenant-identity -control-dsn postgres://missionmatch_migrator:...@host/controlplane -org <uuid> package main import ( "context" "flag" "fmt" "log" "os" "github.com/google/uuid" "github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5/pgxpool" "github.com/missionworkforce/missionmatch/internal/platform/database" "github.com/missionworkforce/missionmatch/internal/platform/directory" "github.com/missionworkforce/missionmatch/internal/platform/identity" ) func main() { controlDSN := flag.String("control-dsn", os.Getenv("MM_MIGRATOR_DATABASE_URL"), "migrator DSN to the control plane database") orgStr := flag.String("org", "", "organization id to sync") flag.Parse() if *controlDSN == "" || *orgStr == "" { log.Fatal("sync-tenant-identity: -control-dsn (or MM_MIGRATOR_DATABASE_URL) and -org are required") } org, err := uuid.Parse(*orgStr) if err != nil { log.Fatalf("sync-tenant-identity: -org is not a uuid: %v", err) } ctx := context.Background() control, err := pgxpool.New(ctx, *controlDSN) if err != nil { log.Fatalf("sync-tenant-identity: control plane pool: %v", err) } defer control.Close() if err := database.AssertMigratorRole(ctx, control); err != nil { log.Fatalf("sync-tenant-identity: %v", err) } tc, err := directory.New(control).Lookup(ctx, org) if err != nil { log.Fatalf("sync-tenant-identity: %v", err) } tenantDSN := swapDB(*controlDSN, tc.DBName) tenant, err := pgxpool.New(ctx, tenantDSN) if err != nil { log.Fatalf("sync-tenant-identity: tenant pool: %v", err) } defer tenant.Close() n, err := identity.SeedTenant(ctx, control, tenant, org) if err != nil { log.Fatalf("sync-tenant-identity: %v", err) } log.Printf("sync-tenant-identity: seeded org %s and %d user(s) into tenant database %q", org, n, tc.DBName) } // swapDB reuses a migrator DSN and swaps only the database name (mirrors cmd/provision-tenant). func swapDB(dsn, name string) string { cfg, err := pgx.ParseConfig(dsn) if err != nil { return dsn } out := fmt.Sprintf("host=%s port=%d user=%s dbname=%s", cfg.Host, cfg.Port, cfg.User, name) if cfg.Password != "" { out += " password=" + cfg.Password } if cfg.TLSConfig == nil { out += " sslmode=disable" } return out }

Search equations, builds, manuscript text, and recovered sources.