Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2161 fix edge model update #2170

Merged
merged 5 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<ChildContent>
<MudGrid>
<MudItem xs="12" md="6">
<MudTextField id="@nameof(EdgeModel.Name)" @bind-Value="@EdgeModel.Name" For="@(() => EdgeModel.Name)" Label="Name" Margin="Margin.Dense" Variant="Variant.Outlined" Required="true" />
<MudTextField id="@nameof(EdgeModel.Name)" @bind-Value="@EdgeModel.Name" For="@(() => EdgeModel.Name)" Label="Name" Margin="Margin.Dense" Variant="Variant.Outlined" Required="true" ReadOnly="true"/>
</MudItem>
<MudItem xs="12" md="6">
<MudTextField id="@nameof(EdgeModel.Description)" @bind-Value="@EdgeModel.Description" For="@(() => EdgeModel.Description)" Label="Description" Variant="Variant.Outlined" Lines="5" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,20 +253,21 @@ public async Task UpdateEdgeModel(IoTEdgeModel edgeModel)
foreach (var labelEntity in edgeModelEntity.Labels)
{
this.labelRepository.Delete(labelEntity.Id);
}

}

edgeModel.ExternalIdentifier = await this.configService.RollOutEdgeModelConfiguration(edgeModel);

Check warning

Code scanning / CodeQL

Dereferenced variable may be null

Variable [edgeModel](1) may be null at this access as suggested by [this](2) null check. Variable [edgeModel](1) may be null at this access as suggested by [this](3) null check.

_ = this.mapper.Map(edgeModel, edgeModelEntity);

this.edgeModelRepository.Update(edgeModelEntity);


// For AWS, we do the update in the AwsConfiguration
if (this.config.CloudProvider.Equals(CloudProviders.Azure, StringComparison.Ordinal))
{
_ = this.mapper.Map(edgeModel, edgeModelEntity);

this.edgeModelRepository.Update(edgeModelEntity);

await SaveModuleCommands(edgeModel);
await SaveModuleCommands(edgeModel);

}

edgeModel.ExternalIdentifier = await this.configService.RollOutEdgeModelConfiguration(edgeModel);

await this.unitOfWork.SaveAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ public async Task UpdateEdgeModelForAWSShouldUpdateEdgeModel()
this.mockLabelRepository.Setup(repository => repository.Delete(It.IsAny<string>()))
.Verifiable();

_ = this.mockEdgeDeviceModelRepository.Setup(repository => repository.Update(It.IsAny<EdgeDeviceModel>()));
_ = this.mockUnitOfWork.Setup(work => work.SaveAsync())
.Returns(Task.CompletedTask);

_ = this.mockConfigService.Setup(x => x.RollOutEdgeModelConfiguration(It.IsAny<IoTEdgeModel>()))
.Returns(Task.FromResult(Fixture.Create<string>()));

Expand Down