Skip to content

Commit

Permalink
feat: Adds a "SandBox" option to the dotnet/cli so that our existing …
Browse files Browse the repository at this point in the history
…SDK validation mechanisms can remain unchanged (#134)

* intial draft on docs prototype

* fixes name typo

* adds sandbox

* updates the code template

* implements sandbox for .net

* adds sandbox as a cli option

* corrects the cli help text

* udpates JWT lib for consistency
  • Loading branch information
nickfloyd authored Oct 3, 2024
1 parent 27d9af9 commit 2ec04ba
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"name": "Debug Go post-processing",
"type": "go",
Expand All @@ -29,12 +30,11 @@
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/stage/dotnet/dotnet-sdk/cli/bin/Debug/net8.0/cli.dll",
"args": ["PersonalAccessToken"],
"args": ["Sandbox"],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole",
"logging": {
"engineLogging": false,
"moduleLoad": false
}
}
Expand Down
5 changes: 4 additions & 1 deletion stage/dotnet/dotnet-sdk-enterprise-cloud/cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ static async Task Main(string[] args)
{
if (args == null || args.Length == 0)
{
Console.WriteLine("Please provide an argument: 'AppInstallationToken' or 'PersonalAccessToken'");
Console.WriteLine("Please provide an argument: 'AppInstallationToken', 'PersonalAccessToken', or 'Sandbox'");
return;
}

Expand All @@ -35,6 +35,9 @@ static async Task Main(string[] args)
case "PersonalAccessToken":
await PersonalAccessToken.Run(approach);
break;
case "Sandbox":
await Example.Run();
break;
default:
Console.WriteLine("Invalid argument. Please provide 'AppInstallationToken' or 'PersonalAccessToken'");
break;
Expand Down
7 changes: 7 additions & 0 deletions stage/dotnet/dotnet-sdk-enterprise-cloud/cli/SandBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class Example
{
public static async Task Run()
{
Console.WriteLine("Hello, World!");
}
}
2 changes: 1 addition & 1 deletion stage/dotnet/dotnet-sdk-enterprise-cloud/cli/cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<RestoreSources>$(RestoreSources);../src/bin/Debug;https://api.nuget.org/v3/index.json</RestoreSources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.0.2" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.1.0" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.12.4" />
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.12.4" />
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.12.4" />
Expand Down
5 changes: 4 additions & 1 deletion stage/dotnet/dotnet-sdk-enterprise-server/cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ static async Task Main(string[] args)
{
if (args == null || args.Length == 0)
{
Console.WriteLine("Please provide an argument: 'AppInstallationToken' or 'PersonalAccessToken'");
Console.WriteLine("Please provide an argument: 'AppInstallationToken', 'PersonalAccessToken', or 'Sandbox'");
return;
}

Expand All @@ -35,6 +35,9 @@ static async Task Main(string[] args)
case "PersonalAccessToken":
await PersonalAccessToken.Run(approach);
break;
case "Sandbox":
await Example.Run();
break;
default:
Console.WriteLine("Invalid argument. Please provide 'AppInstallationToken' or 'PersonalAccessToken'");
break;
Expand Down
7 changes: 7 additions & 0 deletions stage/dotnet/dotnet-sdk-enterprise-server/cli/SandBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class Example
{
public static async Task Run()
{
Console.WriteLine("Hello, World!");
}
}
2 changes: 1 addition & 1 deletion stage/dotnet/dotnet-sdk-enterprise-server/cli/cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<RestoreSources>$(RestoreSources);../src/bin/Debug;https://api.nuget.org/v3/index.json</RestoreSources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.0.2" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.1.0" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.12.4" />
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.12.4" />
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.12.4" />
Expand Down
7 changes: 5 additions & 2 deletions stage/dotnet/dotnet-sdk/cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ static async Task Main(string[] args)
{
if (args == null || args.Length == 0)
{
Console.WriteLine("Please provide an argument: 'AppInstallationToken' or 'PersonalAccessToken'");
Console.WriteLine("Please provide an argument: 'AppInstallationToken' or 'PersonalAccessToken' or 'Sandbox'");
return;
}

Expand All @@ -35,8 +35,11 @@ static async Task Main(string[] args)
case "PersonalAccessToken":
await PersonalAccessToken.Run(approach);
break;
case "Sandbox":
await Example.Run();
break;
default:
Console.WriteLine("Invalid argument. Please provide 'AppInstallationToken' or 'PersonalAccessToken'");
Console.WriteLine("Invalid argument. Please provide 'AppInstallationToken', 'PersonalAccessToken', or 'Sandbox'");
break;
}
}
Expand Down
21 changes: 21 additions & 0 deletions stage/dotnet/dotnet-sdk/cli/SandBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using GitHub;
using GitHub.Octokit.Client;
using GitHub.Octokit.Client.Authentication;
using Microsoft.Kiota.Abstractions;
using System.Net.Http;
using System.IO;


public class Example
{
public static async Task Run()
{
Console.WriteLine("Hello, World!");
var tokenProvider = new TokenProvider(Environment.GetEnvironmentVariable("GITHUB_TOKEN") ?? "");
var adapter = RequestAdapter.Create(new TokenAuthProvider(tokenProvider));
var gitHubClient = new GitHubClient(adapter);

var response = await gitHubClient.Repos["octokit"]["octokit.net"].Contents["LICENSE.txt"].GetAsync();
var content = await response.ReadContentAsStringAsync();
}
}
2 changes: 1 addition & 1 deletion stage/dotnet/dotnet-sdk/cli/cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<RestoreSources>$(RestoreSources);../src/bin/Debug;https://api.nuget.org/v3/index.json</RestoreSources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.0.2" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.1.0" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.12.4" />
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.12.4" />
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.12.4" />
Expand Down

0 comments on commit 2ec04ba

Please sign in to comment.