Skip to content

Commit

Permalink
Remove dead code from AwsConfigService
Browse files Browse the repository at this point in the history
  • Loading branch information
hocinehacherouf committed Jun 1, 2023
1 parent 1a30d01 commit 766692a
Showing 1 changed file with 32 additions and 91 deletions.
123 changes: 32 additions & 91 deletions src/AzureIoTHub.Portal.Infrastructure/Services/AWS/AwsConfigService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private async Task<Dictionary<string, ComponentDeploymentSpecification>> CreateG
{
var componentArn = !string.IsNullOrEmpty(component.Id) ?
$"{component.Id}:versions:{component.Version}" : // Public greengrass component
$"arn:aws:greengrass:{config.AWSRegion}:{config.AWSAccountId}:components:{component.ModuleName}:versions:{component.Version}"; // Private greengrass component
$"arn:aws:greengrass:{config.AWSRegion}:{config.AWSAccountId}:components:{component.ModuleName}:versions:{component.Version}"; //

_ = await this.greengrass.DescribeComponentAsync(new DescribeComponentRequest
{
Expand All @@ -175,51 +175,6 @@ private async Task<Dictionary<string, ComponentDeploymentSpecification>> CreateG

return components;
}

// TODO: To delete if no more needed
//private static JObject JsonCreateComponent(IoTEdgeModule component)
//{

// var environmentVariableObject = new JObject();

// foreach (var env in component.EnvironmentVariables)
// {
// environmentVariableObject.Add(new JProperty(env.Name, env.Value));
// }

// var recipeJson =new JObject(
// new JProperty("RecipeFormatVersion", "2020-01-25"),
// new JProperty("ComponentName", component.ModuleName),
// new JProperty("ComponentVersion", component.Version),
// new JProperty("ComponentPublisher", "IotHub"),
// new JProperty("ComponentDependencies",
// new JObject(
// new JProperty("aws.greengrass.DockerApplicationManager",
// new JObject(new JProperty("VersionRequirement", "~2.0.0"))),
// new JProperty("aws.greengrass.TokenExchangeService",
// new JObject(new JProperty("VersionRequirement", "~2.0.0")))
// )
// ),
// new JProperty("Manifests",
// new JArray(
// new JObject(
// new JProperty("Platform",
// new JObject(new JProperty("os", "linux"))),
// new JProperty("Lifecycle",
// new JObject(new JProperty("Run", $"docker run {component.ImageURI}"),
// new JProperty("Environment",environmentVariableObject))),
// new JProperty("Artifacts",
// new JArray(
// new JObject(new JProperty("URI", $"docker:{component.ImageURI}"))
// )
// )
// )
// )
// )
// );

// return recipeJson;
//}

//AWS Not implemented methods

Expand Down Expand Up @@ -346,13 +301,6 @@ public async Task<List<IoTEdgeModule>> GetConfigModuleList(string modelId)

}
}

// TODO: Delete if no more needed
//private static string retreiveImageUri(string parent, string child, string recipeJsonString)
//{
// var uriImage = "";
// // Parse the string as a JSON object
// var recipeJsonObject = JObject.Parse(recipeJsonString);

// // Extract the "Manifests" array
// var jArray = recipeJsonObject["Manifests"] as JArray;
Expand All @@ -372,28 +320,26 @@ public async Task<List<IoTEdgeModule>> GetConfigModuleList(string modelId)
// // Extract the value of "Run"
// var runValue = lifecycle[child]?.ToString();

if (lifecycle != null)
{
// Extract the value of "Run"
var runValue = lifecycle[child]?.ToString();
// // Search the index of the 1st whitespace
// var firstSpaceIndex = runValue.IndexOf(' ');

// Search the index of the 1st whitespace
var firstSpaceIndex = runValue.IndexOf(' ');
// if (firstSpaceIndex != -1)
// {
// // // Search the index of the 2nd whitespace
// var secondSpaceIndex = runValue.IndexOf(' ', firstSpaceIndex + 1);

if (firstSpaceIndex != -1)
{
// // Search the index of the 2nd whitespace
var secondSpaceIndex = runValue.IndexOf(' ', firstSpaceIndex + 1);
// if (secondSpaceIndex != -1)
// {
// // Extract the URI iamge
// uriImage = runValue[(secondSpaceIndex + 1)..];
// }

if (secondSpaceIndex != -1)
{
// Extract the URI iamge
uriImage = runValue[(secondSpaceIndex + 1)..];
}
// }
// }
// }

}
}
}
// return uriImage;
//}

//private static List<IoTEdgeModuleEnvironmentVariable> retreiveEnvVariableAttr(string parent, string child, string recipeJsonString)
//{
Expand Down Expand Up @@ -421,28 +367,23 @@ public async Task<List<IoTEdgeModule>> GetConfigModuleList(string modelId)
// // Extract the value of "Environment"
// var env = lifecycle?[child] as JObject;

if (lifecycle != null)
{
// Extract the value of "Environment"
var env = lifecycle?[child] as JObject;
// // Convert Environment JSON Object as a dictionnary
// var keyValuePairs = env!.ToObject<Dictionary<string, string>>();

// Convert Environment JSON Object as a dictionnary
var keyValuePairs = env!.ToObject<Dictionary<string, string>>();
// foreach (var kvp in keyValuePairs!)
// {
// var iotEnvVariable = new IoTEdgeModuleEnvironmentVariable
// {
// Name = kvp.Key,
// Value = kvp.Value
// };

foreach (var kvp in keyValuePairs!)
{
var iotEnvVariable = new IoTEdgeModuleEnvironmentVariable
{
Name = kvp.Key,
Value = kvp.Value
};

environmentVariables.Add(iotEnvVariable);
}
}
}
return environmentVariables;
}
// environmentVariables.Add(iotEnvVariable);
// }
// }
// }
// return environmentVariables;
//}

public Task<List<EdgeModelSystemModule>> GetModelSystemModule(string modelId)
{
Expand Down

0 comments on commit 766692a

Please sign in to comment.