Skip to content

Commit 93dc9c0

Browse files
committed
Initial commit
Signed-off-by: kvmw <mshamsi@broadcom.com>
0 parents  commit 93dc9c0

20 files changed

Lines changed: 422 additions & 0 deletions

.github/workflows/ci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
pull_request:
7+
branches: ['main']
8+
9+
jobs:
10+
greeter-messages:
11+
runs-on: ubuntu-latest
12+
name: Greeter Messages Service
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v4
20+
with:
21+
dotnet-version: '8.0.x'
22+
23+
- name: Restore dependencies
24+
run: dotnet restore greeter-messages/greeter-messages.csproj
25+
26+
- name: Check code formatting
27+
run: dotnet format --verify-no-changes greeter-messages/
28+
29+
- name: Build
30+
run: dotnet build greeter-messages/greeter-messages.csproj --no-restore --configuration Release
31+
32+
- name: Test
33+
run: dotnet test greeter-messages/greeter-messages.csproj --no-build --verbosity normal
34+
35+
greeter:
36+
runs-on: ubuntu-latest
37+
name: Greeter Service
38+
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
43+
- name: Setup .NET
44+
uses: actions/setup-dotnet@v4
45+
with:
46+
dotnet-version: '8.0.x'
47+
48+
- name: Restore dependencies
49+
run: dotnet restore greeter/greeter.csproj
50+
51+
- name: Check code formatting
52+
run: dotnet format --verify-no-changes greeter/
53+
54+
- name: Build
55+
run: dotnet build greeter/greeter.csproj --no-restore --configuration Release
56+
57+
- name: Test
58+
run: dotnet test greeter/greeter.csproj --no-build --verbosity normal
59+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*/bin/
2+
*/obj/

LICENSE

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
SOFTWARE LICENSE AGREEMENT
3+
4+
Copyright (c) VMware LLC. All rights reserved.
5+
6+
You are hereby granted a non-exclusive, worldwide, royalty-free license under VMware LLC’s copyrights to use, copy, modify, and distribute this software in source code or binary form for use in connection with VMware LLC products.
7+
8+
This copyright notice shall be included in all copies or substantial portions of the software.
9+
10+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Service Registry .NET sample
2+
3+
![CI](https://github.com/spring-cloud-services-samples/greeting-dotnet/actions/workflows/ci.yml/badge.svg)
4+
5+
Sample .NET application demonstrating the use of Service Registry in Tanzu Platform for Cloud Foundry.
6+
7+
For information on the Service Registry product in Tanzu Platform for Cloud Foundry, please [see the documentation](https://techdocs.broadcom.com/us/en/vmware-tanzu/spring/spring-cloud-services-for-cloud-foundry/3-3/scs-tanzu/service-registry-index.html).
8+
9+
## Building and Deploying
10+
11+
- Create a Service Registry instance:
12+
13+
```
14+
cf create-service p.service-registry standard greeter-service-registry
15+
```
16+
17+
- Push applications:
18+
19+
```
20+
cf push
21+
# or push each app separately
22+
cf push greeter-messages
23+
cf push greeter
24+
```
25+
26+
## Trying It Out
27+
28+
Call `[ROUTE]/hello`, where `[ROUTE]` is the route bound to the `greeter` application, with optional `name` and `salutation` parameters.
29+
30+
```
31+
$ curl "greeter.apps.example.cf-app.com/hello?name=John"
32+
Hello, John!
33+
```

greeter-messages/.editorconfig

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
root = true
2+
3+
[*.cs]
4+
# Indentation
5+
indent_style = space
6+
indent_size = 4
7+
8+
# New lines
9+
end_of_line = lf
10+
insert_final_newline = true
11+
charset = utf-8
12+
13+
# C# formatting
14+
csharp_new_line_before_open_brace = all
15+
csharp_new_line_before_else = true
16+
csharp_new_line_before_catch = true
17+
csharp_new_line_before_finally = true
18+
csharp_new_line_before_members_in_object_initializers = true
19+
csharp_new_line_before_members_in_anonymous_types = true
20+
21+
# Naming conventions
22+
dotnet_naming_rule.interface_should_be_prefixed_with_i.severity = warning
23+
dotnet_naming_rule.interface_should_be_prefixed_with_i.symbols = interface
24+
dotnet_naming_rule.interface_should_be_prefixed_with_i.style = prefix_interface_with_i
25+
26+
dotnet_naming_symbols.interface.applicable_kinds = interface
27+
dotnet_naming_style.prefix_interface_with_i.required_prefix = I
28+
29+
# Code style
30+
dotnet_style_qualification_for_field = false:suggestion
31+
dotnet_style_qualification_for_property = false:suggestion
32+
dotnet_style_qualification_for_method = false:suggestion
33+
dotnet_style_qualification_for_event = false:suggestion
34+
35+
# Expression-level preferences
36+
dotnet_style_object_initializer = true:suggestion
37+
dotnet_style_collection_initializer = true:suggestion
38+
dotnet_style_explicit_tuple_names = true:suggestion
39+
dotnet_style_null_propagation = true:suggestion
40+
dotnet_style_coalesce_expression = true:suggestion
41+
42+
[*.{json,yml,yaml}]
43+
indent_style = space
44+
indent_size = 2

greeter-messages/Program.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Steeltoe.Configuration.CloudFoundry;
2+
using Steeltoe.Configuration.CloudFoundry.ServiceBindings;
3+
using Steeltoe.Discovery.Eureka;
4+
5+
var builder = WebApplication.CreateBuilder(args);
6+
7+
builder.AddCloudFoundryConfiguration();
8+
builder.Configuration.AddCloudFoundryServiceBindings();
9+
builder.Services.AddEurekaDiscoveryClient();
10+
11+
var app = builder.Build();
12+
13+
app.UseHttpsRedirection();
14+
15+
app.MapGet("/greeting", (string? salutation, string? name) =>
16+
{
17+
salutation ??= "Hello";
18+
name ??= "Bob";
19+
20+
return $"{salutation}, {name}!";
21+
})
22+
.WithName("GetGreeting");
23+
24+
app.Run();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"http": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": true,
8+
"applicationUrl": "http://localhost:8080",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development"
11+
}
12+
},
13+
"https": {
14+
"commandName": "Project",
15+
"dotnetRunMessages": true,
16+
"launchBrowser": true,
17+
"applicationUrl": "https://localhost:8443;http://localhost:8080",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
}
22+
}
23+
}

greeter-messages/app.config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<configuration>
4+
<runtime>
5+
<gcServer enabled="true" />
6+
</runtime>
7+
</configuration>

greeter-messages/appsettings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
},
8+
"spring": {
9+
"application": {
10+
"name": "greeter-messages"
11+
}
12+
}
13+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Description>greeter-messages project</Description>
6+
<Nullable>enable</Nullable>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<NoWarn>SA1402;SA1600;SA0001;SA1633</NoWarn>
9+
</PropertyGroup>
10+
11+
<PropertyGroup>
12+
<SteeltoeVersion>4.0.*-*</SteeltoeVersion>
13+
</PropertyGroup>
14+
15+
<ItemGroup>
16+
<PackageReference Include="Steeltoe.Configuration.CloudFoundry" Version="$(SteeltoeVersion)" />
17+
<PackageReference Include="Steeltoe.Discovery.Eureka" Version="$(SteeltoeVersion)" />
18+
</ItemGroup>
19+
20+
<ItemGroup>
21+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507">
22+
<PrivateAssets>all</PrivateAssets>
23+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
24+
</PackageReference>
25+
</ItemGroup>
26+
27+
</Project>

0 commit comments

Comments
 (0)