Skip to content

Commit

Permalink
feat: migrate to tag-based images
Browse files Browse the repository at this point in the history
  • Loading branch information
kirinnee committed Nov 11, 2023
1 parent 04bed77 commit 7b3e966
Show file tree
Hide file tree
Showing 24 changed files with 849 additions and 73 deletions.
716 changes: 716 additions & 0 deletions App/Migrations/20231111121538_MigrateToTagFromSha.Designer.cs

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions App/Migrations/20231111121538_MigrateToTagFromSha.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace App.Migrations
{
/// <inheritdoc />
public partial class MigrateToTagFromSha : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "TemplateDockerSha",
table: "TemplateVersions",
newName: "TemplateDockerTag");

migrationBuilder.RenameColumn(
name: "BlobDockerSha",
table: "TemplateVersions",
newName: "BlobDockerTag");

migrationBuilder.RenameColumn(
name: "DockerSha",
table: "ProcessorVersions",
newName: "DockerTag");

migrationBuilder.RenameColumn(
name: "DockerSha",
table: "PluginVersions",
newName: "DockerTag");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "TemplateDockerTag",
table: "TemplateVersions",
newName: "TemplateDockerSha");

migrationBuilder.RenameColumn(
name: "BlobDockerTag",
table: "TemplateVersions",
newName: "BlobDockerSha");

migrationBuilder.RenameColumn(
name: "DockerTag",
table: "ProcessorVersions",
newName: "DockerSha");

migrationBuilder.RenameColumn(
name: "DockerTag",
table: "PluginVersions",
newName: "DockerSha");
}
}
}
8 changes: 4 additions & 4 deletions App/Migrations/MainDbContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.IsRequired()
.HasColumnType("text");

b.Property<string>("DockerSha")
b.Property<string>("DockerTag")
.IsRequired()
.HasColumnType("text");

Expand Down Expand Up @@ -243,7 +243,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.IsRequired()
.HasColumnType("text");

b.Property<string>("DockerSha")
b.Property<string>("DockerTag")
.IsRequired()
.HasColumnType("text");

Expand Down Expand Up @@ -398,7 +398,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.IsRequired()
.HasColumnType("text");

b.Property<string>("BlobDockerSha")
b.Property<string>("BlobDockerTag")
.IsRequired()
.HasColumnType("text");

Expand All @@ -413,7 +413,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.IsRequired()
.HasColumnType("text");

b.Property<string>("TemplateDockerSha")
b.Property<string>("TemplateDockerTag")
.IsRequired()
.HasColumnType("text");

Expand Down
6 changes: 3 additions & 3 deletions App/Modules/Cyan/API/V1/Mappers/PluginMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static (PluginRecord, PluginMetadata, PluginVersionRecord, PluginVersionP
Readme = req.Readme
},
new PluginVersionRecord { Description = req.Description, },
new PluginVersionProperty { DockerReference = req.DockerReference, DockerSha = req.DockerSha, }
new PluginVersionProperty { DockerReference = req.DockerReference, DockerTag = req.DockerTag, }
);

public static (PluginRecord, PluginMetadata) ToDomain(this CreatePluginReq req) =>
Expand Down Expand Up @@ -70,7 +70,7 @@ public static PluginResp ToResp(this Plugin plugin) =>
public static class PluginVersionMapper
{
public static (PluginVersionProperty, PluginVersionRecord) ToDomain(this CreatePluginVersionReq req) =>
(new PluginVersionProperty { DockerReference = req.DockerReference, DockerSha = req.DockerSha },
(new PluginVersionProperty { DockerReference = req.DockerReference, DockerTag = req.DockerTag },
new PluginVersionRecord { Description = req.Description });

public static PluginVersionRecord ToDomain(this UpdatePluginVersionReq req) =>
Expand All @@ -82,7 +82,7 @@ public static PluginVersionSearch ToDomain(this SearchPluginVersionQuery query)
public static PluginVersionPrincipalResp ToResp(this PluginVersionPrincipal principal) =>
new(principal.Id, principal.Version, principal.CreatedAt,
principal.Record.Description, principal.Property.DockerReference,
principal.Property.DockerSha);
principal.Property.DockerTag);

public static PluginVersionResp ToResp(this PluginVersion version) =>
new(version.Principal.ToResp(), version.PluginPrincipal.ToResp());
Expand Down
16 changes: 6 additions & 10 deletions App/Modules/Cyan/API/V1/Mappers/ProcessorMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static (ProcessorRecord, ProcessorMetadata, ProcessorVersionRecord, Proce
Readme = req.Readme
},
new ProcessorVersionRecord { Description = req.Description, },
new ProcessorVersionProperty { DockerReference = req.DockerReference, DockerSha = req.DockerSha, }
new ProcessorVersionProperty { DockerReference = req.DockerReference, DockerTag = req.DockerTag, }
);

public static (ProcessorRecord, ProcessorMetadata) ToDomain(this CreateProcessorReq req) =>
Expand Down Expand Up @@ -70,23 +70,19 @@ public static ProcessorResp ToResp(this Processor processor) =>
public static class ProcessorVersionMapper
{
public static (ProcessorVersionProperty, ProcessorVersionRecord) ToDomain(this CreateProcessorVersionReq req) =>
(new ProcessorVersionProperty { DockerReference = req.DockerReference, DockerSha = req.DockerSha },
(new ProcessorVersionProperty { DockerReference = req.DockerReference, DockerTag = req.DockerTag },
new ProcessorVersionRecord { Description = req.Description });

public static ProcessorVersionRecord ToDomain(this UpdateProcessorVersionReq req) => new() { Description = req.Description };
public static ProcessorVersionRecord ToDomain(this UpdateProcessorVersionReq req) =>
new() { Description = req.Description };

public static ProcessorVersionSearch ToDomain(this SearchProcessorVersionQuery query) =>
new()
{
Search = query.Search,
Limit = query.Limit ?? 20,
Skip = query.Skip ?? 0,
};
new() { Search = query.Search, Limit = query.Limit ?? 20, Skip = query.Skip ?? 0, };

public static ProcessorVersionPrincipalResp ToResp(this ProcessorVersionPrincipal principal) =>
new(principal.Id, principal.Version, principal.CreatedAt,
principal.Record.Description, principal.Property.DockerReference,
principal.Property.DockerSha);
principal.Property.DockerTag);

public static ProcessorVersionResp ToResp(this ProcessorVersion version) =>
new(version.Principal.ToResp(), version.ProcessorPrincipal.ToResp());
Expand Down
15 changes: 8 additions & 7 deletions App/Modules/Cyan/API/V1/Mappers/TemplateMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public static (TemplateRecord, TemplateMetadata, TemplateVersionRecord, Template
new TemplateVersionProperty
{
BlobDockerReference = req.BlobDockerReference,
BlobDockerSha = req.BlobDockerSha,
BlobDockerTag = req.BlobDockerTag,
TemplateDockerReference = req.TemplateDockerReference,
TemplateDockerSha = req.TemplateDockerSha,
TemplateDockerTag = req.TemplateDockerTag,
}
);

Expand Down Expand Up @@ -82,9 +82,9 @@ public static TemplateVersionProperty ToProperty(this CreateTemplateVersionReq r
new()
{
BlobDockerReference = req.BlobDockerReference,
BlobDockerSha = req.BlobDockerSha,
BlobDockerTag = req.BlobDockerTag,
TemplateDockerReference = req.TemplateDockerReference,
TemplateDockerSha = req.TemplateDockerSha
TemplateDockerTag = req.TemplateDockerTag
};

public static TemplateVersionRecord ToDomain(this UpdateTemplateVersionReq req) =>
Expand All @@ -93,16 +93,17 @@ public static TemplateVersionRecord ToDomain(this UpdateTemplateVersionReq req)
public static TemplateVersionSearch ToDomain(this SearchTemplateVersionQuery query) =>
new() { Search = query.Search, Limit = query.Limit ?? 20, Skip = query.Skip ?? 0, };

public static PluginVersionRef ToDomain(this PluginReferenceReq req) => new(req.Username, req.Name, req.Version == 0 ? null : req.Version);
public static PluginVersionRef ToDomain(this PluginReferenceReq req) =>
new(req.Username, req.Name, req.Version == 0 ? null : req.Version);

public static ProcessorVersionRef ToDomain(this ProcessorReferenceReq req) =>
new(req.Username, req.Name, req.Version == 0 ? null : req.Version);

public static TemplateVersionPrincipalResp ToResp(this TemplateVersionPrincipal principal) =>
new(principal.Id, principal.Version, principal.CreatedAt,
principal.Record.Description, principal.Property.BlobDockerReference,
principal.Property.BlobDockerSha, principal.Property.TemplateDockerReference,
principal.Property.TemplateDockerSha);
principal.Property.BlobDockerTag, principal.Property.TemplateDockerReference,
principal.Property.TemplateDockerTag);

public static TemplateVersionResp ToResp(this TemplateVersion version) =>
new(
Expand Down
6 changes: 3 additions & 3 deletions App/Modules/Cyan/API/V1/Models/PluginVersionModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace App.Modules.Cyan.API.V1.Models;
public record SearchPluginVersionQuery(string? Search, int? Limit, int? Skip);

public record CreatePluginVersionReq(
string Description, string DockerReference, string DockerSha);
string Description, string DockerReference, string DockerTag);

public record UpdatePluginVersionReq(string Description);

Expand All @@ -18,12 +18,12 @@ public record PushPluginReq(

string VersionDescription,
string DockerReference,
string DockerSha
string DockerTag
);

public record PluginVersionPrincipalResp(
Guid Id, ulong Version, DateTime CreatedAt,
string Description, string DockerReference, string DockerSha);
string Description, string DockerReference, string DockerTag);

public record PluginVersionResp(
PluginVersionPrincipalResp Principal,
Expand Down
6 changes: 3 additions & 3 deletions App/Modules/Cyan/API/V1/Models/ProcessorVersionModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace App.Modules.Cyan.API.V1.Models;
public record SearchProcessorVersionQuery(string? Search, int? Limit, int? Skip);

public record CreateProcessorVersionReq(
string Description, string DockerReference, string DockerSha);
string Description, string DockerReference, string DockerTag);

public record UpdateProcessorVersionReq(string Description);

Expand All @@ -18,12 +18,12 @@ public record PushProcessorReq(

string VersionDescription,
string DockerReference,
string DockerSha
string DockerTag
);

public record ProcessorVersionPrincipalResp(
Guid Id, ulong Version, DateTime CreatedAt,
string Description, string DockerReference, string DockerSha);
string Description, string DockerReference, string DockerTag);

public record ProcessorVersionResp(
ProcessorVersionPrincipalResp Principal,
Expand Down
13 changes: 6 additions & 7 deletions App/Modules/Cyan/API/V1/Models/TemplateVersionModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ public record SearchTemplateVersionQuery(string? Search, int? Limit, int? Skip);
public record CreateTemplateVersionReq(
string Description,
string BlobDockerReference,
string BlobDockerSha,
string BlobDockerTag,
string TemplateDockerReference,
string TemplateDockerSha,
string TemplateDockerTag,
PluginReferenceReq[] Plugins,
ProcessorReferenceReq[] Processors
);
Expand All @@ -20,12 +20,11 @@ public record PushTemplateReq(
string[] Tags,
string Description,
string Readme,

string VersionDescription,
string BlobDockerReference,
string BlobDockerSha,
string BlobDockerTag,
string TemplateDockerReference,
string TemplateDockerSha,
string TemplateDockerTag,
PluginReferenceReq[] Plugins,
ProcessorReferenceReq[] Processors
);
Expand All @@ -39,8 +38,8 @@ public record UpdateTemplateVersionReq(string Description);
public record TemplateVersionPrincipalResp(
Guid Id, ulong Version, DateTime CreatedAt,
string Description,
string BlobDockerReference, string BlobDockerSha,
string TemplateDockerReference, string TemplateDockerSha
string BlobDockerReference, string BlobDockerTag,
string TemplateDockerReference, string TemplateDockerTag
);

public record TemplateVersionResp(
Expand Down
8 changes: 4 additions & 4 deletions App/Modules/Cyan/API/V1/Validators/PluginVersionValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public CreatePluginVersionReqValidator()
.DescriptionValid();
this.RuleFor(x => x.DockerReference)
.DockerReferenceValid();
this.RuleFor(x => x.DockerSha)
.ShaValid();
this.RuleFor(x => x.DockerTag)
.TagValid();
}
}

Expand Down Expand Up @@ -61,7 +61,7 @@ public PushPluginReqValidator()
.DescriptionValid();
this.RuleFor(x => x.DockerReference)
.DockerReferenceValid();
this.RuleFor(x => x.DockerSha)
.ShaValid();
this.RuleFor(x => x.DockerTag)
.TagValid();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public CreateProcessorVersionReqValidator()
.DescriptionValid();
this.RuleFor(x => x.DockerReference)
.DockerReferenceValid();
this.RuleFor(x => x.DockerSha)
.ShaValid();
this.RuleFor(x => x.DockerTag)
.TagValid();
}
}

Expand Down Expand Up @@ -61,7 +61,7 @@ public PushProcessorReqValidator()
.DescriptionValid();
this.RuleFor(x => x.DockerReference)
.DockerReferenceValid();
this.RuleFor(x => x.DockerSha)
.ShaValid();
this.RuleFor(x => x.DockerTag)
.TagValid();
}
}
16 changes: 8 additions & 8 deletions App/Modules/Cyan/API/V1/Validators/TemplateVersionValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public CreateTemplateVersionReqValidator()
.DescriptionValid();
this.RuleFor(x => x.BlobDockerReference)
.DockerReferenceValid();
this.RuleFor(x => x.BlobDockerSha)
.ShaValid();
this.RuleFor(x => x.BlobDockerTag)
.TagValid();
this.RuleFor(x => x.TemplateDockerReference)
.DockerReferenceValid();
this.RuleFor(x => x.TemplateDockerSha)
.ShaValid();
this.RuleFor(x => x.TemplateDockerTag)
.TagValid();
}
}

Expand Down Expand Up @@ -65,11 +65,11 @@ public PushTemplateReqValidator()
.DescriptionValid();
this.RuleFor(x => x.BlobDockerReference)
.DockerReferenceValid();
this.RuleFor(x => x.BlobDockerSha)
.ShaValid();
this.RuleFor(x => x.BlobDockerTag)
.TagValid();
this.RuleFor(x => x.TemplateDockerReference)
.DockerReferenceValid();
this.RuleFor(x => x.TemplateDockerSha)
.ShaValid();
this.RuleFor(x => x.TemplateDockerTag)
.TagValid();
}
}
4 changes: 2 additions & 2 deletions App/Modules/Cyan/Data/Mappers/PluginMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public static PluginVersionData HydrateData(this PluginVersionData data, PluginV
data with { Description = record.Description, };

public static PluginVersionData HydrateData(this PluginVersionData data, PluginVersionProperty record) =>
data with { DockerReference = record.DockerReference, DockerSha = record.DockerSha, };
data with { DockerReference = record.DockerReference, DockerTag = record.DockerTag, };

public static PluginVersionProperty ToProperty(this PluginVersionData data) =>
new() { DockerReference = data.DockerReference, DockerSha = data.DockerSha, };
new() { DockerReference = data.DockerReference, DockerTag = data.DockerTag, };

public static PluginVersionRecord ToRecord(this PluginVersionData data) =>
new() { Description = data.Description, };
Expand Down
4 changes: 2 additions & 2 deletions App/Modules/Cyan/Data/Mappers/ProcessorMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public static ProcessorVersionData HydrateData(this ProcessorVersionData data, P
data with { Description = record.Description, };

public static ProcessorVersionData HydrateData(this ProcessorVersionData data, ProcessorVersionProperty record) =>
data with { DockerReference = record.DockerReference, DockerSha = record.DockerSha, };
data with { DockerReference = record.DockerReference, DockerTag = record.DockerTag, };

public static ProcessorVersionProperty ToProperty(this ProcessorVersionData data) =>
new() { DockerReference = data.DockerReference, DockerSha = data.DockerSha, };
new() { DockerReference = data.DockerReference, DockerTag = data.DockerTag, };

public static ProcessorVersionRecord ToRecord(this ProcessorVersionData data) =>
new() { Description = data.Description, };
Expand Down
Loading

0 comments on commit 7b3e966

Please sign in to comment.