Skip to content

Commit

Permalink
WIP WinlogBeat POC
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuriy committed Aug 22, 2019
1 parent 6e69a4d commit a33439d
Show file tree
Hide file tree
Showing 28 changed files with 866 additions and 1 deletion.
1 change: 1 addition & 0 deletions .buildroot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
keep
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
root=true

[*]
indent_style = space
indent_size = 4

[*.markdown]
indent_size = 2

[*.xaml]
indent_size = 2

[*.resx]
indent_size = 2

[*.json]
indent_size = 2
48 changes: 48 additions & 0 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
** Please read the guidelines below. **
Issues that do not follow these guidelines are likely to be closed.
GitHub is reserved for bug reports and feature requests. The best place to
ask a general question is at the Elastic forums: https://discuss.elastic.co/c/elasticsearch
GitHub is not the place for general questions.
Documentation for the Elasticsearch ODBC Driver Installer can be found at
https://www.elastic.co/guide/en/elasticsearch/sql-odbc/current/index.html
Be sure to select the documentation version relevant to the installer version you
are using.
### Failed Installations
If you are reporting an issue that occurred during installation, we ask that you
attach the installation log file to your issue to help diagnose the root cause.
The log file can be found in the %TEMP% directory with a randomly generated name adhering to the format MSI<random>.LOG. It should be the most recent log file.
When installing from the command-line, the log file can be captured by passing the /l*v <logfilename>
flag as per the documentation:
https://www.elastic.co/guide/en/elasticsearch/sql-odbc/current/sql-odbc-installation.html#installation-cmd
-->

### Environment

<!-- Operating system -->
<!-- Are you running behind a corporate proxy? -->
<!-- Where are you based geographically? -->

### Expected Behaviour

### Actual Behaviour

### Steps to reproduce the behaviour

1.
2.
3.

<!-- Attach any screenshots that may help -->
51 changes: 51 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## Project specific ignores

.vs

#build/*
#!build/scripts
#!build/scripts/*
#build/scripts/obj
#build/tools/vagrant/.vagrant
#!build/tools
#!build/tools/*



## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.msi

# Build results
[Dd]ebug/
[Rr]elease/
x64/
x86/
[Bb]in/
[Oo]bj/
*.wixobj

# Roslyn cache directories
*.ide/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# NuGet Packages
*.nupkg

# The packages folder can be ignored because of Package Restore
**/packages/*

# except build/, which is used as an MSBuild target.
!**/packages/build/
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
... tracks design/development process for wave two of Windows installers.
# Windows MSI packages for Elastic Beats (POC)

### Feature set

- Downloads and unpacks winlogbeat-7.3.0-windows-x86_64.zip (hardcoded).
- Builds MSI package, install as-a-service not supported yet.

### Requirements

- .net core sdk v2.2.401 (https://dotnet.microsoft.com/download/thank-you/dotnet-sdk-2.2.401-windows-x64-installer)
- Wix Toolset v3.11.1 (https://github.com/wixtoolset/wix3/releases/download/wix3111rtm/wix311.exe)

### Running

```
.\build winlogbeat
```

Run `.\build -t` to list available targets.

### Knonwn issues
- Lots, it's a POC
2 changes: 2 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
dotnet run --project %~dp0src\build\ElastiBuild.csproj -c Release -- %*
5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "2.2.401"
}
}
36 changes: 36 additions & 0 deletions src/ElastiBuild.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29209.62
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElastiBuild", "build\ElastiBuild.csproj", "{CDD2CCC6-3C0C-47CC-A7E5-93FC4BF2664A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "script", "script", "{6E880F89-0C6E-4BBC-88F6-5DF297901196}"
ProjectSection(SolutionItems) = preProject
..\build.bat = ..\build.bat
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CDD2CCC6-3C0C-47CC-A7E5-93FC4BF2664A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CDD2CCC6-3C0C-47CC-A7E5-93FC4BF2664A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CDD2CCC6-3C0C-47CC-A7E5-93FC4BF2664A}.Debug|x86.ActiveCfg = Debug|Any CPU
{CDD2CCC6-3C0C-47CC-A7E5-93FC4BF2664A}.Debug|x86.Build.0 = Debug|Any CPU
{CDD2CCC6-3C0C-47CC-A7E5-93FC4BF2664A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CDD2CCC6-3C0C-47CC-A7E5-93FC4BF2664A}.Release|Any CPU.Build.0 = Release|Any CPU
{CDD2CCC6-3C0C-47CC-A7E5-93FC4BF2664A}.Release|x86.ActiveCfg = Release|Any CPU
{CDD2CCC6-3C0C-47CC-A7E5-93FC4BF2664A}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F8D3B98B-337D-4629-8754-18EC48761229}
EndGlobalSection
EndGlobal
30 changes: 30 additions & 0 deletions src/Installer.Beats.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29209.62
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinlogBeat", "installer\WinlogBeat\WinlogBeat.csproj", "{F49E9F7B-B6F9-4422-9366-8A48D6C39D44}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "shared", "shared", "{BCCC594C-069C-4385-8329-52E26AAE2080}"
ProjectSection(SolutionItems) = preProject
installer\shared\CmdLineOptions.cs = installer\shared\CmdLineOptions.cs
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F49E9F7B-B6F9-4422-9366-8A48D6C39D44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F49E9F7B-B6F9-4422-9366-8A48D6C39D44}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F49E9F7B-B6F9-4422-9366-8A48D6C39D44}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F49E9F7B-B6F9-4422-9366-8A48D6C39D44}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {21598226-3BA2-433E-8447-A1A13B910D4D}
EndGlobalSection
EndGlobal
23 changes: 23 additions & 0 deletions src/build/BuildContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace ElastiBuild
{
public class BuildContext
{
public BuildContext(CmdLineOptions opts_)
{
Options = opts_;
}

public CmdLineOptions Options { get; private set; }

// TODO: remember these
public string SrcDir => Path.Combine(Options.BuildRoot, "src");
public string BinDir => Path.Combine(Options.BuildRoot, "bin");
public string InDir => Path.Combine(BinDir, "in");
public string OutDir => Path.Combine(BinDir, "out");
}
}
18 changes: 18 additions & 0 deletions src/build/BuildTargetBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace ElastiBuild.BuildTarget
{
public abstract class BuildTargetBase<T>
where T: BuildTargetBase<T>, new()
{
protected BuildContext Context;

public static T Create(BuildContext ctx_)
{
var tgt = new T
{
Context = ctx_
};

return tgt;
}
}
}
55 changes: 55 additions & 0 deletions src/build/BuildTargetSetup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using CommandLine;

using static Bullseye.Targets;

namespace ElastiBuild
{
partial class Program
{
// NOTE: In BullsEye v3.0 target names case sensitivity will go away.
// At this time .ToLower() and .Select() calls shuld be removed.
async Task BuildTaskSetup(CommandLine.Parser parser_, BuildContext ctx_)
{
Target(
"default",
DependsOn(nameof(BuildTarget.Help).ToLower()));

Target(
nameof(BuildTarget.Help).ToLower(),
BuildTarget.Help.Create(ctx_).Build);

Target(
nameof(BuildTarget.Clean).ToLower(),
BuildTarget.Clean.Create(ctx_).Build);

Target(
nameof(BuildTarget.ResolveArtifact).ToLower(),
BuildTarget.ResolveArtifact.Create(ctx_).Build);

Target(
nameof(BuildTarget.WinlogBeat).ToLower(),
DependsOn(
//nameof(BuildTarget.Clean).ToLower(),
nameof(BuildTarget.ResolveArtifact).ToLower()),
BuildTarget.WinlogBeat.Create(ctx_).Build);

Target(
"all",
DependsOn(
nameof(BuildTarget.WinlogBeat).ToLower()
));

IBullseyeOptions qq = ctx_.Options;
var ti = qq.GetType().GetProperties().SelectMany(x => x.GetCustomAttributes(typeof(OptionAttribute), false));

var opts = parser_.FormatCommandLine((IBullseyeOptions) ctx_.Options);
var tgts = ctx_.Options.BuildTargets ?? Enumerable.Empty<string>();
var args = tgts.Concat(opts.Split(' '));

await RunTargetsAndExitAsync(args);
}
}
}
16 changes: 16 additions & 0 deletions src/build/BuildTargets/Clean.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Threading.Tasks;

using static SimpleExec.Command;

namespace ElastiBuild.BuildTarget
{
public class Clean : BuildTargetBase<Clean>
{
public async Task Build()
{
Console.WriteLine($"----> Cleaning");
await Task.Yield();
}
}
}
34 changes: 34 additions & 0 deletions src/build/BuildTargets/Help.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Threading.Tasks;

namespace ElastiBuild.BuildTarget
{
public class Help : BuildTargetBase<Help>
{
public Task Build()
{
return Console.Out.WriteLineAsync(@"-= ElastiBuild =-
./build [target [target [...]]] [target options]
List available targets:
./build --list-tree
Target options:
--skip-tests Do not run tests
--cert-file Path to certificate file to sign .msi
--cert-pass Certificate password
Bullseye options:
-n, --dry-run Do a dry run without executing actions
-T, --list-targets List all (or specified) targets, then exit
-t, --list-tree List all (or specified) targets and dependency trees, then exit
-N, --no-color Disable colored output
-p, --parallel Run targets in parallel
-s, --skip-dependencies Do not run targets' dependencies
-v, --verbose Enable verbose output
-h, --help, -? Show this help, then exit (case insensitive)
");
}
}
}
Loading

0 comments on commit a33439d

Please sign in to comment.