Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update samples #340

Merged
merged 8 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@cloudfoundry_scaffold
Feature: Steeltoe Configuration
In order to show you how to use Steeltoe with IConfiguration
You can run the configuration sample

@net8.0
@linux
Scenario: Steeltoe Configuration (net8.0/linux)
When you run: dotnet build
And you run in the background: cf push -f manifest.yml
And you wait until CloudFoundry app configuration-providers-sample is started
When you get https://configuration-providers-sample/Home/ExternalConfigurationData
Then you should see "Property bar = spam"
When you get https://configuration-providers-sample/Home/ConfigServerSettings
Then you should see "spring:cloud:config:name = foo"
When you get https://configuration-providers-sample/Home/CloudFoundry
Then you should see "vcap:application:application_name = configuration-providers-sample"
When you get https://configuration-providers-sample/Home/PlaceholderValues
Then you should see "ResolvedFromJsonInformation"

@net8.0
@windows
Scenario: Steeltoe Configuration (net8.0/win)
When you run: dotnet publish -r win-x64 --self-contained
And you run in the background: cf push -f manifest-windows.yml -p bin/Release/net8.0/win-x64/publish
And you wait until CloudFoundry app configuration-providers-sample is started
When you get https://configuration-providers-sample/Home/ExternalConfigurationData
Then you should see "Property bar = spam"
When you get https://configuration-providers-sample/Home/ConfigServerSettings
Then you should see "spring:cloud:config:name = foo"
When you get https://configuration-providers-sample/Home/CloudFoundry
Then you should see "vcap:application:application_name = configuration-providers-sample"
When you get https://configuration-providers-sample/Home/PlaceholderValues
Then you should see "ResolvedFromJsonInformation"
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@
using Microsoft.Extensions.Options;
using Steeltoe.Configuration.CloudFoundry;
using Steeltoe.Configuration.ConfigServer;
using Steeltoe.Samples.Configuration.Models;
using Steeltoe.Samples.ConfigurationProviders.Models;

namespace Steeltoe.Samples.Configuration.Controllers;
namespace Steeltoe.Samples.ConfigurationProviders.Controllers;

public sealed class HomeController(
IOptionsSnapshot<ExternalConfiguration> configServerDataSnapshot, IOptionsSnapshot<ConfigServerClientOptions> configServerClientOptions,
IOptionsSnapshot<PlaceholderValues> placeholderValues, IOptions<CloudFoundryApplicationOptions> appOptions,
IOptions<CloudFoundryServicesOptions> serviceOptions, IConfiguration configuration) : Controller
{
private readonly ExternalConfiguration _dataSnapshot = configServerDataSnapshot.Value;

private readonly ConfigServerClientOptions _configServerClientOptions = configServerClientOptions.Value;

private readonly PlaceholderValues _placeholderResolverValues = placeholderValues.Value;

private readonly ExternalConfiguration _dataSnapshot = configServerDataSnapshot.Value;
private readonly ConfigServerClientOptions _configServerClientOptions = configServerClientOptions.Value;
private readonly PlaceholderValues _placeholderResolverValues = placeholderValues.Value;
private readonly CloudFoundryApplicationOptions _applicationOptions = appOptions.Value;
private readonly CloudFoundryServicesOptions _serviceOptions = serviceOptions.Value;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<SteeltoeVersion>4.0.*-*</SteeltoeVersion>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Steeltoe.Configuration.CloudFoundry;

namespace Steeltoe.Samples.Configuration.Models;
namespace Steeltoe.Samples.ConfigurationProviders.Models;

public sealed class CloudFoundryViewModel(CloudFoundryApplicationOptions applicationOptions, CloudFoundryServicesOptions servicesOptions)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Steeltoe.Samples.ConfigurationProviders.Models;

public class ErrorViewModel
{
public string? RequestId { get; set; }

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Steeltoe.Samples.Configuration.Models;
namespace Steeltoe.Samples.ConfigurationProviders.Models;

/// <summary>
/// This object contains the configuration values provided by a configuration service. The source of these values is here:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Steeltoe.Samples.Configuration.Models;
namespace Steeltoe.Samples.ConfigurationProviders.Models;

public sealed class ExternalConfigurationInfo
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Steeltoe.Samples.Configuration.Models;
namespace Steeltoe.Samples.ConfigurationProviders.Models;

public sealed class PlaceholderValues
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Steeltoe.Configuration.Placeholder;
using Steeltoe.Configuration.RandomValue;
using Steeltoe.Management.Endpoint;
using Steeltoe.Samples.Configuration.Models;
using Steeltoe.Samples.ConfigurationProviders.Models;

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

Expand Down Expand Up @@ -49,8 +49,6 @@

app.UseAuthorization();

app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");

app.Run();
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ LOCAL_PATH = os.getenv("LOCAL_PATH", default=".")
NAMESPACE = os.getenv("NAMESPACE", default="apps")
WAIT_TIMEOUT = os.getenv("WAIT_TIMEOUT", default='10m00s')
TYPE = os.getenv("TYPE", default='web')
NAME = "steeltoe-samples-configuration"
NAME = "configuration-providers-sample"
TimHess marked this conversation as resolved.
Show resolved Hide resolved
LIVE_UPDATE_PATH = os.getenv("LIVE_UPDATE_PATH", default="bin\\Debug\\net8.0")

k8s_custom_deploy(
Expand All @@ -24,6 +24,6 @@ k8s_custom_deploy(
)

k8s_resource(NAME, port_forwards=["8080:8080"],
extra_pod_selectors=[{'carto.run/workload-name': 'steeltoe-samples-configuration', 'app.kubernetes.io/component': 'run'}])
extra_pod_selectors=[{'carto.run/workload-name': 'configuration-providers-sample', 'app.kubernetes.io/component': 'run'}])

allow_k8s_contexts('tap-sandbox')
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@using Steeltoe.Common
@using Steeltoe.Configuration.CloudFoundry
@model CloudFoundryViewModel
@model Steeltoe.Samples.ConfigurationProviders.Models.CloudFoundryViewModel
@{
ViewData["Title"] = "CloudFoundry Configuration data from VCAP_APPLICATION & VCAP_SERVICES";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@model ExternalConfiguration;
@model Steeltoe.Samples.ConfigurationProviders.Models.ExternalConfiguration;
@{
ViewData["Title"] = "Configuration Data";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@model PlaceholderValues
@model Steeltoe.Samples.ConfigurationProviders.Models.PlaceholderValues
@{
ViewData["Title"] = "Placeholder Values";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@model ErrorViewModel
@model Steeltoe.Samples.ConfigurationProviders.Models.ErrorViewModel
@{
ViewData["Title"] = "Error";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
<title>@ViewData["Title"] - Steeltoe Configuration Sample</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/Steeltoe.Samples.Configuration.styles.css" asp-append-version="true" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Steeltoe.Samples.Configuration</a>
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Steeltoe.Samples.ConfigurationProviders</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
Expand All @@ -38,7 +37,7 @@

<footer class="border-top footer text-muted">
<div class="container">
&copy; @DateTime.Now.Year - Steeltoe.Samples.Configuration - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
&copy; 2024 - Steeltoe.Samples.ConfigurationProviders - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@using Steeltoe.Samples.ConfigurationProviders;
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: "services.apps.tanzu.vmware.com/v1alpha1"
kind: ResourceClaim
metadata:
name: my-config
name: sample-config-server
TimHess marked this conversation as resolved.
Show resolved Hide resolved
namespace: apps
spec:
ref:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
apiVersion: carto.run/v1alpha1
kind: Workload
metadata:
name: steeltoe-configuration-sample
name: configuration-providers-sample
labels:
apps.tanzu.vmware.com/workload-type: web
app.kubernetes.io/part-of: steeltoe-samples
tanzu.app.live.view: "true"
tanzu.app.live.view.application.flavours: steeltoe
tanzu.app.live.view.application.name: steeltoe-configuration-sample
tanzu.app.live.view.application.name: configuration-providers-sample
spec:
build:
env:
Expand All @@ -32,10 +32,10 @@ spec:
ref:
apiVersion: services.apps.tanzu.vmware.com/v1alpha1
kind: ResourceClaim
name: my-config
name: sample-config-server
source:
git:
url: https://github.com/SteeltoeOSS/Samples
subPath: Configuration/src/Steeltoe.Samples.Configuration
subPath: Configuration/src/ConfigurationProviders
ref:
branch: config
branch: latest
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
applications:
- name: steeltoe-configuration-sample
- name: configuration-providers-sample
buildpacks:
- binary_buildpack
memory: 128M
random-route: true
stack: windows
command: cmd /c .\Steeltoe.Samples.Configuration --urls=http://0.0.0.0:%PORT%
command: cmd /c .\Steeltoe.Samples.ConfigurationProviders --urls=http://0.0.0.0:%PORT%
env:
# ASPNETCORE_ENVIRONMENT value is lower-cased here to match the files in the config repository at:
# https://github.com/spring-cloud-samples/config-repo
ASPNETCORE_ENVIRONMENT: development
DOTNET_CLI_TELEMETRY_OPTOUT: "true"
DOTNET_NOLOGO: "true"
services:
- myConfigServer
- sampleConfigServer
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
applications:
- name: steeltoe-configuration-sample
- name: configuration-providers-sample
buildpacks:
- dotnet_core_buildpack
memory: 128M
Expand All @@ -13,4 +13,4 @@ applications:
DOTNET_CLI_TELEMETRY_OPTOUT: "true"
DOTNET_NOLOGO: "true"
services:
- myConfigServer
- sampleConfigServer
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ def setup(context):
"""
cf = cloudfoundry.CloudFoundry(context)
# remove previous app
app = 'steeltoe-configuration-sample'
app = 'configuration-providers-sample'
cf.delete_app(app)
# create service
service = 'p.config-server'
plan = 'standard'
instance = 'myConfigServer'
instance = 'sampleConfigServer'
args = ['-c', './config-server.json']
cf.create_service(service, plan, instance, args)
2 changes: 1 addition & 1 deletion Configuration/src/Steeltoe.Samples.Configuration.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\..\CommonTasks.md = ..\..\CommonTasks.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steeltoe.Samples.Configuration", "Steeltoe.Samples.Configuration\Steeltoe.Samples.Configuration.csproj", "{82489734-D845-44FA-9EAB-1ED0A7013E51}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steeltoe.Samples.ConfigurationProviders", "ConfigurationProviders\Steeltoe.Samples.ConfigurationProviders.csproj", "{82489734-D845-44FA-9EAB-1ED0A7013E51}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

6 changes: 3 additions & 3 deletions Connectors/src/CosmosDb/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Text.Json;
using CosmosDb.Data;
using CosmosDb.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Cosmos;
using Microsoft.Azure.Cosmos.Linq;
using Steeltoe.Connectors;
using Steeltoe.Connectors.CosmosDb;
using Steeltoe.Samples.CosmosDb.Data;
using Steeltoe.Samples.CosmosDb.Models;

namespace CosmosDb.Controllers;
namespace Steeltoe.Samples.CosmosDb.Controllers;

public class HomeController : Controller
{
Expand Down
8 changes: 4 additions & 4 deletions Connectors/src/CosmosDb/CosmosDb.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ Feature: CosmosDb Connector
Scenario: CosmosDb Connector (net8.0/windows)
When you run: dotnet publish -r win-x64 --self-contained
And you run: cf push -f manifest-windows.yml -p bin/Release/net8.0/win-x64/publish
And you wait until CloudFoundry app cosmosdb-connector is started
When you get https://cosmosdb-connector/
And you wait until CloudFoundry app cosmosdb-connector-sample is started
When you get https://cosmosdb-connector-sample/
Then you should see "Object1"
And you should see "Object2"

@net8.0
@linux
Scenario: CosmosDb Connector (net8.0/linux)
When you run: cf push -f manifest.yml
And you wait until CloudFoundry app cosmosdb-connector is started
When you get https://cosmosdb-connector/
And you wait until CloudFoundry app cosmosdb-connector-sample is started
When you get https://cosmosdb-connector-sample/
Then you should see "Object1"
And you should see "Object2"
Loading
Loading