diff options
| author | Melodi <62381002+Melodi17@users.noreply.github.com> | 2026-09-06 09:02:31 +1000 |
|---|---|---|
| committer | Melodi <62381002+Melodi17@users.noreply.github.com> | 2026-09-06 09:02:31 +1000 |
| commit | a9bc03fb01b5d1ac41bf5592f384d22df5425aa4 (patch) | |
| tree | 16ae13e19d2a3cd7488202c30790d09557559d70 /src/marlin.web/Data | |
| parent | c00992ffad24212c4398736efd6d707d4cb0cc0d (diff) | |
feat: vcs and secret management support
Diffstat (limited to 'src/marlin.web/Data')
| -rw-r--r-- | src/marlin.web/Data/ApplicationDbContext.cs | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/marlin.web/Data/ApplicationDbContext.cs b/src/marlin.web/Data/ApplicationDbContext.cs index 41ec4bc..2e05835 100644 --- a/src/marlin.web/Data/ApplicationDbContext.cs +++ b/src/marlin.web/Data/ApplicationDbContext.cs @@ -1,15 +1,31 @@ namespace marlin.web.Data; using System.Linq.Expressions; +using System.Text.Json; using core; using core.models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Models; + +// user-based session grant +// agent id/token grant +// agent job claim session grant +// service grant +public interface IActiveGrant +{ + bool CanAccessSource(Guid sourceId); +} public class ApplicationDbContext : DbContext { public DbSet<VersionControlSource> Sources => this.Set<VersionControlSource>(); + public DbSet<VersionControlledBranch> SourceBranches => this.Set<VersionControlledBranch>(); + public DbSet<VersionControlledCommit> SourceCommits => this.Set<VersionControlledCommit>(); + public DbSet<VersionControlledBlob> SourceBlobs => this.Set<VersionControlledBlob>(); + public DbSet<VersionControlSecret> Secrets => this.Set<VersionControlSecret>(); public DbSet<Job> Jobs => this.Set<Job>(); + public DbSet<Agent> Agents => this.Set<Agent>(); public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } @@ -18,7 +34,21 @@ public class ApplicationDbContext : DbContext { modelBuilder .Entity<Agent>() - .OwnsOne(p => p.Capabilities, b => b.ToJson()); + .Property(p => p.Capabilities) + .HasConversion( + v => JsonSerializer.Serialize(v, (JsonSerializerOptions?)null), + v => JsonSerializer.Deserialize<CapabilitySet>(v, (JsonSerializerOptions?)null)!); + + modelBuilder + .Entity<VersionControlledCommit>() + .HasAlternateKey(x => new { x.SourceId, x.Hash }); + + modelBuilder + .Entity<VersionControlSecret>() + .Property(p => p.Content) + .HasConversion( + v => JsonSerializer.Serialize(v, (JsonSerializerOptions?)null), + v => JsonSerializer.Deserialize<Dictionary<string, string>>(v, (JsonSerializerOptions?)null)!); base.OnModelCreating(modelBuilder); } |
