Skip to content

Commit 3a88dfe

Browse files
author
Sarath chandra Bussa
committed
fix: Resolve StyleCop analyzer errors in ACR SDK provider files
- SA1204: Move static GetFirstLayerDigest before instance members (OciRegistryClient.cs) - SA1124: Remove #region/#endregion around OCI JSON models (OciRegistryClient.cs) - SA1202: Move protected GetAcrInstallerScriptSnippet before private methods (PlatformInstallerBase.cs) - SA1116/SA1117: Place multi-line parameters each on own line (ExternalAcrSdkProvider.cs) - SA1515: Add blank line before single-line comment (DotNetCoreAcrVersionProvider.cs)
1 parent faa6b2d commit 3a88dfe

File tree

9 files changed

+223
-137
lines changed

9 files changed

+223
-137
lines changed

src/BuildScriptGenerator/DotNetCore/VersionProviders/DotNetCoreAcrVersionProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ private bool TryGetVersionInfoFromCatalog(string repository, string debianFlavor
8686
// Download the catalog layer (small JSON blob)
8787
var url = $"{this.commonOptions.OryxAcrSdkRegistryUrl?.TrimEnd('/') ?? SdkStorageConstants.DefaultAcrSdkRegistryUrl}/v2/{repository}/blobs/{layerDigest}";
8888
var httpClient = this.OciClient.GetAllTagsAsync(repository).Result; // We need a different approach
89+
8990
// Actually, we can get the blob content via the same pattern
9091

9192
// Use a simpler approach: read config labels from the catalog image

src/BuildScriptGenerator/ExternalAcrSdkProvider.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ public async Task<bool> RequestSdkFromAcrAsync(string platformName, string versi
7676
this.logger.LogInformation(
7777
"Requesting SDK from ACR via LWASv2: platform={PlatformName}, version={Version}, " +
7878
"debianFlavor={DebianFlavor}",
79-
platformName, version, debianFlavor);
79+
platformName,
80+
version,
81+
debianFlavor);
8082
this.outputWriter.WriteLine(
8183
$"Requesting SDK from ACR via external provider: {platformName} {version} ({debianFlavor})");
8284

@@ -116,7 +118,9 @@ public async Task<bool> RequestSdkFromAcrAsync(string platformName, string versi
116118
this.logger.LogInformation(
117119
"Successfully pulled SDK from ACR via LWASv2: {PlatformName} {Version}, " +
118120
"available at {FilePath}",
119-
platformName, version, expectedFilePath);
121+
platformName,
122+
version,
123+
expectedFilePath);
120124
this.outputWriter.WriteLine(
121125
$"Successfully pulled SDK from ACR: {platformName} {version}");
122126
return true;
@@ -126,17 +130,22 @@ public async Task<bool> RequestSdkFromAcrAsync(string platformName, string versi
126130
this.logger.LogWarning(
127131
"ACR SDK pull via LWASv2 did not produce expected file: {PlatformName} {Version} " +
128132
"at {FilePath}. Response: {Response}",
129-
platformName, version, expectedFilePath, response);
133+
platformName,
134+
version,
135+
expectedFilePath,
136+
response);
130137
this.outputWriter.WriteLine(
131138
$"Failed to pull SDK from ACR via external provider: {platformName} {version}");
132139
return false;
133140
}
134141
}
135142
catch (Exception ex)
136143
{
137-
this.logger.LogError(ex,
144+
this.logger.LogError(
145+
ex,
138146
"Error requesting SDK from ACR via LWASv2: {PlatformName} {Version}",
139-
platformName, version);
147+
platformName,
148+
version);
140149
this.outputWriter.WriteLine(
141150
$"Error pulling SDK from ACR via external provider: {platformName} {version}: {ex.Message}");
142151
return false;
@@ -151,7 +160,8 @@ private async Task<bool> SendRequestAsync(AcrSdkProviderRequest request)
151160
this.logger.LogInformation(
152161
"Sending ACR SDK request to external provider: {PlatformName}, {BlobName}, " +
153162
"UrlParameters: {UrlParamsJson}",
154-
request.PlatformName, request.BlobName,
163+
request.PlatformName,
164+
request.BlobName,
155165
JsonSerializer.Serialize(request.UrlParameters));
156166

157167
using (var cts = new CancellationTokenSource(
@@ -161,7 +171,8 @@ private async Task<bool> SendRequestAsync(AcrSdkProviderRequest request)
161171
var requestJson = JsonSerializer.Serialize(request);
162172
this.logger.LogInformation(
163173
"Connected to socket {SocketPath} and sending ACR request: {RequestJson}",
164-
SocketPath, requestJson);
174+
SocketPath,
175+
requestJson);
165176

166177
requestJson += "$";
167178
var requestBytes = Encoding.UTF8.GetBytes(requestJson);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// --------------------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// Licensed under the MIT license.
4+
// --------------------------------------------------------------------------------------------
5+
6+
using System.Collections.Generic;
7+
using System.Text.Json.Serialization;
8+
9+
namespace Microsoft.Oryx.BuildScriptGenerator
10+
{
11+
public class OciContainerConfig
12+
{
13+
[JsonPropertyName("Labels")]
14+
public Dictionary<string, string> Labels { get; set; }
15+
}
16+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// --------------------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// Licensed under the MIT license.
4+
// --------------------------------------------------------------------------------------------
5+
6+
using System.Text.Json.Serialization;
7+
8+
namespace Microsoft.Oryx.BuildScriptGenerator
9+
{
10+
public class OciDescriptor
11+
{
12+
[JsonPropertyName("mediaType")]
13+
public string MediaType { get; set; }
14+
15+
[JsonPropertyName("digest")]
16+
public string Digest { get; set; }
17+
18+
[JsonPropertyName("size")]
19+
public long Size { get; set; }
20+
}
21+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// --------------------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// Licensed under the MIT license.
4+
// --------------------------------------------------------------------------------------------
5+
6+
using System.Text.Json.Serialization;
7+
8+
namespace Microsoft.Oryx.BuildScriptGenerator
9+
{
10+
public class OciImageConfig
11+
{
12+
[JsonPropertyName("config")]
13+
public OciContainerConfig Config { get; set; }
14+
}
15+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// --------------------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// Licensed under the MIT license.
4+
// --------------------------------------------------------------------------------------------
5+
6+
using System.Collections.Generic;
7+
using System.Text.Json.Serialization;
8+
9+
namespace Microsoft.Oryx.BuildScriptGenerator
10+
{
11+
public class OciManifest
12+
{
13+
[JsonPropertyName("schemaVersion")]
14+
public int SchemaVersion { get; set; }
15+
16+
[JsonPropertyName("mediaType")]
17+
public string MediaType { get; set; }
18+
19+
[JsonPropertyName("config")]
20+
public OciDescriptor Config { get; set; }
21+
22+
[JsonPropertyName("layers")]
23+
public List<OciDescriptor> Layers { get; set; }
24+
}
25+
}

0 commit comments

Comments
 (0)