Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickkirschen committed May 29, 2024
0 parents commit b697d61
Show file tree
Hide file tree
Showing 18 changed files with 533 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
tab_width = 4
indent_style = space
max_line_length = 120
insert_final_newline = true
trim_trailing_whitespace = true

[{*.go}]
indent_style = tab

[{*.md,LICENSE}]
max_line_length = 80

[{*.yml,*.yaml,*.json}]
indent_size = 2
tab_width = 2
34 changes: 34 additions & 0 deletions .github/commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
rules: {
'body-leading-blank': [2, 'always'],
'body-max-line-length': [2, 'always', 100],
'header-max-length': [2, 'always', 100],
'scope-case': [2, 'always', 'lower-case'],
'subject-case': [
2,
'never',
['start-case', 'pascal-case', 'upper-case'],
],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'type-enum': [
2,
'always',
[
'chore',
'build',
'ci',
'docs',
'feat',
'feat!',
'fix',
'perf',
'refactor',
'test'
],
],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'signed-off-by': [2, 'always']
}
};
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"

- package-ecosystem: "github-actions"
directory: "/.github/workflows"
schedule:
interval: "daily"
23 changes: 23 additions & 0 deletions .github/workflows/commit-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Lint commit message

on: [push]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Clone
uses: actions/checkout@v4

- name: Setup node 20
uses: actions/setup-node@v4
with:
node-version: "20"
check-latest: true

- name: Install commitlint
run: npm install -g @commitlint/cli @commitlint/config-conventional

- name: Lint commit message
run: echo "${{ github.event.head_commit.message }}" | commitlint --config .github/commitlint.config.js
71 changes: 71 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Go Workflow (Push)

on:
push:
branches: ["**"]
pull_request:
branches: ["**"]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.20"
check-latest: true

- name: Build
run: go build ./...

test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.20"
check-latest: true

- name: Format
run: |
OUT="$(go fmt $(go list ./... | grep -v /vendor/) 2>&1)"
if [ -n "$OUT" ]; then
echo "The following files are not correctly formatted"
echo "${OUT}"
exit 1
fi
- name: Test
run: go test -json ./...

lint:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.20"
check-latest: true

- name: Format
run: |
OUT="$(go fmt $(go list ./... | grep -v /vendor/) 2>&1)"
if [ -n "$OUT" ]; then
echo "The following files are not correctly formatted"
echo "${OUT}"
exit 1
fi
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Go Workflow (Release)

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.20"
check-latest: true

- name: Build
run: go build ./...

test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.20"
check-latest: true

- name: Format
run: |
OUT="$(go fmt $(go list ./... | grep -v /vendor/) 2>&1)"
if [ -n "$OUT" ]; then
echo "The following files are not correctly formatted"
echo "${OUT}"
exit 1
fi
- name: Test
run: go test -json ./...

lint:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.20"
check-latest: true

- name: Format
run: |
OUT="$(go fmt $(go list ./... | grep -v /vendor/) 2>&1)"
if [ -n "$OUT" ]; then
echo "The following files are not correctly formatted"
echo "${OUT}"
exit 1
fi
11 changes: 11 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"recommendations": [
"streetsidesoftware.code-spell-checker",
"editorconfig.editorconfig",
"davidanson.vscode-markdownlint",
"sonarsource.sonarlint-vscode",
"wayou.vscode-todo-highlight",
"redhat.vscode-yaml",
"golang.go"
]
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"cSpell.language": "en",
"editor.formatOnSave": true,
"editor.wordWrap": "on",
"editor.rulers": [
80,
120
]
}
8 changes: 8 additions & 0 deletions .whitesource
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"checkRunSettings": {
"vulnerableCheckRunConclusionLevel": "failure"
},
"issueSettings": {
"minSeverityLevel": "LOW"
}
}
5 changes: 5 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Code of Conduct

Actually, the author is hungry and does not want to write a novel here. So,
please just act like a normal human and treat others the same way as you want to
be treated.
24 changes: 24 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Contributing

When contributing to this repository, please first discuss the change in the
discussions.

Please note we have a code of conduct, please follow it in all your interactions
with the project.

## Coding

1. Fork the repository.
2. Make your changes on a dedicated branch.
3. Commit your changes according
to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0).
Please try to only make one commit. Squash/rebase if you made a bunch of
fix-up-commits! Commits will be linted on every push.
4. Open up a pull request by using the `Fix`, `Feature` or `Breaking` pull
request template and follow the steps described there.
5. Merge the pull request as described in the template and make
a [release](#release) if required.

## Release

Open an issue by using the template `Release` and follow the steps in there.
24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

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 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.

For more information, please refer to <http://unlicense.org/>
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Manifesto

[![Lint commit message](https://github.com/yannickkirschen/manifesto/actions/workflows/commit-lint.yml/badge.svg)](https://github.com/yannickkirschen/manifesto/actions/workflows/commit-lint.yml)
[![Push](https://github.com/yannickkirschen/manifesto/actions/workflows/push.yml/badge.svg)](https://github.com/yannickkirschen/manifesto/actions/workflows/push.yml)
[![Release](https://github.com/yannickkirschen/manifesto/actions/workflows/release.yml/badge.svg)](https://github.com/yannickkirschen/manifesto/actions/workflows/release.yml)
[![GitHub release](https://img.shields.io/github/release/yannickkirschen/manifesto.svg)](https://github.com/yannickkirschen/manifesto/releases/)

Manifesto is a library that manages declarative APIs using the listener pattern,
just like Kubernetes with its resources and operators.

> [!WARNING]
> This project is currently under heavy development and not stable.
39 changes: 39 additions & 0 deletions example/example.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"fmt"

"github.com/yannickkirschen/manifesto"
)

type MySpec struct {
Message string `yaml:"message" json:"message"`
}

func MyListener(action manifesto.Action, manifest *manifesto.Manifest) {
if manifest.ApiVersion != "example.com/v1alpha1" || manifest.Kind != "MyManifest" {
return
}

spec := manifest.Spec.(*MySpec)

switch action {
case manifesto.Created:
fmt.Println("Created:", spec.Message)
case manifesto.Updated:
fmt.Println("Updated:", spec.Message)
case manifesto.Deleted:
fmt.Println("Deleted:", spec.Message)
}
}

func main() {
m := manifesto.ParseFile("example/my-manifest.yaml", &MySpec{}, &MySpec{})

pool := manifesto.CreatePool()
pool.Listen(MyListener)
pool.Apply(m)

m3 := pool.GetByKey(m.CreateKey())
pool.Delete(m3.CreateKey())
}
6 changes: 6 additions & 0 deletions example/my-manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: example.com/v1alpha1
kind: MyManifest
metadata:
name: my-manifest
spec:
message: hello, world
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/yannickkirschen/manifesto

go 1.20

require gopkg.in/yaml.v3 v3.0.1
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading

0 comments on commit b697d61

Please sign in to comment.