From 0964c0c0147540ae210c649de65d5cc5c82091c9 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Tue, 31 Jul 2018 00:02:02 -0400 Subject: [PATCH] Endless alpha --- src/Tgstation.Server.Api/Models/Job.cs | 5 + src/Tgstation.Server.Api/Models/Repository.cs | 2 +- .../Rights/RightsHelper.cs | 13 +- .../Repository/IRepositoryManager.cs | 2 +- .../Repository/RepositoryManager.cs | 9 +- .../Controllers/ByondController.cs | 2 +- .../Controllers/DreamDaemonController.cs | 2 +- .../Controllers/DreamMakerController.cs | 2 +- .../Controllers/InstanceController.cs | 2 +- .../Controllers/JobController.cs | 4 +- .../Controllers/RepositoryController.cs | 21 +- src/Tgstation.Server.Host/Core/IJobManager.cs | 9 +- src/Tgstation.Server.Host/Core/JobHandler.cs | 5 + src/Tgstation.Server.Host/Core/JobManager.cs | 22 +- .../TgsAuthorizeAttribute.cs | 18 +- tools/TGS.postman_collection.json | 589 ++++++++++++------ v4_prototype_TODO.txt | 7 +- 17 files changed, 490 insertions(+), 224 deletions(-) diff --git a/src/Tgstation.Server.Api/Models/Job.cs b/src/Tgstation.Server.Api/Models/Job.cs index 2f413fff43..3ac1549daa 100644 --- a/src/Tgstation.Server.Api/Models/Job.cs +++ b/src/Tgstation.Server.Api/Models/Job.cs @@ -16,5 +16,10 @@ /// [Permissions(DenyWrite = true)] public User CancelledBy { get; set; } + + /// + /// Optional progress between 0 and 100 inclusive + /// + public int? Progress { get; set; } } } diff --git a/src/Tgstation.Server.Api/Models/Repository.cs b/src/Tgstation.Server.Api/Models/Repository.cs index 981c77aa94..36d2c9b9a8 100644 --- a/src/Tgstation.Server.Api/Models/Repository.cs +++ b/src/Tgstation.Server.Api/Models/Repository.cs @@ -15,7 +15,7 @@ namespace Tgstation.Server.Api.Models public string Origin { get; set; } /// - /// The commit HEAD points to + /// The commit HEAD points to. Not populated in responses, use instead /// [Permissions(WriteRight = RepositoryRights.SetSha)] public string Sha { get; set; } diff --git a/src/Tgstation.Server.Api/Rights/RightsHelper.cs b/src/Tgstation.Server.Api/Rights/RightsHelper.cs index ab4e16de4e..74e23dc94e 100644 --- a/src/Tgstation.Server.Api/Rights/RightsHelper.cs +++ b/src/Tgstation.Server.Api/Rights/RightsHelper.cs @@ -38,7 +38,18 @@ namespace Tgstation.Server.Api.Rights /// The /// The /// A representing the claim role name - public static string RoleName(TRight right) => String.Concat(typeof(TRight).Name, '.', right.ToString()); + public static string RoleNames(TRight right) where TRight: Enum + { + var flags = new List(); + IEnumerable GetRoleNames() + { + foreach (Enum J in Enum.GetValues(right.GetType())) + if (right.HasFlag(J)) + yield return String.Concat(typeof(TRight).Name, '.', J.ToString()); + }; + var names = GetRoleNames(); + return String.Join(",", names); + } /// /// Gets the role claim name used for a given and diff --git a/src/Tgstation.Server.Host/Components/Repository/IRepositoryManager.cs b/src/Tgstation.Server.Host/Components/Repository/IRepositoryManager.cs index 1279f7285a..673384257d 100644 --- a/src/Tgstation.Server.Host/Components/Repository/IRepositoryManager.cs +++ b/src/Tgstation.Server.Host/Components/Repository/IRepositoryManager.cs @@ -24,7 +24,7 @@ namespace Tgstation.Server.Host.Components.Repository /// The access string to clone from /// The for the operation /// The newly cloned , if one already exists - Task CloneRepository(Uri url, string initialBranch, string accessString, CancellationToken cancellationToken); + Task CloneRepository(Uri url, string initialBranch, string accessString, Action progressReporter, CancellationToken cancellationToken); /// /// Delete the current repository diff --git a/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs b/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs index 3187d6dfe2..f594f32132 100644 --- a/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs +++ b/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs @@ -49,7 +49,7 @@ namespace Tgstation.Server.Host.Components.Repository public void Dispose() => semaphore.Dispose(); /// - public async Task CloneRepository(Uri url, string initialBranch, string accessString, CancellationToken cancellationToken) + public async Task CloneRepository(Uri url, string initialBranch, string accessString, Action progressReporter, CancellationToken cancellationToken) { using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken).ConfigureAwait(false)) if (!await ioManager.DirectoryExists(".", cancellationToken).ConfigureAwait(false)) @@ -63,7 +63,12 @@ namespace Tgstation.Server.Host.Components.Repository path = LibGit2Sharp.Repository.Clone(Repository.GenerateAuthUrl(url.ToString(), accessString), ioManager.ResolvePath("."), new CloneOptions { OnProgress = (a) => !cancellationToken.IsCancellationRequested, - OnTransferProgress = (a) => !cancellationToken.IsCancellationRequested, + OnTransferProgress = (a) => + { + var percentage = 100 * (((float)a.IndexedObjects + a.ReceivedObjects) / (a.TotalObjects * 2)); + progressReporter((int)percentage); + return !cancellationToken.IsCancellationRequested; + }, RecurseSubmodules = true, OnUpdateTips = (a, b, c) => !cancellationToken.IsCancellationRequested, RepositoryOperationStarting = (a) => !cancellationToken.IsCancellationRequested, diff --git a/src/Tgstation.Server.Host/Controllers/ByondController.cs b/src/Tgstation.Server.Host/Controllers/ByondController.cs index 0a6a47f408..a137447c4e 100644 --- a/src/Tgstation.Server.Host/Controllers/ByondController.cs +++ b/src/Tgstation.Server.Host/Controllers/ByondController.cs @@ -100,7 +100,7 @@ namespace Tgstation.Server.Host.Controllers CancelRight = (int)ByondRights.CancelInstall, Instance = Instance }; - await jobManager.RegisterOperation(job, (paramJob, serviceProvicer, ct) => byondManager.ChangeVersion(installingVersion, ct), cancellationToken).ConfigureAwait(false); + await jobManager.RegisterOperation(job, (paramJob, serviceProvicer, progressHandler, ct) => byondManager.ChangeVersion(installingVersion, ct), cancellationToken).ConfigureAwait(false); result.InstallJob = job.ToApi(); } result.Version = byondManager.ActiveVersion; diff --git a/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs b/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs index 323e073e00..4d805cca10 100644 --- a/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs +++ b/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs @@ -64,7 +64,7 @@ namespace Tgstation.Server.Host.Controllers StartedBy = AuthenticationContext.User }; await jobManager.RegisterOperation(job, - async (paramJob, serviceProvider, innerCt) => + async (paramJob, serviceProvider, progressHandler, innerCt) => { var result = await instance.Watchdog.Launch(innerCt).ConfigureAwait(false); if (result == null) diff --git a/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs b/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs index c9acbb0d6a..e1b174c132 100644 --- a/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs +++ b/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs @@ -68,7 +68,7 @@ namespace Tgstation.Server.Host.Controllers CancelRight = (int)DreamMakerRights.CancelCompile, Instance = Instance }; - await jobManager.RegisterOperation(job, (paramJob, serviceProvider, ct) => RunCompile(paramJob, serviceProvider, Instance, ct), cancellationToken).ConfigureAwait(false); + await jobManager.RegisterOperation(job, (paramJob, serviceProvider, progressReporter, ct) => RunCompile(paramJob, serviceProvider, Instance, ct), cancellationToken).ConfigureAwait(false); return Json(job); } diff --git a/src/Tgstation.Server.Host/Controllers/InstanceController.cs b/src/Tgstation.Server.Host/Controllers/InstanceController.cs index 53ac454911..9fabc92699 100644 --- a/src/Tgstation.Server.Host/Controllers/InstanceController.cs +++ b/src/Tgstation.Server.Host/Controllers/InstanceController.cs @@ -310,7 +310,7 @@ namespace Tgstation.Server.Host.Controllers StartedBy = AuthenticationContext.User }; - await jobManager.RegisterOperation(job, async (paramJob, serviceProvider, ct) => { + await jobManager.RegisterOperation(job, async (paramJob, serviceProvider, progressHandler, ct) => { try { await instanceManager.MoveInstance(Instance, rawPath, ct).ConfigureAwait(false); diff --git a/src/Tgstation.Server.Host/Controllers/JobController.cs b/src/Tgstation.Server.Host/Controllers/JobController.cs index 79bb25cc15..1fee01abd5 100644 --- a/src/Tgstation.Server.Host/Controllers/JobController.cs +++ b/src/Tgstation.Server.Host/Controllers/JobController.cs @@ -71,7 +71,9 @@ namespace Tgstation.Server.Host.Controllers var job = await DatabaseContext.Jobs.Where(x => x.Id == id).Include(x => x.StartedBy).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false); if (job == default(Job)) return NotFound(); - return Json(job.ToApi()); + var api = job.ToApi(); + api.Progress = jobManager.JobProgress(job); + return Json(api); } } } diff --git a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs index 9a703fb956..a96082300a 100644 --- a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs +++ b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs @@ -80,7 +80,7 @@ namespace Tgstation.Server.Host.Controllers { CommitSha = repoSha, CompileJobs = new List(), - ActiveTestMerges = new List() //non null vals for api returns + ActiveTestMerges = new List() //non null vals for api returns }; lock (DatabaseContext) //cleaner this way @@ -95,12 +95,11 @@ namespace Tgstation.Server.Host.Controllers model.IsGitHub = repository.IsGitHubRepository; model.Origin = repository.Origin; model.Reference = repository.Reference; - model.Sha = repository.Head; //rev info stuff Models.RevisionInformation revisionInfo = null; var needsDbUpdate = await LoadRevisionInformation(repository, x => revisionInfo = x, cancellationToken).ConfigureAwait(false); - revisionInfo.OriginCommitSha = lastOriginCommitSha ?? model.Sha; + revisionInfo.OriginCommitSha = revisionInfo.OriginCommitSha ?? lastOriginCommitSha ?? model.Sha; revInfoSink?.Invoke(revisionInfo); model.RevisionInformation = revisionInfo.ToApi(); return needsDbUpdate; @@ -154,9 +153,9 @@ namespace Tgstation.Server.Host.Controllers Instance = Instance }; var api = currentModel.ToApi(); - await jobManager.RegisterOperation(job, async (paramJob, serviceProvider, ct) => + await jobManager.RegisterOperation(job, async (paramJob, serviceProvider, progressReporter, ct) => { - using (var repos = await repoManager.CloneRepository(new Uri(origin), cloneBranch, GetAccessString(currentModel), cancellationToken).ConfigureAwait(false)) + using (var repos = await repoManager.CloneRepository(new Uri(origin), cloneBranch, GetAccessString(currentModel), progressReporter, cancellationToken).ConfigureAwait(false)) { if (repos == null) throw new Exception("Filesystem conflict while cloning repository!"); @@ -201,7 +200,7 @@ namespace Tgstation.Server.Host.Controllers Instance = Instance }; var api = currentModel.ToApi(); - await jobManager.RegisterOperation(job, (paramJob, serviceProvider, ct) => instanceManager.GetInstance(Instance).RepositoryManager.DeleteRepository(cancellationToken), cancellationToken).ConfigureAwait(false); + await jobManager.RegisterOperation(job, (paramJob, serviceProvider, progressReporter, ct) => instanceManager.GetInstance(Instance).RepositoryManager.DeleteRepository(cancellationToken), cancellationToken).ConfigureAwait(false); api.ActiveJob = job.ToApi(); return Ok(); } @@ -348,12 +347,6 @@ namespace Tgstation.Server.Host.Controllers errorMessage = "P.R.E. NOT FOUND"; } - var attachedContextUser = new Models.User - { - Id = AuthenticationContext.User.Id - }; - DatabaseContext.Users.Attach(attachedContextUser); - var tm = new Models.TestMerge { Author = pr?.User.Login ?? errorMessage, @@ -362,7 +355,7 @@ namespace Tgstation.Server.Host.Controllers TitleAtMerge = pr?.Title ?? errorMessage, Comment = I.Comment, Number = I.Number, - MergedBy = attachedContextUser, + MergedBy = AuthenticationContext.User, PullRequestRevision = I.PullRequestRevision, Url = pr?.HtmlUrl ?? errorMessage }; @@ -397,7 +390,7 @@ namespace Tgstation.Server.Host.Controllers CancelRightsType = RightsType.Repository, CancelRight = (int)RepositoryRights.CancelSynchronize, }; - await jobManager.RegisterOperation(job, async (paramJob, serviceProvider, ct) => + await jobManager.RegisterOperation(job, async (paramJob, serviceProvider, progressReporter, ct) => { using (var repos = await instanceManager.GetInstance(Instance).RepositoryManager.LoadRepository(cancellationToken).ConfigureAwait(false)) if (repos != null) diff --git a/src/Tgstation.Server.Host/Core/IJobManager.cs b/src/Tgstation.Server.Host/Core/IJobManager.cs index 3eabf70612..35f8d5c56e 100644 --- a/src/Tgstation.Server.Host/Core/IJobManager.cs +++ b/src/Tgstation.Server.Host/Core/IJobManager.cs @@ -11,14 +11,19 @@ namespace Tgstation.Server.Host.Core /// public interface IJobManager { + /// + /// Get the for a job + /// + int? JobProgress(Job job); + /// /// Registers a given and begins running it /// /// The - /// The operation to run taking the started , a and a + /// The operation to run taking the started , a progress reporter and a /// The for the operation /// A representing a running operation - Task RegisterOperation(Job job, Func operation, CancellationToken cancellationToken); + Task RegisterOperation(Job job, Func, CancellationToken, Task> operation, CancellationToken cancellationToken); /// /// Cancels a give diff --git a/src/Tgstation.Server.Host/Core/JobHandler.cs b/src/Tgstation.Server.Host/Core/JobHandler.cs index ab05719268..d80bbd1322 100644 --- a/src/Tgstation.Server.Host/Core/JobHandler.cs +++ b/src/Tgstation.Server.Host/Core/JobHandler.cs @@ -32,6 +32,11 @@ namespace Tgstation.Server.Host.Core /// public void Dispose() => cancellationTokenSource.Dispose(); + /// + /// The progress of the job + /// + public int? Progress { get; set; } + /// /// Wait for to complete /// diff --git a/src/Tgstation.Server.Host/Core/JobManager.cs b/src/Tgstation.Server.Host/Core/JobManager.cs index 4d8359e438..88314172f0 100644 --- a/src/Tgstation.Server.Host/Core/JobManager.cs +++ b/src/Tgstation.Server.Host/Core/JobManager.cs @@ -105,7 +105,7 @@ namespace Tgstation.Server.Host.Core } /// - public async Task RegisterOperation(Job job, Func operation, CancellationToken cancellationToken) + public async Task RegisterOperation(Job job, Func, CancellationToken, Task> operation, CancellationToken cancellationToken) { using (var scope = serviceProvider.CreateScope()) { @@ -127,7 +127,14 @@ namespace Tgstation.Server.Host.Core } databaseContext.Jobs.Add(job); await databaseContext.Save(cancellationToken).ConfigureAwait(false); - var jobHandler = JobHandler.Create(x => RunJob(job, operation, x)); + var jobHandler = JobHandler.Create(x => RunJob(job, (jobParam, serviceProvider, ct) => + operation(jobParam, serviceProvider, y => + { + lock (this) + if (jobs.TryGetValue(job.Id, out var handler)) + handler.Progress = y; + }, ct), + x)); lock (this) jobs.Add(job.Id, jobHandler); } @@ -184,5 +191,16 @@ namespace Tgstation.Server.Host.Core await databaseContext.Save(cancellationToken).ConfigureAwait(false); } } + + /// + public int? JobProgress(Job job) + { + lock (this) + { + if (!jobs.TryGetValue(job.Id, out var handler)) + return null; + return handler.Progress; + } + } } } diff --git a/src/Tgstation.Server.Host/TgsAuthorizeAttribute.cs b/src/Tgstation.Server.Host/TgsAuthorizeAttribute.cs index 2281587fae..427a73b27c 100644 --- a/src/Tgstation.Server.Host/TgsAuthorizeAttribute.cs +++ b/src/Tgstation.Server.Host/TgsAuthorizeAttribute.cs @@ -19,54 +19,54 @@ namespace Tgstation.Server.Host /// Construct a for /// /// The rights required - public TgsAuthorizeAttribute(AdministrationRights requiredRights) => Roles = RightsHelper.RoleName(requiredRights); + public TgsAuthorizeAttribute(AdministrationRights requiredRights) => Roles = RightsHelper.RoleNames(requiredRights); /// /// Construct a for /// /// The rights required - public TgsAuthorizeAttribute(InstanceManagerRights requiredRights) => Roles = RightsHelper.RoleName(requiredRights); + public TgsAuthorizeAttribute(InstanceManagerRights requiredRights) => Roles = RightsHelper.RoleNames(requiredRights); /// /// Construct a for /// /// The rights required - public TgsAuthorizeAttribute(RepositoryRights requiredRights) => Roles = RightsHelper.RoleName(requiredRights); + public TgsAuthorizeAttribute(RepositoryRights requiredRights) => Roles = RightsHelper.RoleNames(requiredRights); /// /// Construct a for /// /// The rights required - public TgsAuthorizeAttribute(ByondRights requiredRights) => Roles = RightsHelper.RoleName(requiredRights); + public TgsAuthorizeAttribute(ByondRights requiredRights) => Roles = RightsHelper.RoleNames(requiredRights); /// /// Construct a for /// /// The rights required - public TgsAuthorizeAttribute(DreamMakerRights requiredRights) => Roles = RightsHelper.RoleName(requiredRights); + public TgsAuthorizeAttribute(DreamMakerRights requiredRights) => Roles = RightsHelper.RoleNames(requiredRights); /// /// Construct a for /// /// The rights required - public TgsAuthorizeAttribute(DreamDaemonRights requiredRights) => Roles = RightsHelper.RoleName(requiredRights); + public TgsAuthorizeAttribute(DreamDaemonRights requiredRights) => Roles = RightsHelper.RoleNames(requiredRights); /// /// Construct a for /// /// The rights required - public TgsAuthorizeAttribute(ChatSettingsRights requiredRights) => Roles = RightsHelper.RoleName(requiredRights); + public TgsAuthorizeAttribute(ChatSettingsRights requiredRights) => Roles = RightsHelper.RoleNames(requiredRights); /// /// Construct a for /// /// The rights required - public TgsAuthorizeAttribute(ConfigurationRights requiredRights) => Roles = RightsHelper.RoleName(requiredRights); + public TgsAuthorizeAttribute(ConfigurationRights requiredRights) => Roles = RightsHelper.RoleNames(requiredRights); /// /// Construct a for /// /// The rights required - public TgsAuthorizeAttribute(InstanceUserRights requiredRights) => Roles = RightsHelper.RoleName(requiredRights); + public TgsAuthorizeAttribute(InstanceUserRights requiredRights) => Roles = RightsHelper.RoleNames(requiredRights); } } diff --git a/tools/TGS.postman_collection.json b/tools/TGS.postman_collection.json index 92ea78f73b..a4153fa1d9 100644 --- a/tools/TGS.postman_collection.json +++ b/tools/TGS.postman_collection.json @@ -1321,14 +1321,14 @@ "raw": "{\n\t\"userId\": 1,\n\t\"byondRights\": -1,\n\t\"dreamDaemonRights\": -1,\n\t\"dreamMakerRights\": -1,\n\t\"repositoryRights\": -1,\n\t\"chatSettingsRights\": -1,\n\t\"configurationRights\": -1\n}" }, "url": { - "raw": "localhost:5000/Job/10", + "raw": "localhost:5000/Job/29", "host": [ "localhost" ], "port": "5000", "path": [ "Job", - "10" + "29" ] } }, @@ -1365,14 +1365,14 @@ "raw": "" }, "url": { - "raw": "localhost:5000/Job/11", + "raw": "localhost:5000/Job/20", "host": [ "localhost" ], "port": "5000", "path": [ "Job", - "11" + "20" ] } }, @@ -1403,6 +1403,408 @@ ], "_postman_isSubFolder": true }, + { + "name": "Byond", + "description": "", + "item": [ + { + "name": "List installed versions", + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "User-Agent", + "value": "Postman/1.0" + }, + { + "key": "User-Agent", + "value": "Tgstation.Server.Api/4.0.0.0" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "InstanceId", + "value": "1" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": 1,\n \"online\": false\n}" + }, + "url": { + "raw": "localhost:5000/Byond/List", + "host": [ + "localhost" + ], + "port": "5000", + "path": [ + "Byond", + "List" + ] + } + }, + "response": [] + }, + { + "name": "Read active version", + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "User-Agent", + "value": "Postman/1.0" + }, + { + "key": "User-Agent", + "value": "Tgstation.Server.Api/4.0.0.0" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "InstanceId", + "value": "1" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": 1,\n \"online\": false\n}" + }, + "url": { + "raw": "localhost:5000/Byond", + "host": [ + "localhost" + ], + "port": "5000", + "path": [ + "Byond" + ] + } + }, + "response": [] + }, + { + "name": "Set 511.1385 active", + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "User-Agent", + "value": "Postman/1.0" + }, + { + "key": "User-Agent", + "value": "Tgstation.Server.Api/4.0.0.0" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "InstanceId", + "value": "1" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"version\": {\n \t\"major\": 511,\n \t\"minor\": 1385\n }\n}" + }, + "url": { + "raw": "localhost:5000/Byond", + "host": [ + "localhost" + ], + "port": "5000", + "path": [ + "Byond" + ] + } + }, + "response": [] + }, + { + "name": "Set 512.1441 active", + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "User-Agent", + "value": "Postman/1.0" + }, + { + "key": "User-Agent", + "value": "Tgstation.Server.Api/4.0.0.0" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "InstanceId", + "value": "1" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"version\": {\n \t\"major\": 512,\n \t\"minor\": 1441\n }\n}" + }, + "url": { + "raw": "localhost:5000/Byond", + "host": [ + "localhost" + ], + "port": "5000", + "path": [ + "Byond" + ] + } + }, + "response": [] + } + ], + "_postman_isSubFolder": true + }, + { + "name": "Repo", + "description": "", + "item": [ + { + "name": "Read Info", + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "User-Agent", + "value": "Postman/1.0" + }, + { + "key": "User-Agent", + "value": "Tgstation.Server.Api/4.0.0.0" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "InstanceId", + "value": "1" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": 1,\n \"online\": false\n}" + }, + "url": { + "raw": "localhost:5000/Repository", + "host": [ + "localhost" + ], + "port": "5000", + "path": [ + "Repository" + ] + } + }, + "response": [] + }, + { + "name": "Just fetch", + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "User-Agent", + "value": "Postman/1.0" + }, + { + "key": "User-Agent", + "value": "Tgstation.Server.Api/4.0.0.0" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "InstanceId", + "value": "1" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"updateReference\": true\n}" + }, + "url": { + "raw": "localhost:5000/Repository", + "host": [ + "localhost" + ], + "port": "5000", + "path": [ + "Repository" + ] + } + }, + "response": [] + }, + { + "name": "Test merge some stuff", + "request": { + "method": "POST", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "User-Agent", + "value": "Postman/1.0" + }, + { + "key": "User-Agent", + "value": "Tgstation.Server.Api/4.0.0.0" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "InstanceId", + "value": "1" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"updateReference\": true,\n\t\"reference\": \"master\",\n\t\"newTestMerges\": [\n\t\t{\n\t\t\t\"number\": 39476,\n\t\t\t\"pullRequestRevision\": \"11edfe5\"\n\t\t},\n\t\t{\n\t\t\t\"number\": 39469,\n\t\t\t\"pullRequestRevision\": \"ee4f00d\",\n\t\t\t\"comment\": \"babby's first pr\"\n\t\t}\n\t\t]\n}" + }, + "url": { + "raw": "localhost:5000/Repository", + "host": [ + "localhost" + ], + "port": "5000", + "path": [ + "Repository" + ] + } + }, + "response": [] + }, + { + "name": "Clone tg", + "request": { + "method": "PUT", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "User-Agent", + "value": "Postman/1.0" + }, + { + "key": "User-Agent", + "value": "Tgstation.Server.Api/4.0.0.0" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "InstanceId", + "value": "1" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"origin\": \"https://github.com/tgstation/tgstation\"\n}" + }, + "url": { + "raw": "localhost:5000/Repository", + "host": [ + "localhost" + ], + "port": "5000", + "path": [ + "Repository" + ] + } + }, + "response": [] + }, + { + "name": "Delete", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Accept", + "value": "application/json" + }, + { + "key": "User-Agent", + "value": "Postman/1.0" + }, + { + "key": "User-Agent", + "value": "Tgstation.Server.Api/4.0.0.0" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "InstanceId", + "value": "1" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "localhost:5000/Repository", + "host": [ + "localhost" + ], + "port": "5000", + "path": [ + "Repository" + ] + } + }, + "response": [] + } + ], + "_postman_isSubFolder": true + }, { "name": "Online Instance ID 1", "request": { @@ -1601,185 +2003,6 @@ } ] }, - { - "name": "Byond", - "description": "", - "item": [ - { - "name": "List installed versions", - "request": { - "method": "GET", - "header": [ - { - "key": "Accept", - "value": "application/json" - }, - { - "key": "User-Agent", - "value": "Postman/1.0" - }, - { - "key": "User-Agent", - "value": "Tgstation.Server.Api/4.0.0.0" - }, - { - "key": "Content-Type", - "value": "application/json" - }, - { - "key": "InstanceId", - "value": "1" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"id\": 1,\n \"online\": false\n}" - }, - "url": { - "raw": "localhost:5000/Byond/List", - "host": [ - "localhost" - ], - "port": "5000", - "path": [ - "Byond", - "List" - ] - } - }, - "response": [] - }, - { - "name": "Read active version", - "request": { - "method": "GET", - "header": [ - { - "key": "Accept", - "value": "application/json" - }, - { - "key": "User-Agent", - "value": "Postman/1.0" - }, - { - "key": "User-Agent", - "value": "Tgstation.Server.Api/4.0.0.0" - }, - { - "key": "Content-Type", - "value": "application/json" - }, - { - "key": "InstanceId", - "value": "1" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"id\": 1,\n \"online\": false\n}" - }, - "url": { - "raw": "localhost:5000/Byond", - "host": [ - "localhost" - ], - "port": "5000", - "path": [ - "Byond" - ] - } - }, - "response": [] - }, - { - "name": "Set 511.1385 active", - "request": { - "method": "POST", - "header": [ - { - "key": "Accept", - "value": "application/json" - }, - { - "key": "User-Agent", - "value": "Postman/1.0" - }, - { - "key": "User-Agent", - "value": "Tgstation.Server.Api/4.0.0.0" - }, - { - "key": "Content-Type", - "value": "application/json" - }, - { - "key": "InstanceId", - "value": "1" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"version\": {\n \t\"major\": 511,\n \t\"minor\": 1385\n }\n}" - }, - "url": { - "raw": "localhost:5000/Byond", - "host": [ - "localhost" - ], - "port": "5000", - "path": [ - "Byond" - ] - } - }, - "response": [] - }, - { - "name": "Set 512.1441 active", - "request": { - "method": "POST", - "header": [ - { - "key": "Accept", - "value": "application/json" - }, - { - "key": "User-Agent", - "value": "Postman/1.0" - }, - { - "key": "User-Agent", - "value": "Tgstation.Server.Api/4.0.0.0" - }, - { - "key": "Content-Type", - "value": "application/json" - }, - { - "key": "InstanceId", - "value": "1" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"version\": {\n \t\"major\": 512,\n \t\"minor\": 1441\n }\n}" - }, - "url": { - "raw": "localhost:5000/Byond", - "host": [ - "localhost" - ], - "port": "5000", - "path": [ - "Byond" - ] - } - }, - "response": [] - } - ] - }, { "name": "Login Admin Default", "request": { diff --git a/v4_prototype_TODO.txt b/v4_prototype_TODO.txt index 8262e03165..bce08e2158 100644 --- a/v4_prototype_TODO.txt +++ b/v4_prototype_TODO.txt @@ -10,13 +10,12 @@ Verify the byond cache folder location on linux Server updates. Use FOLDERS so dependencies can be properly packaged -Fix this -TgsAuthorize attribute |'ing doesn't work due to role names, change to params[] -OR use pow2 to go up and reverse tocode the enums - Don't throw arg null exceptions with null [FromBody]'s, apparently that's allowed, return bad request instead Test repo Test byond Test compile Test watchdog -test configuration \ No newline at end of file +test configuration + +Think about how to preserve the LastOriginCommit while merging/test merging