Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jherns committed Apr 13, 2023
1 parent 79a2b85 commit 12853c7
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 46 deletions.
4 changes: 2 additions & 2 deletions src/Runner.Common/LaunchServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void InitializeLaunchClient(Uri uri, string token)
var httpMessageHandler = HostContext.CreateHttpClientHandler();
this._launchClient = new LaunchHttpClient(uri, httpMessageHandler, token, disposeHandler: true);
}

public Task<ActionDownloadInfoCollection> ResolveActionsDownloadInfoAsync(Guid planId, Guid jobId, ActionReferenceList actionReferenceList,
CancellationToken cancellationToken)
{
Expand All @@ -39,4 +39,4 @@ public Task<ActionDownloadInfoCollection> ResolveActionsDownloadInfoAsync(Guid p
throw new InvalidOperationException("Launch client is not initialized.");
}
}
}
}
2 changes: 1 addition & 1 deletion src/Runner.Worker/ActionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ private async Task BuildActionContainerAsync(IExecutionContext executionContext,
{
actionDownloadInfos = await launchServer.ResolveActionsDownloadInfoAsync(executionContext.Global.Plan.PlanId, Guid.Parse(executionContext.Global.Variables.Get("system.jobId")), new WebApi.ActionReferenceList { Actions = actionReferences }, executionContext.CancellationToken);
}
else
else
{
actionDownloadInfos = await jobServer.ResolveActionDownloadInfoAsync(executionContext.Global.Plan.ScopeIdentifier, executionContext.Global.Plan.PlanType, executionContext.Global.Plan.PlanId, executionContext.Root.Id, new WebApi.ActionReferenceList { Actions = actionReferences }, executionContext.CancellationToken);
}
Expand Down
6 changes: 2 additions & 4 deletions src/Sdk/WebApi/WebApi/LaunchContracts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ActionReferenceRequest
[DataMember(EmitDefaultValue = false, Name = "path")]
public string Path { get; set; }
}

[DataContract]
public class ActionReferenceRequestList
{
Expand Down Expand Up @@ -67,6 +67,4 @@ public class ActionDownloadInfoResponseCollection
[DataMember(EmitDefaultValue = false, Name = "actions")]
public IDictionary<string, ActionDownloadInfoResponse> Actions { get; set; }
}


}
}
77 changes: 39 additions & 38 deletions src/Sdk/WebApi/WebApi/LaunchHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private async Task<T> GetLaunchSignedURLResponse<R, T>(Uri uri, R request, Cance
}
}
}

public async Task<ActionDownloadInfoCollection> GetResolveActionsDownloadInfoAsync(Guid planId, Guid jobId, ActionReferenceList actionReferenceList, CancellationToken cancellationToken)
{

Expand All @@ -64,54 +65,54 @@ private static ActionReferenceRequestList ToGitHubData(ActionReferenceList actio
};
}

private static ActionReferenceRequest ToGitHubData(ActionReference actionReference)
{
return new ActionReferenceRequest
private static ActionReferenceRequest ToGitHubData(ActionReference actionReference)
{
Action = actionReference.NameWithOwner,
Version = actionReference.Ref,
Path = actionReference.Path
};
}

private static ActionDownloadInfoCollection ToServerData(ActionDownloadInfoResponseCollection actionDownloadInfoResponseCollection)
{
return new ActionDownloadInfoCollection
{
Actions = actionDownloadInfoResponseCollection.Actions?.ToDictionary(kvp => kvp.Key, kvp => ToServerData(kvp.Value))
};
}
return new ActionReferenceRequest
{
Action = actionReference.NameWithOwner,
Version = actionReference.Ref,
Path = actionReference.Path
};
}

private static ActionDownloadInfo ToServerData(ActionDownloadInfoResponse actionDownloadInfoResponse)
{
return new ActionDownloadInfo
private static ActionDownloadInfoCollection ToServerData(ActionDownloadInfoResponseCollection actionDownloadInfoResponseCollection)
{
Authentication = ToServerData(actionDownloadInfoResponse.Authentication),
NameWithOwner = actionDownloadInfoResponse.Name,
ResolvedNameWithOwner = actionDownloadInfoResponse.ResolvedName,
ResolvedSha = actionDownloadInfoResponse.ResolvedSha,
TarballUrl = actionDownloadInfoResponse.TarUrl,
Ref = actionDownloadInfoResponse.Version,
ZipballUrl = actionDownloadInfoResponse.ZipUrl,
};
}
return new ActionDownloadInfoCollection
{
Actions = actionDownloadInfoResponseCollection.Actions?.ToDictionary(kvp => kvp.Key, kvp => ToServerData(kvp.Value))
};
}

private static ActionDownloadAuthentication? ToServerData(ActionDownloadAuthenticationResponse? actionDownloadAuthenticationResponse)
{
if (actionDownloadAuthenticationResponse == null)
private static ActionDownloadInfo ToServerData(ActionDownloadInfoResponse actionDownloadInfoResponse)
{
return null;
return new ActionDownloadInfo
{
Authentication = ToServerData(actionDownloadInfoResponse.Authentication),
NameWithOwner = actionDownloadInfoResponse.Name,
ResolvedNameWithOwner = actionDownloadInfoResponse.ResolvedName,
ResolvedSha = actionDownloadInfoResponse.ResolvedSha,
TarballUrl = actionDownloadInfoResponse.TarUrl,
Ref = actionDownloadInfoResponse.Version,
ZipballUrl = actionDownloadInfoResponse.ZipUrl,
};
}

return new ActionDownloadAuthentication
private static ActionDownloadAuthentication? ToServerData(ActionDownloadAuthenticationResponse? actionDownloadAuthenticationResponse)
{
ExpiresAt = actionDownloadAuthenticationResponse.ExpiresAt,
Token = actionDownloadAuthenticationResponse.Token
};
}
if (actionDownloadAuthenticationResponse == null)
{
return null;
}

return new ActionDownloadAuthentication
{
ExpiresAt = actionDownloadAuthenticationResponse.ExpiresAt,
Token = actionDownloadAuthenticationResponse.Token
};
}

private MediaTypeFormatter m_formatter;
private Uri m_launchServiceUrl;
private string m_token;
}
}
}
2 changes: 1 addition & 1 deletion src/Test/L0/Worker/ActionManagerL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,7 @@ private void Setup([CallerMemberName] string name = "", bool enableComposite = t
}
return Task.FromResult(result);
});

_launchServer = new Mock<ILaunchServer>();
_launchServer.Setup(x => x.ResolveActionsDownloadInfoAsync(It.IsAny<Guid>(), It.IsAny<Guid>(), It.IsAny<ActionReferenceList>(), It.IsAny<CancellationToken>()))
.Returns((Guid planId, Guid jobId, ActionReferenceList actions, CancellationToken cancellationToken) =>
Expand Down

0 comments on commit 12853c7

Please sign in to comment.