Skip to content

Commit

Permalink
cleanup & safeguards
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherjturner committed Jan 15, 2025
1 parent f853161 commit 52488d5
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ protected override List<CreateIndexModel<AppConfigVersion>> DefineIndexes(
}
}

[BsonIgnoreExtraElements]
public record AppConfigVersion(string CommitSha, DateTime CommitTimestamp, string Environment)
{
[BsonId(IdGenerator = typeof(ObjectIdGenerator))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public async Task PersistEvent(Event<EnabledVanityUrlsPayload> workflowEvent, Ca
}
}

[BsonIgnoreExtraElements]
public record EnabledVanityUrlRecord(string Url, string Environment, string Service)
{
[BsonId(IdGenerator = typeof(ObjectIdGenerator))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private async Task UpdateVanityUrls(List<NginxVanityUrlsRecord> vanityUrls,
}
}

[BsonIgnoreExtraElements]
public record NginxVanityUrlsRecord(string Environment, string ServiceName, string Url)
{
[BsonId(IdGenerator = typeof(ObjectIdGenerator))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public async Task<List<ShutteredUrlRecord>> FindShutteredUrls(CancellationToken
}
}

[BsonIgnoreExtraElements]
public record ShutteredUrlRecord(string Environment, string Url)
{
[BsonId(IdGenerator = typeof(ObjectIdGenerator))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ private async Task UpdateSquidProxyConfigs(List<SquidProxyConfigRecord> squidPro
}
}

[BsonIgnoreExtraElements]
public record SquidProxyConfigRecord(string Environment, string ServiceName, List<string> DefaultDomains, List<string> AllowedDomains)
{
[BsonId(IdGenerator = typeof(ObjectIdGenerator))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ private async Task DeleteBuckets(List<TenantBucketRecord> tenantBucketRecords,
}
}

[BsonIgnoreExtraElements]
public record TenantBucketRecord(
string Environment,
string ServiceName,
Expand All @@ -135,7 +136,7 @@ public record TenantBucketRecord(

public virtual bool Equals(TenantBucketRecord? other)
{
return Environment == other.Environment && ServiceName == other.ServiceName && Bucket == other.Bucket;
return Environment == other?.Environment && ServiceName == other.ServiceName && Bucket == other.Bucket;
}

public override int GetHashCode() => HashCode.Combine(Environment, ServiceName, Bucket);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public async Task<List<TenantServiceRecord>> FindAllServices(string service, Can
}
}

[BsonIgnoreExtraElements]
public record TenantServiceRecord(
string Environment,
string ServiceName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private async Task<List<VanityUrlRecord>> Find(BsonDocument matchStage, Cancella
];
}

[BsonIgnoreExtraElements]
public record VanityUrlRecord(string Url, string Environment, string ServiceName, bool Enabled, bool Shuttered)
{
[BsonId(IdGenerator = typeof(ObjectIdGenerator))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ServiceOverviewService(
IVanityUrlService vanityUrlService,
IDeploymentsServiceV2 deploymentsService,
SelfServiceOpsFetcher selfServiceOpsFetcher
) : IServiceOverviewService
) : IServiceOverviewService
{
public async Task<ServiceV2?> GetService(string name, CancellationToken cancellationToken = default)
{
Expand Down
17 changes: 8 additions & 9 deletions Defra.Cdp.Backend.Api/Utils/Fetchers/SelfServiceOpsFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ public async Task<HttpStatusCode> TriggerTestSuite(string imageName, string envi
}
}


public class CreationStatus
{
public string Status { get; init; }
public string Kind { get; init; }
public DateTime Started { get; init; }
public required string Status { get; init; }
public string? Kind { get; init; }
public DateTime? Started { get; init; }
public User? Creator { get; init; }
public JsonObject? Content { get; set; }
}
Expand All @@ -70,13 +69,13 @@ public class SelfServiceOpsStatus
public class RepoStatus
{
[property: JsonPropertyName("status")]
public string Status { get; init; }
public required string Status { get; init; }

[property: JsonPropertyName("kind")]
public string Kind { get; init; }
public required string Kind { get; init; }

[property: JsonPropertyName("started")]
public DateTime Started { get; init; }
public DateTime? Started { get; init; }

[property: JsonPropertyName("creator")]
public User? Creator { get; init; }
Expand All @@ -86,7 +85,7 @@ public class RepoStatus
public class User
{
[property: JsonPropertyName("id")]
string Id { get; init; }
string? Id { get; init; }
[property: JsonPropertyName("displayName")]
string DisplayName { get; init; }
string? DisplayName { get; init; }
}

0 comments on commit 52488d5

Please sign in to comment.