Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
.vscode
debug.log

# IDEA
.idea/
*.DotSettings.user

# .NET Core
bin
obj
Expand All @@ -18,4 +22,5 @@ cloudformation.json
params.yml
appsettings.Development.json
src/CloudFormationResourceSpecification.json
tmp/
tmp/
*~
8 changes: 8 additions & 0 deletions .idea/.idea.LambdaSharpTool/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/.idea.LambdaSharpTool/.idea/projectSettingsUpdater.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/.idea.LambdaSharpTool/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Deterministic>true</Deterministic>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<RootNamespace>DemoS3Subscriber.Subscriber</RootNamespace>
Expand Down
2 changes: 1 addition & 1 deletion Demos/SlackTodo/SlackCommand/SlackCommand.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Deterministic>true</Deterministic>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<NoWarn>CS1998</NoWarn>
Expand Down
2 changes: 1 addition & 1 deletion Demos/TwitterNotifier/NotifyFunction/NotifyFunction.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Deterministic>true</Deterministic>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<RootNamespace>Demo.TwitterNotifier.NotifyFunction</RootNamespace>
Expand Down
1,114 changes: 1,114 additions & 0 deletions LambdaSharpTool.sln

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Libraries/LambdaSharp.Build/LambdaSharp.Build.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>LambdaSharp.Build</RootNamespace>
<Nullable>enable</Nullable>
<NoWarn>CS1998</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>LambdaSharp.CloudFormation</RootNamespace>
<Nullable>enable</Nullable>
<NoWarn>CS1998</NoWarn>
Expand Down
4 changes: 2 additions & 2 deletions Libraries/LambdaSharp.Modules/LambdaSharp.Modules.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>LambdaSharp.Modules</RootNamespace>
<Nullable>enable</Nullable>
<NoWarn>CS1998</NoWarn>
<NoWarn>CS1998;SYSLIB0051</NoWarn>
<ImplicitUsings>enable</ImplicitUsings>
<WarningLevel>9999</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down
4 changes: 4 additions & 0 deletions Libraries/LambdaSharp.Modules/VersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public static VersionInfo Parse(string text) {
build = -1;
revision = -1;
} else {
var versionHashArray = versionText.Split('+');
if (versionHashArray.Length > 1) {
versionText = versionHashArray[0];
}
var version = Version.Parse(versionText);

// assign parts of the parsed version information
Expand Down
12 changes: 10 additions & 2 deletions Libraries/LambdaSharp.Modules/VersionInfoCompatibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static bool IsReadyToRunSupported(string framework)

// NOTE (2022-03-04, bjorg): ReadyToRun is supported as of .NET Core 3.0
=> framework switch {
"netcoreapp3.0" or "netcoreapp3.1" or "net5.0" or "net6.0" => true,
"netcoreapp3.0" or "netcoreapp3.1" or "net5.0" or "net6.0" or "net8.0" => true,
_ => false
};

Expand Down Expand Up @@ -130,12 +130,20 @@ public static bool IsValidLambdaSharpAssemblyReferenceForToolVersion(VersionInfo
break;
case "net6":
case "net6.0":

// .NET 6 projects require 0.8.4.*
valid = (libraryVersion.Major == 0)
&& (libraryVersion.Minor == 8)
&& (libraryVersion.Build == 4);
break;
case "net8":
case "net8.0":

// .NET 8 projects require 0.8.5.* or higher
valid = (libraryVersion.Major == 0)
&& (libraryVersion.Minor == 8)
&& (libraryVersion.Build >= 5);
break;
default:
throw new VersionInfoCompatibilityUnsupportedFrameworkException(projectFramework);
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/LambdaSharp.App.Api/Finalizer/Finalizer.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Deterministic>true</Deterministic>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Deterministic>true</Deterministic>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Deterministic>true</Deterministic>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Deterministic>true</Deterministic>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<NoWarn>CS1998</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>LambdaSharp.CloudFormation.Preprocessor</RootNamespace>
<Nullable>enable</Nullable>
<NoWarn>CS1998</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Deterministic>true</Deterministic>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Deterministic>true</Deterministic>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
Expand Down
2 changes: 1 addition & 1 deletion Modules/LambdaSharp.Core/CommonLib/CommonLib.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Deterministic>true</Deterministic>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<RootNamespace>LambdaSharp.Core</RootNamespace>
Expand Down
10 changes: 10 additions & 0 deletions Modules/LambdaSharp.Core/CommonLib/RollbarApi/Rollbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,13 @@ public class Frame {
[JsonPropertyName("method")]
public string? Method { get; set; }
}

public class RollbarTeam {

//--- Properties ---
[JsonPropertyName("id")]
public int Id { get; set; }

[JsonPropertyName("name")]
public string? Name { get; set; }
}
101 changes: 93 additions & 8 deletions Modules/LambdaSharp.Core/CommonLib/RollbarApi/RollbarClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,11 @@ public async Task<RollbarProject> CreateProjectAsync(string projectName) {
public async Task<IEnumerable<RollbarProject>> ListAllProjectsAsync() {
LogInfo($"list all rollbar projects");
var httpResponse = await HttpClient.SendAsync(new HttpRequestMessage {
RequestUri = new Uri($"https://api.rollbar.com/api/1/projects/?access_token={_accountReadAccessToken}"),
Method = HttpMethod.Get
RequestUri = new Uri($"https://api.rollbar.com/api/1/projects/?limit=100"),
Method = HttpMethod.Get,
Headers = {
{ "X-Rollbar-Access-Token", _accountReadAccessToken }
}
});
if(!httpResponse.IsSuccessStatusCode) {
throw new RollbarClientException($"http operation failed: {httpResponse.StatusCode}");
Expand All @@ -199,8 +202,11 @@ public async Task<IEnumerable<RollbarProject>> ListAllProjectsAsync() {
public async Task<RollbarProject> GetProjectAsync(int projectId) {
LogInfo($"get rollbar project {projectId}");
var httpResponse = await HttpClient.SendAsync(new HttpRequestMessage {
RequestUri = new Uri($"https://api.rollbar.com/api/1/project/{projectId}?access_token={_accountReadAccessToken}"),
Method = HttpMethod.Get
RequestUri = new Uri($"https://api.rollbar.com/api/1/project/{projectId}"),
Method = HttpMethod.Get,
Headers = {
{ "X-Rollbar-Access-Token", _accountReadAccessToken }
}
});
if(!httpResponse.IsSuccessStatusCode) {
throw new RollbarClientException($"http operation failed: {httpResponse.StatusCode}");
Expand All @@ -215,8 +221,11 @@ public async Task<RollbarProject> GetProjectAsync(int projectId) {
public async Task DeleteProjectAsync(int projectId) {
LogInfo($"delete rollbar project {projectId}");
var httpResponse = await HttpClient.SendAsync(new HttpRequestMessage {
RequestUri = new Uri($"https://api.rollbar.com/api/1/project/{projectId}?access_token={_accountWriteAccessToken}"),
Method = HttpMethod.Delete
RequestUri = new Uri($"https://api.rollbar.com/api/1/project/{projectId}"),
Method = HttpMethod.Delete,
Headers = {
{ "X-Rollbar-Access-Token", _accountWriteAccessToken }
}
});
if(!httpResponse.IsSuccessStatusCode) {
throw new RollbarClientException($"http operation failed: {httpResponse.StatusCode}");
Expand All @@ -230,8 +239,11 @@ public async Task DeleteProjectAsync(int projectId) {
public async Task<IEnumerable<RollbarProjectToken>> ListProjectTokensAsync(int projectId) {
LogInfo($"list rollbar project tokens {projectId}");
var httpResponse = await HttpClient.SendAsync(new HttpRequestMessage {
RequestUri = new Uri($"https://api.rollbar.com/api/1/project/{projectId}/access_tokens?access_token={_accountReadAccessToken}"),
Method = HttpMethod.Get
RequestUri = new Uri($"https://api.rollbar.com/api/1/project/{projectId}/access_tokens"),
Method = HttpMethod.Get,
Headers = {
{ "X-Rollbar-Access-Token", _accountReadAccessToken }
}
});
if(!httpResponse.IsSuccessStatusCode) {
throw new RollbarClientException($"http operation failed: {httpResponse.StatusCode}");
Expand All @@ -243,5 +255,78 @@ public async Task<IEnumerable<RollbarProjectToken>> ListProjectTokensAsync(int p
return Deserialize<List<RollbarProjectToken>>(Serialize(result.Result));
}

public async Task<RollbarProjectToken> CreateProjectTokenAsync(int projectId, string tokenName, string[] scopes) {
LogInfo($"creating rollbar project token '{tokenName}' for project {projectId} with scopes: {string.Join(", ", scopes)}");
var requestBody = new {
name = tokenName,
scopes = scopes
};
var httpResponse = await HttpClient.SendAsync(new HttpRequestMessage {
RequestUri = new Uri($"https://api.rollbar.com/api/1/project/{projectId}/access_tokens"),
Method = HttpMethod.Post,
Content = new StringContent(Serialize(requestBody), Encoding.UTF8, "application/json"),
Headers = {
{ "X-Rollbar-Access-Token", _accountWriteAccessToken }
}
});
if(!httpResponse.IsSuccessStatusCode) {
throw new RollbarClientException($"http operation failed: {httpResponse.StatusCode}");
}
var result = Deserialize<RollbarResponse>(await httpResponse.Content.ReadAsStringAsync());
if(result.Error != 0) {
throw new RollbarClientException($"rollbar operation failed (error {result.Error}): {result.Message}");
}
var token = Deserialize<RollbarProjectToken>(Serialize(result.Result));
LogInfo($"created rollbar project token '{token.Name}' (status: {token.Status}) for project {projectId}");
return token;
}

public async Task AssignProjectToEngineeringTeamAsync(int projectId) {
const string ENGINEERING_TEAM_NAME = "Engineering";
LogInfo($"finding team '{ENGINEERING_TEAM_NAME}'");

// Get all teams
var httpResponse = await HttpClient.SendAsync(new HttpRequestMessage {
RequestUri = new Uri("https://api.rollbar.com/api/1/teams?limit=100"),
Method = HttpMethod.Get,
Headers = {{ "X-Rollbar-Access-Token", _accountReadAccessToken }}
});
if(!httpResponse.IsSuccessStatusCode) {
throw new RollbarClientException($"http operation failed: {httpResponse.StatusCode}");
}
var result = Deserialize<RollbarResponse>(await httpResponse.Content.ReadAsStringAsync());
if(result.Error != 0) {
throw new RollbarClientException($"rollbar operation failed (error {result.Error}): {result.Message}");
}

// Parse teams and find Engineering
var teamsJson = Serialize(result.Result);
var teams = Deserialize<List<RollbarTeam>>(teamsJson);
var engineeringTeam = teams?.FirstOrDefault(t =>
t.Name?.Equals(ENGINEERING_TEAM_NAME, StringComparison.OrdinalIgnoreCase) == true
);

if(engineeringTeam == null) {
throw new RollbarClientException($"team '{ENGINEERING_TEAM_NAME}' not found");
}

var teamId = engineeringTeam.Id;
LogInfo($"assigning rollbar project {projectId} to team '{ENGINEERING_TEAM_NAME}' (ID: {teamId})");

httpResponse = await HttpClient.SendAsync(new HttpRequestMessage {
RequestUri = new Uri($"https://api.rollbar.com/api/1/team/{teamId}/project/{projectId}"),
Method = HttpMethod.Put,
Headers = {{ "X-Rollbar-Access-Token", _accountWriteAccessToken }}
});
if(!httpResponse.IsSuccessStatusCode) {
throw new RollbarClientException($"http operation failed: {httpResponse.StatusCode}");
}
result = Deserialize<RollbarResponse>(await httpResponse.Content.ReadAsStringAsync());
if(result.Error != 0) {
throw new RollbarClientException($"rollbar operation failed (error {result.Error}): {result.Message}");
}
LogInfo($"assigned rollbar project {projectId} to team '{ENGINEERING_TEAM_NAME}'");
}

private void LogInfo(string message) => _logInfo?.Invoke(message);
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public override async Task InitializeAsync(LambdaConfig config) {
_registrations = new RegistrationTable(dynamoClient, tableName);
_cachedRegistrations = new Dictionary<string, OwnerMetaData>();
_rollbarClient = new RollbarClient(
httpClient: null,
HttpClient,
accountReadAccessToken: null,
accountWriteAccessToken: null,
message => LogInfo(message)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Deterministic>true</Deterministic>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<RootNamespace>LambdaSharp.Core.LoggingStreamAnalyzerFunction</RootNamespace>
Expand Down
Loading