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

chore: adjust get queries to filter for name #43

Merged
merged 1 commit into from
Apr 30, 2024
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
4 changes: 2 additions & 2 deletions charts/dim/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
apiVersion: v2
name: dim
type: application
version: 0.0.5
appVersion: 0.0.5
version: 0.0.6
appVersion: 0.0.6
description: Helm chart for DIM Middle Layer
home: https://github.com/catenax-ng/dim-repo
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion charts/dim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ To use the helm chart as a dependency:
dependencies:
- name: dim
repository: https://phil91.github.io/dim-client
version: 0.0.5
version: 0.0.6
```

## Requirements
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<Project>
<PropertyGroup>
<VersionPrefix>0.0.5</VersionPrefix>
<VersionPrefix>0.0.6</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
</Project>
8 changes: 4 additions & 4 deletions src/clients/Dim.Clients/Api/Cf/CfClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@

private static async Task<Guid> GetEnvironmentId(string tenantName, CancellationToken cancellationToken, HttpClient client)
{
var environmentsResponse = await client.GetAsync("/v3/organizations", cancellationToken)
var environmentsResponse = await client.GetAsync($"/v3/organizations?names={tenantName}", cancellationToken)
.CatchingIntoServiceExceptionFor("get-organizations", HttpAsyncResponseMessageExtension.RecoverOptions.INFRASTRUCTURE);
var environments = await environmentsResponse.Content
.ReadFromJsonAsync<GetEnvironmentsResponse>(JsonSerializerExtensions.Options, cancellationToken)
.ConfigureAwait(false);

var tenantEnvironment = environments.Resources.Where(x => x.Name == tenantName);

Check warning on line 80 in src/clients/Dim.Clients/Api/Cf/CfClient.cs

View workflow job for this annotation

GitHub Actions / build (8.0)

Dereference of a possibly null reference.

Check warning on line 80 in src/clients/Dim.Clients/Api/Cf/CfClient.cs

View workflow job for this annotation

GitHub Actions / build (8.0)

Dereference of a possibly null reference.
if (tenantEnvironment.Count() > 1)
{
throw new ConflictException($"There should only be one cf environment for tenant {tenantName}");
Expand Down Expand Up @@ -136,7 +136,7 @@
{
var spaceName = $"{tenantName}-space";
var client = await _basicAuthTokenService.GetBasicAuthorizedLegacyClient<CfClient>(_settings, cancellationToken).ConfigureAwait(false);
var result = await client.GetAsync("/v3/spaces", cancellationToken)
var result = await client.GetAsync($"/v3/spaces?names={spaceName}", cancellationToken)
.CatchingIntoServiceExceptionFor("get-space", HttpAsyncResponseMessageExtension.RecoverOptions.ALLWAYS).ConfigureAwait(false);
try
{
Expand Down Expand Up @@ -180,8 +180,9 @@

private async Task<Guid> GetServiceInstances(string tenantName, Guid? spaceId, CancellationToken cancellationToken)
{
var name = $"{tenantName}-dim-instance";
var client = await _basicAuthTokenService.GetBasicAuthorizedLegacyClient<CfClient>(_settings, cancellationToken).ConfigureAwait(false);
var result = await client.GetAsync("/v3/service_instances", cancellationToken)
var result = await client.GetAsync($"/v3/service_instances?names={name}", cancellationToken)
.CatchingIntoServiceExceptionFor("get-si", HttpAsyncResponseMessageExtension.RecoverOptions.INFRASTRUCTURE).ConfigureAwait(false);
try
{
Expand All @@ -193,7 +194,6 @@
throw new ServiceException("Response must not be null");
}

var name = $"{tenantName}-dim-instance";
var resources = response.Resources.Where(x => x.Name == name && x.Type == "managed" && (spaceId == null || x.Relationships.Space.Data.Id == spaceId.Value) && x.LastOperation.State == "succeeded");
if (resources.Count() != 1)
{
Expand Down
Loading