This repository has been archived by the owner on Dec 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from coopnorge/init
init cdk8s lib
- Loading branch information
Showing
42 changed files
with
68,004 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/dist/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,20 @@ | ||
# github-template-default | ||
# Coop Norge cdk8s library | ||
|
||
This is a basic template for when creating a Github repository. | ||
> very much POC! | ||
## Initialization instructions: | ||
|
||
1. Setup [CODEOWNERS](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners) | ||
## Requirements | ||
|
||
In a new branch Add you own team as the default code owner. Replace `* | ||
@coopnorge/platform-guild` with `* @coopnorge/your-team-here` | ||
`./CODEOWNERS`. Leave the rest of the file as is. | ||
* cdk8s | ||
|
||
```CODEOWNERS | ||
* @coopnorge/your-team-here | ||
/CODEOWNERS @coopnorge/security-guild | ||
.github/workflows/security-* @coopnorge/security-guild | ||
``` | ||
### Goal | ||
|
||
Create a pull request, get it approved and merge it. | ||
Make a library which can support many usecases | ||
|
||
2. Setup and fix default [workflows](https://docs.github.com/en/actions/using-workflows) | ||
#### Go Library | ||
|
||
`.github/workflows/build.yaml` declares the default required GitHub Actions | ||
job `build`. The job will fail on all builds in all repositories, except | ||
<https://github.com/coopnorge/github-template-default>. Update the workflow | ||
to do something that actually validates the content of your repository. | ||
A library to build default kubernetes templates. A demo consumer can be found at [coopnorge/cdk8s-demo-consumer](https://github.com/coopnorge/cdk8s-demo-consumer) | ||
|
||
3. Setup | ||
[dependabot](https://playbook.internal.coop/platforms/cloud_platform/dev_build_deploy/github/guide_github_dependabot.html) | ||
to update all dependencies from all ecosystems in the repository. | ||
#### Yaml input | ||
|
||
4. Create a new branch and start initializing your repository with the code you | ||
need. | ||
This library also has a binary which can render manifests based on yaml input. Its in the `cmd/cdk8slibrary` folder. Edit the test.yaml and do a `go run .` and it will render the manifest in the `dist` directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
language: go | ||
app: go run . | ||
imports: | ||
- k8s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
//TODO: add ability to merge yamls | ||
package main | ||
|
||
import ( | ||
"log" | ||
"os" | ||
|
||
ck8slibrary "github.com/coopnorge/cdk8slibrary" | ||
"github.com/creasty/defaults" | ||
"github.com/mitchellh/mapstructure" | ||
"gopkg.in/yaml.v2" | ||
|
||
"github.com/aws/constructs-go/constructs/v10" | ||
"github.com/aws/jsii-runtime-go" | ||
"github.com/cdk8s-team/cdk8s-core-go/cdk8s/v2" | ||
) | ||
|
||
type MyChartProps struct { | ||
cdk8s.ChartProps | ||
} | ||
|
||
func NewMyChart(scope constructs.Construct, id string, props *ck8slibrary.ChartProps) cdk8s.Chart { | ||
var cprops cdk8s.ChartProps | ||
|
||
chart := cdk8s.NewChart(scope, jsii.String(id), &cprops) | ||
|
||
ck8slibrary.Chart(chart, jsii.String("hello"), props) | ||
|
||
return chart | ||
} | ||
|
||
func main() { | ||
// Load the file; returns []byte | ||
f, err := os.ReadFile("test.yaml") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
// Create an empty Car to be are target of unmarshalling | ||
var c ck8slibrary.ChartProps | ||
if err := defaults.Set(&c); err != nil { | ||
panic(err) | ||
} | ||
|
||
var raw interface{} | ||
|
||
// Unmarshal our input YAML file into empty interface | ||
if err := yaml.Unmarshal(f, &raw); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Use mapstructure to convert our interface{} to Car (var c) | ||
decoder, _ := mapstructure.NewDecoder(&mapstructure.DecoderConfig{WeaklyTypedInput: true, Result: &c}) | ||
if err := decoder.Decode(raw); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Print out the new struct | ||
//fmt.Printf("%+v\n", *c.Name) | ||
app := cdk8s.NewApp(nil) | ||
NewMyChart(app, "test", &c) | ||
app.Synth() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: kees | ||
image: pan/piet | ||
ports: | ||
- port: 30 | ||
serviceEntries: | ||
- name: google | ||
hosts: | ||
- google.nl | ||
- google.no | ||
- google.com |
Oops, something went wrong.