Skip to content
Open
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
109 changes: 109 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Default settings
[*]
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
# (Please don't specify an indent_size here; that has too many unintended consequences.)

[*.md]
indent_size = 4
trim_trailing_whitespace = false

[*.sql]
indent_size = 4
indent_style = space

# .NET
[*.{cs,csx,vb,vbx,ashx}]
charset = utf-8-bom
indent_style = tab
tab_width = 4

[*.{asp,aspx,cshtml,vbhtml}]
charset = utf-8-bom
indent_size = 2
indent_style = space

# Shell scripts
[*.{bat,cmd}]
end_of_line = crlf
indent_size = 4

[*.sh]
end_of_line = lf
indent_size = 4

[*.{ps1,psm1}]
charset = utf-8-bom
indent_size = 4
indent_style = space

# Web
[*.{css,html,js,json,yml}]
indent_size = 2
indent_style = space
insert_final_newline = false

# XML
[*.{xml,xsl,xslt,xsd}]
indent_size = 2
indent_style = space
insert_final_newline = false

# Xml project files
[*.*proj]
charset = utf-8-bom
indent_size = 2
indent_style = space
insert_final_newline = false

# Xml config files
[*.{props,targets,ruleset,Config,config,nuspec,pubxml,resx,vsixmanifest,vsct}]
charset = utf-8-bom
indent_size = 2
indent_style = space
insert_final_newline = false

# CSharp code style settings:
[*.cs]
# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true

# Don't use this. qualifier
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion

# use int x = .. over Int32
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion

# use int.MaxValue over Int32.MaxValue
dotnet_style_predefined_type_for_member_access = true:none

# Do not require var all the time.
csharp_style_var_for_built_in_types = false:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:none

csharp_prefer_braces = true:suggestion

# Indentation Settings
csharp_indent_labels = no_change

# Newline settings
csharp_new_line_before_open_brace = accessors, control_blocks, events, indexers, local_functions, methods, properties, types

# Spacing settings
csharp_space_after_cast = true
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_parentheses = false

# Wrapping settings
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = false
80 changes: 80 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CI

permissions:
checks: write
pull-requests: write

on:
push:
branches:
- main
- 'feature/**'
tags:
- 'v*'

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
if: ${{ !env.ACT }}
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x

- name: Dotnet information
run: dotnet --info

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3.0.0
with:
versionSpec: 6.0.x

- name: Determine Version
id: version
uses: gittools/actions/gitversion/execute@v3.0.0
with:
useConfigFile: true

- name: Install dependencies
run: dotnet restore

- name: Build
run: >
dotnet build --no-restore -c Release
/p:Version="${{steps.version.outputs.MajorMinorPatch}}"
/p:AssemblyVersion="${{steps.version.outputs.AssemblySemVer}}"
/p:AssemblyFileVersion="${{steps.version.outputs.FullSemVer}}"
/p:InformationalVersion="${{steps.version.outputs.InformationalVersion}}"

- name: Test
continue-on-error: true
run: dotnet test --no-build -c Release -- --report-trx

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
test/**/*.trx

- name: Package
run: dotnet pack --no-build -c Release -o artifacts /p:Version="${{ steps.version.outputs.FullSemVer }}"

- name: Upload package to MyGet
if: steps.version.outputs.PreReleaseTag != '' && !github.event.act
run: dotnet nuget push "*.nupkg" -k ${{ secrets.MYGET_API_KEY }} -s https://www.myget.org/F/digillect/api/v3/index.json
working-directory: artifacts

- name: Upload package to NuGet
if: steps.version.outputs.PreReleaseTag == '' && !github.event.act
run: dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
working-directory: artifacts
34 changes: 34 additions & 0 deletions Digillect.SunStone.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Digillect.Sunstone.Abstractions", "src\Digillect.Sunstone.Abstractions\Digillect.Sunstone.Abstractions.csproj", "{C71DB8F4-A5EF-4742-A66A-4628AED67772}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Digillect.Sunstone", "src\Digillect.Sunstone\Digillect.Sunstone.csproj", "{BB8F0D81-AD00-4231-B1B8-B1E9DB3D45D3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Digillect.Sunstone.Resources.SourceGenerator", "src\Digillect.Sunstone.Resources.SourceGenerator\Digillect.Sunstone.Resources.SourceGenerator.csproj", "{98ADD99E-A940-4DFD-8985-1E518CBEC5C5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Digillect.Sunstone.Resources.Kubernetes", "src\Digillect.Sunstone.Resources.Kubernetes\Digillect.Sunstone.Resources.Kubernetes.csproj", "{FB1CDC9C-9B5B-46AD-B569-79D449131641}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C71DB8F4-A5EF-4742-A66A-4628AED67772}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C71DB8F4-A5EF-4742-A66A-4628AED67772}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C71DB8F4-A5EF-4742-A66A-4628AED67772}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C71DB8F4-A5EF-4742-A66A-4628AED67772}.Release|Any CPU.Build.0 = Release|Any CPU
{BB8F0D81-AD00-4231-B1B8-B1E9DB3D45D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BB8F0D81-AD00-4231-B1B8-B1E9DB3D45D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BB8F0D81-AD00-4231-B1B8-B1E9DB3D45D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BB8F0D81-AD00-4231-B1B8-B1E9DB3D45D3}.Release|Any CPU.Build.0 = Release|Any CPU
{98ADD99E-A940-4DFD-8985-1E518CBEC5C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98ADD99E-A940-4DFD-8985-1E518CBEC5C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98ADD99E-A940-4DFD-8985-1E518CBEC5C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98ADD99E-A940-4DFD-8985-1E518CBEC5C5}.Release|Any CPU.Build.0 = Release|Any CPU
{FB1CDC9C-9B5B-46AD-B569-79D449131641}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FB1CDC9C-9B5B-46AD-B569-79D449131641}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB1CDC9C-9B5B-46AD-B569-79D449131641}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB1CDC9C-9B5B-46AD-B569-79D449131641}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
13 changes: 13 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project>

<PropertyGroup>
<Version>1.0.0</Version>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Authors>Gregory Nickonov</Authors>
<Company>Digillect</Company>
<Product>Kubernetes manifests generator framework</Product>
<Copyright>Copyright © 2024-2025 Gregory Nickonov</Copyright>
<RepositoryUrl>https://github.com/digillect/sunstone.net</RepositoryUrl>
</PropertyGroup>

</Project>
33 changes: 33 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
workflow: GitHubFlow/v1
assembly-versioning-scheme: MajorMinorPatch
strategies:
- MergeMessage
- TaggedCommit
- Mainline
- Fallback
branches:
main:
regex: ^master$|^main$
label: alpha
increment: Patch
is-release-branch: false
is-main-branch: true

feature:
mode: ContinuousDelivery
regex: ^features?[/-](?<BranchName>.+)
label: '{BranchName}'
increment: Inherit
#pre-release-weight: 30000

tags:
regex: ^tags/v.+$
label: ''
source-branches: ['main']
increment: None
is-release-branch: true
is-main-branch: true

ignore:
sha: []
merge-message-formats: {}
11 changes: 11 additions & 0 deletions NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="packages" />
</config>
<packageSources>
<clear />
<add key="digillect-myget" value="https://www.myget.org/F/digillect/api/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"version": "9.0.200",
"rollForward": "latestFeature"
}
}
69 changes: 69 additions & 0 deletions src/Digillect.Sunstone.Abstractions/BaseArray.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System.Collections;

namespace Digillect.Sunstone;

public class BaseArray<T>(SunstoneObject? owner) : IReadOnlyList<T>
{
private readonly List<T> _items = [];

public int Count => _items.Count;

public T this[int index] => _items[index];

public IEnumerator<T> GetEnumerator()
{
return _items.GetEnumerator();
}

IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}

public void Add(T item)
{
if (item is SunstoneObject baseObject)
{
baseObject.SetParent(owner);
}

_items.Add(item);
}

public void Add(params T[] items)
{
foreach (var item in items)
{
if (item is SunstoneObject baseObject)
{
baseObject.SetParent(owner);
}

_items.Add(item);
}
}

public T? AddOrReplace(T item, Func<T, bool> predicate)
{
var existing = _items.FirstOrDefault(predicate);

if (existing is not null)
{
_items.Remove(existing);

if (existing is SunstoneObject existingBaseObject)
{
existingBaseObject.SetParent(null);
}
}

if (item is SunstoneObject baseObject)
{
baseObject.SetParent(owner);
}

_items.Add(item);

return existing;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<RootNamespace>Digillect.Sunstone</RootNamespace>
</PropertyGroup>

</Project>
7 changes: 7 additions & 0 deletions src/Digillect.Sunstone.Abstractions/IHaveApiVersionAndKind.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Digillect.Sunstone;

public interface IHaveApiVersionAndKind
{
public string ApiVersion { get; }
public string Kind { get; }
}
13 changes: 13 additions & 0 deletions src/Digillect.Sunstone.Abstractions/IHaveFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Digillect.Sunstone;

public interface IHaveFactory<out T>
where T : SunstoneObject
{
public static abstract string ResourceApiVersion { get; }
public static abstract string ResourceKind { get; }

[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public ResourcesCollection Resources { get; }

public static abstract T Create(string name, ResourcesCollection resources);
}
Loading