mirror of https://github.com/dotnet/tye.git
Browse Source
* allows specifying the Kubernetes imagePullSecrets in configuration to pull from a private registry
* removed trailing whitespace 🙄
* removes interactive prompt for pull secret
* adds copyright info
* renames registry.hostname to regisry.name in tye.yaml schema
* reverted unnecessary change to project file
* fixes registry entry in schema documentation
Co-authored-by: David Fowler <davidfowl@gmail.com>
pull/1494/head
committed by
GitHub
13 changed files with 248 additions and 34 deletions
@ -0,0 +1,16 @@ |
|||
// Licensed to the .NET Foundation under one or more agreements.
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
|||
// See the LICENSE file in the project root for more information.
|
|||
|
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Microsoft.Tye.ConfigModel |
|||
{ |
|||
public class ConfigRegistry |
|||
{ |
|||
[Required] |
|||
public string Hostname { get; set; } = null!; |
|||
|
|||
public string? PullSecret { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
// Licensed to the .NET Foundation under one or more agreements.
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
|||
// See the LICENSE file in the project root for more information.
|
|||
|
|||
using Microsoft.Tye.ConfigModel; |
|||
using YamlDotNet.RepresentationModel; |
|||
|
|||
namespace Tye.Serialization |
|||
{ |
|||
public class ConfigRegistryParser |
|||
{ |
|||
public static ConfigRegistry HandleRegistry(string key, YamlNode node) |
|||
{ |
|||
ConfigRegistry configRegistry; |
|||
if (node.NodeType == YamlNodeType.Scalar) |
|||
{ |
|||
configRegistry = new ConfigRegistry |
|||
{ |
|||
Hostname = ((YamlScalarNode)node).Value! |
|||
}; |
|||
} |
|||
else if (node.NodeType == YamlNodeType.Mapping) |
|||
{ |
|||
configRegistry = HandleRegistryMapping((YamlMappingNode)node); |
|||
} |
|||
else |
|||
{ |
|||
throw new TyeYamlException(node.Start, CoreStrings.FormatExpectedYamlScalar(key)); |
|||
} |
|||
|
|||
return configRegistry; |
|||
} |
|||
|
|||
private static ConfigRegistry HandleRegistryMapping(YamlMappingNode mappingNode) |
|||
{ |
|||
var configRegistry = new ConfigRegistry(); |
|||
|
|||
foreach (var child in mappingNode.Children) |
|||
{ |
|||
var key = YamlParser.GetScalarValue(child.Key); |
|||
|
|||
switch (key) |
|||
{ |
|||
case "name": |
|||
configRegistry.Hostname = YamlParser.GetScalarValue(key, child.Value); |
|||
break; |
|||
case "pullSecret": |
|||
configRegistry.PullSecret = YamlParser.GetScalarValue(key, child.Value); |
|||
break; |
|||
default: |
|||
throw new TyeYamlException(child.Key.Start, CoreStrings.FormatUnrecognizedKey(key)); |
|||
} |
|||
} |
|||
|
|||
return configRegistry; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
kind: Deployment |
|||
apiVersion: apps/v1 |
|||
metadata: |
|||
name: test-project |
|||
labels: |
|||
app.kubernetes.io/name: 'test-project' |
|||
app.kubernetes.io/part-of: 'single-project' |
|||
spec: |
|||
replicas: 1 |
|||
selector: |
|||
matchLabels: |
|||
app.kubernetes.io/name: test-project |
|||
template: |
|||
metadata: |
|||
labels: |
|||
app.kubernetes.io/name: 'test-project' |
|||
app.kubernetes.io/part-of: 'single-project' |
|||
spec: |
|||
containers: |
|||
- name: test-project |
|||
image: test/test-project:1.0.0 |
|||
imagePullPolicy: Always |
|||
env: |
|||
- name: DOTNET_LOGGING__CONSOLE__DISABLECOLORS |
|||
value: 'true' |
|||
- name: ASPNETCORE_URLS |
|||
value: 'http://*' |
|||
- name: PORT |
|||
value: '80' |
|||
- name: SERVICE__TEST-PROJECT__PROTOCOL |
|||
value: 'http' |
|||
- name: SERVICE__TEST-PROJECT__PORT |
|||
value: '80' |
|||
- name: SERVICE__TEST-PROJECT__HOST |
|||
value: 'test-project' |
|||
ports: |
|||
- containerPort: 80 |
|||
imagePullSecrets: |
|||
- name: credsecret |
|||
... |
|||
--- |
|||
kind: Service |
|||
apiVersion: v1 |
|||
metadata: |
|||
name: test-project |
|||
labels: |
|||
app.kubernetes.io/name: 'test-project' |
|||
app.kubernetes.io/part-of: 'single-project' |
|||
spec: |
|||
selector: |
|||
app.kubernetes.io/name: test-project |
|||
type: ClusterIP |
|||
ports: |
|||
- name: http |
|||
protocol: TCP |
|||
port: 80 |
|||
targetPort: 80 |
|||
... |
|||
Loading…
Reference in new issue