Files
runner/src/Sdk/DTWebApi/WebApi/TaskAttachment.cs
Sven Pfleiderer 1a0d588d3a Add support for Step Summary (#1642)
* First prototype of step summary environment variable

* Fix file contention issue

* Try to simplify cleaning up file references

* use step id as md file name, queue file attachment

* separate logic into attachment summary func

* Fix indentation

* Add (experimental) feature flag support

* reorganize summary upload determination logic

* file i/o exception handling + pr feedback

* Revert changes for now to reintroduce them later

* Add skeleton SetStepSummaryCommand

* Update step summary feature flag name

* Port ShouldUploadAttachment from previous iteration

* Port QueueStepSummaryUpload from previous iteration

* Improve exception handling when uploading attachment

* Add some minor logging improvements

* Refuse to upload files larger than 128k

* Implement secrets scrubbing

* Add TODO comment to remove debugging temp files

* Add first tests

* Add test for secret masking

* Add some naming/style fixes suggested in feedback

* inline check for feature flag

* Inline method for style consistency

* Make sure that scrubbed file doesn't exist before creating it

* Rename SetStepSummaryCommand to CreateStepSummaryCommand

* Fix error handling messages

* Fix file command name when registering extension

* Remove unnecessary file deletion

Co-authored-by: Rob Herley <robherley@github.com>
2022-02-04 13:46:30 -08:00

112 lines
2.5 KiB
C#

using GitHub.Services.Common;
using GitHub.Services.WebApi;
using System;
using System.Runtime.Serialization;
namespace GitHub.DistributedTask.WebApi
{
[DataContract]
public class TaskAttachment
{
internal TaskAttachment()
{ }
internal TaskAttachment(String type, String name, ReferenceLinks links)
{
ArgumentUtility.CheckStringForNullOrEmpty(type, "type");
ArgumentUtility.CheckStringForNullOrEmpty(name, "name");
this.Type = type;
this.Name = name;
this.m_links = links;
}
public TaskAttachment(String type, String name)
{
ArgumentUtility.CheckStringForNullOrEmpty(type, "type");
ArgumentUtility.CheckStringForNullOrEmpty(name, "name");
this.Type = type;
this.Name = name;
}
[DataMember]
public String Type
{
get;
internal set;
}
[DataMember]
public String Name
{
get;
internal set;
}
public ReferenceLinks Links
{
get
{
if (m_links == null)
{
m_links = new ReferenceLinks();
}
return m_links;
}
}
[DataMember]
public DateTime CreatedOn
{
get;
internal set;
}
[DataMember]
public DateTime LastChangedOn
{
get;
internal set;
}
[DataMember]
public Guid LastChangedBy
{
get;
internal set;
}
[DataMember]
public Guid TimelineId
{
get;
set;
}
[DataMember]
public Guid RecordId
{
get;
set;
}
[DataMember(Name = "_links", EmitDefaultValue = false)]
private ReferenceLinks m_links;
}
[GenerateAllConstants]
public class CoreAttachmentType
{
public static readonly String Log = "DistributedTask.Core.Log";
public static readonly String Summary = "DistributedTask.Core.Summary";
public static readonly String FileAttachment = "DistributedTask.Core.FileAttachment";
public static readonly String DiagnosticLog = "DistributedTask.Core.DiagnosticLog";
}
[GenerateAllConstants]
public class ChecksAttachmentType
{
public static readonly String StepSummary = "Checks.Step.Summary";
}
}