From 3dca490c6df221f510667158092bd0bb789520a0 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Thu, 8 Nov 2018 09:28:43 +1000 Subject: [PATCH 1/7] add an initial dockerfile --- dockerfiles/seqcli/.gitignore | 1 + dockerfiles/seqcli/Dockerfile | 25 +++++++++++++++++++++++++ dockerfiles/seqcli/run.sh | 6 ++++++ 3 files changed, 32 insertions(+) create mode 100644 dockerfiles/seqcli/.gitignore create mode 100644 dockerfiles/seqcli/Dockerfile create mode 100755 dockerfiles/seqcli/run.sh diff --git a/dockerfiles/seqcli/.gitignore b/dockerfiles/seqcli/.gitignore new file mode 100644 index 00000000..6be5221d --- /dev/null +++ b/dockerfiles/seqcli/.gitignore @@ -0,0 +1 @@ +seqcli.tar.gz \ No newline at end of file diff --git a/dockerfiles/seqcli/Dockerfile b/dockerfiles/seqcli/Dockerfile new file mode 100644 index 00000000..4571abc4 --- /dev/null +++ b/dockerfiles/seqcli/Dockerfile @@ -0,0 +1,25 @@ +# based on: https://github.com/dotnet/dotnet-docker/blob/master/2.0/runtime-deps/jessie/amd64/Dockerfile + +FROM ubuntu:18.04 + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + ca-certificates \ + liblmdb-dev \ + libc6 \ + libgcc1 \ + libgssapi-krb5-2 \ + libicu60 \ + liblttng-ust0 \ + libssl1.0.0 \ + libstdc++6 \ + zlib1g \ +&& rm -rf /var/lib/apt/lists/* + +COPY run.sh /run.sh +ADD seqcli.tar.gz /tmp/ +RUN mv /tmp/seqcli-* /bin/seqcli + +ENTRYPOINT ["/run.sh"] + +LABEL Description="Seq" Vendor="Datalust Pty Ltd" diff --git a/dockerfiles/seqcli/run.sh b/dockerfiles/seqcli/run.sh new file mode 100755 index 00000000..33e2c492 --- /dev/null +++ b/dockerfiles/seqcli/run.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# Default arguments to those passed to the container +args=$@ + +exec /bin/seqcli/seqcli $args From 39dcd4b22634f304c0b26f46d1c4d38f0d07e598 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Fri, 9 Nov 2018 08:54:17 +1000 Subject: [PATCH 2/7] add note about the docker container --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index f84ae153..832e0dc4 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,14 @@ seqcli config -k connection.serverUrl -v https://your-seq-server This will create `SeqConfig.json` in your home directory. A default API key can also be set by providing the `connection.apiKey` setting name. +`seqcli` is also available as a Docker container under [`datalust/seqcli`](https://store.docker.com/community/images/datalust/seqcli): + +``` +docker run --rm datalust/seqcli:latest [] +``` + +Use Docker networks and volumes to make local files and other containers accessible to `seqcli` within its container. + ## Commands Usage: From a327714431854801f79ce1bb6050ced958576c5d Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 8 Jan 2019 13:21:52 +1000 Subject: [PATCH 3/7] Fixes #87 - update to a version of Serilog.Filters.Expressions that's compatible with Superpower 2.0 --- src/SeqCli/SeqCli.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SeqCli/SeqCli.csproj b/src/SeqCli/SeqCli.csproj index ea193301..7994c882 100644 --- a/src/SeqCli/SeqCli.csproj +++ b/src/SeqCli/SeqCli.csproj @@ -21,7 +21,7 @@ - + From 69eb39f8f473a3a40b470847d6f2f093731d8df5 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 8 Jan 2019 13:27:46 +1000 Subject: [PATCH 4/7] Cherry-pick from #86 - opt out of managed sockets on Windows so that proxy settings etc. are respected --- Build.ps1 | 2 +- SeqCli.Runtime.targets | 20 ++++++++++++++++++++ seqcli.sln | 1 + src/SeqCli/Program.cs | 8 +++++++- src/SeqCli/SeqCli.csproj | 1 + 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 SeqCli.Runtime.targets diff --git a/Build.ps1 b/Build.ps1 index b2db9f40..99f6f349 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -27,7 +27,7 @@ function Publish-Archives($version) { $rids = @("linux-x64", "osx-x64", "win-x64") foreach ($rid in $rids) { - & dotnet publish src/SeqCli/SeqCli.csproj -c Release -f $framework -r $rid /p:VersionPrefix=$version /p:ShowLinkerSizeComparison=true + & dotnet publish src/SeqCli/SeqCli.csproj -c Release -f $framework -r $rid /p:VersionPrefix=$version /p:SeqCliRid=$rid /p:ShowLinkerSizeComparison=true if($LASTEXITCODE -ne 0) { exit 4 } # Make sure the archive contains a reasonable root filename diff --git a/SeqCli.Runtime.targets b/SeqCli.Runtime.targets new file mode 100644 index 00000000..ed4e9b56 --- /dev/null +++ b/SeqCli.Runtime.targets @@ -0,0 +1,20 @@ + + + + true + + + true + $(DefineConstants);WINDOWS + + + true + true + $(DefineConstants);LINUX;UNIX + + + true + true + $(DefineConstants);MACOS;UNIX + + diff --git a/seqcli.sln b/seqcli.sln index 75f0eb9f..ddd2f71c 100644 --- a/seqcli.sln +++ b/seqcli.sln @@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{2EA56595-519 Build.ps1 = Build.ps1 LICENSE = LICENSE README.md = README.md + SeqCli.Runtime.targets = SeqCli.Runtime.targets EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{3587B633-0C03-4235-8903-6226900328F1}" diff --git a/src/SeqCli/Program.cs b/src/SeqCli/Program.cs index 6dcc49c7..7abab8fa 100644 --- a/src/SeqCli/Program.cs +++ b/src/SeqCli/Program.cs @@ -1,4 +1,4 @@ -// Copyright 2018 Datalust Pty Ltd +// Copyright 2018-2019 Datalust Pty Ltd // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -27,6 +27,12 @@ class Program { static async Task Main(string[] args) { +#if WINDOWS + // This reverts to using the WinHTTP stack instead of managed sockets, so that + // Windows proxy settings are respected + AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false); +#endif + Log.Logger = new LoggerConfiguration() .MinimumLevel.Error() .WriteTo.Console( diff --git a/src/SeqCli/SeqCli.csproj b/src/SeqCli/SeqCli.csproj index ea193301..f2c21be1 100644 --- a/src/SeqCli/SeqCli.csproj +++ b/src/SeqCli/SeqCli.csproj @@ -11,6 +11,7 @@ x64 7.2 + From 252ebd9aa437269873ca4a32989ae01640f61865 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 8 Jan 2019 13:30:40 +1000 Subject: [PATCH 5/7] Update Serilog dependency --- src/SeqCli/SeqCli.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SeqCli/SeqCli.csproj b/src/SeqCli/SeqCli.csproj index 7994c882..4cfa4bc9 100644 --- a/src/SeqCli/SeqCli.csproj +++ b/src/SeqCli/SeqCli.csproj @@ -20,7 +20,7 @@ - + @@ -31,4 +31,4 @@ - \ No newline at end of file + From 2dcb9fd1e022e681858f997a0469e68b0e70a244 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 8 Jan 2019 13:42:45 +1000 Subject: [PATCH 6/7] Fixes #85 - convert enums to strings in JSON output representing entities --- .../Cli/Features/OutputFormatFeature.cs | 10 +++++++- .../ApiKey/ApiKeyCreateTestCase.cs | 25 +++++++++++++++++++ .../Dashboard/RenderTestCase.cs | 2 +- .../Signal/SignalBasicsTestCase.cs | 2 +- 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 test/SeqCli.EndToEnd/ApiKey/ApiKeyCreateTestCase.cs diff --git a/src/SeqCli/Cli/Features/OutputFormatFeature.cs b/src/SeqCli/Cli/Features/OutputFormatFeature.cs index 434b94c8..e9b1f1e2 100644 --- a/src/SeqCli/Cli/Features/OutputFormatFeature.cs +++ b/src/SeqCli/Cli/Features/OutputFormatFeature.cs @@ -14,6 +14,8 @@ using System; using Destructurama; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using Seq.Api.Model; using SeqCli.Config; @@ -88,7 +90,13 @@ public void WriteEntity(Entity entity) { if (entity == null) throw new ArgumentNullException(nameof(entity)); - var jo = JObject.FromObject(entity); + var jo = JObject.FromObject( + entity, + JsonSerializer.CreateDefault(new JsonSerializerSettings { + Converters = { + new StringEnumConverter() + } + })); if (_json) { diff --git a/test/SeqCli.EndToEnd/ApiKey/ApiKeyCreateTestCase.cs b/test/SeqCli.EndToEnd/ApiKey/ApiKeyCreateTestCase.cs new file mode 100644 index 00000000..4d749d1f --- /dev/null +++ b/test/SeqCli.EndToEnd/ApiKey/ApiKeyCreateTestCase.cs @@ -0,0 +1,25 @@ +using System.Threading.Tasks; +using Seq.Api; +using SeqCli.EndToEnd.Support; +using Serilog; +using Xunit; + +namespace SeqCli.EndToEnd.ApiKey +{ + public class ApiKeyCreateTestCase : ICliTestCase + { + public Task ExecuteAsync(SeqConnection connection, ILogger logger, CliCommandRunner runner) + { + var exit = runner.Exec("apikey create", "-t Test"); + Assert.Equal(0, exit); + + exit = runner.Exec("apikey list", "-t Test --no-color"); + Assert.Equal(0, exit); + + var output = runner.LastRunProcess.Output; + Assert.Contains("\"AssignedPermissions\":[\"Ingest\"]", output); + + return Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/test/SeqCli.EndToEnd/Dashboard/RenderTestCase.cs b/test/SeqCli.EndToEnd/Dashboard/RenderTestCase.cs index c2fba3a1..ff3ed650 100644 --- a/test/SeqCli.EndToEnd/Dashboard/RenderTestCase.cs +++ b/test/SeqCli.EndToEnd/Dashboard/RenderTestCase.cs @@ -7,7 +7,7 @@ namespace SeqCli.EndToEnd.Dashboard { - public class RenderTestcase : ICliTestCase + public class RenderTestCase : ICliTestCase { public Task ExecuteAsync( SeqConnection connection, diff --git a/test/SeqCli.EndToEnd/Signal/SignalBasicsTestCase.cs b/test/SeqCli.EndToEnd/Signal/SignalBasicsTestCase.cs index 3efbee9a..60c4eab8 100644 --- a/test/SeqCli.EndToEnd/Signal/SignalBasicsTestCase.cs +++ b/test/SeqCli.EndToEnd/Signal/SignalBasicsTestCase.cs @@ -6,7 +6,7 @@ namespace SeqCli.EndToEnd.Signal { - public class SignalBasicsTestcase : ICliTestCase + public class SignalBasicsTestCase : ICliTestCase { public Task ExecuteAsync( SeqConnection connection, From 2c5e089940fce188dad699002d619f6307a54e3f Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 8 Jan 2019 13:46:45 +1000 Subject: [PATCH 7/7] Opt out of any potential date parsing inference --- src/SeqCli/Cli/Features/OutputFormatFeature.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SeqCli/Cli/Features/OutputFormatFeature.cs b/src/SeqCli/Cli/Features/OutputFormatFeature.cs index e9b1f1e2..d6568263 100644 --- a/src/SeqCli/Cli/Features/OutputFormatFeature.cs +++ b/src/SeqCli/Cli/Features/OutputFormatFeature.cs @@ -93,6 +93,7 @@ public void WriteEntity(Entity entity) var jo = JObject.FromObject( entity, JsonSerializer.CreateDefault(new JsonSerializerSettings { + DateParseHandling = DateParseHandling.None, Converters = { new StringEnumConverter() }