-
Notifications
You must be signed in to change notification settings - Fork 1
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 #5 from draganm/rewrite
Rewrite
- Loading branch information
Showing
18 changed files
with
824 additions
and
257 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,10 @@ | ||
render('deployment.yaml',{"name": "mfstr"}, "deployment.yaml") | ||
render( | ||
'ingress.yaml', | ||
{ | ||
"hostnames": ["www.netice9.com","netice9.com"], | ||
'serviceName': "foo", | ||
'name': "bar", | ||
}, | ||
"ingress.yaml", | ||
) |
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,39 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
annotations: | ||
labels: | ||
name: ${name} | ||
name: ${name} | ||
spec: | ||
replicas: 1 | ||
revisionHistoryLimit: 3 | ||
selector: | ||
matchLabels: | ||
app: ${name} | ||
strategy: | ||
rollingUpdate: | ||
maxSurge: 25% | ||
maxUnavailable: 25% | ||
type: RollingUpdate | ||
template: | ||
metadata: | ||
labels: | ||
app: ${name} | ||
spec: | ||
containers: | ||
- image: registry.digitalocean.com/netice9/${name}:226b90e | ||
imagePullPolicy: IfNotPresent | ||
name: nin-home | ||
ports: | ||
- containerPort: 5001 | ||
name: http | ||
protocol: TCP | ||
resources: | ||
limits: | ||
cpu: 300m | ||
memory: 300Mi | ||
requests: | ||
cpu: 300m | ||
memory: 300Mi | ||
restartPolicy: Always |
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,26 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
annotations: | ||
external-dns.alpha.kubernetes.io/hostname: "${hostnames.join(',')}" | ||
nginx.ingress.kubernetes.io/force-ssl-redirect: "true" | ||
cert-manager.io/cluster-issuer: letsencrypt-prod | ||
name: ${name} | ||
spec: | ||
ingressClassName: nginx | ||
rules: | ||
_forEach: ${hostnames} | ||
_template: | ||
host: ${eachValue} | ||
http: | ||
paths: | ||
- backend: | ||
service: | ||
name: ${eachValue} | ||
port: | ||
name: http | ||
path: / | ||
pathType: ImplementationSpecific | ||
tls: | ||
- hosts: ${hostnames} | ||
secretName: nin-home-netice9-com-tls |
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,7 @@ | ||
{ | ||
"cSpell.words": [ | ||
"envsubst", | ||
"goja", | ||
"Manifestor" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
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,45 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
func manifestorProvider(outDir string) func(name string) (*yaml.Encoder, func() error, error) { | ||
|
||
if outDir == "" { | ||
return func(name string) (*yaml.Encoder, func() error, error) { | ||
return yaml.NewEncoder(os.Stdout), func() error { return nil }, nil | ||
} | ||
} | ||
|
||
return func(name string) (*yaml.Encoder, func() error, error) { | ||
outPath := filepath.Join(outDir, name) | ||
dir := filepath.Dir(outPath) | ||
if dir != "" { | ||
_, err := os.Stat(dir) | ||
if os.IsNotExist(err) { | ||
err = os.MkdirAll(dir, 0777) | ||
if err != nil { | ||
return nil, nil, fmt.Errorf("could not mkdir %s: %w", dir, err) | ||
} | ||
_, err = os.Stat(dir) | ||
} | ||
|
||
if err != nil { | ||
return nil, nil, fmt.Errorf("could not stat %s: %w", dir, err) | ||
} | ||
} | ||
|
||
f, err := os.OpenFile(outPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0777) | ||
|
||
if err != nil { | ||
return nil, nil, fmt.Errorf("could not open output file: %w", err) | ||
} | ||
return yaml.NewEncoder(f), f.Close, nil | ||
|
||
} | ||
} |
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,19 +1,46 @@ | ||
module github.com/draganm/manifestor | ||
|
||
go 1.17 | ||
go 1.20 | ||
|
||
require ( | ||
github.com/dop251/goja v0.0.0-20220124171016-cfb079cdc7b4 | ||
github.com/drone/envsubst v1.0.2 | ||
github.com/urfave/cli/v2 v2.3.0 | ||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b | ||
github.com/dop251/goja v0.0.0-20230919151941-fc55792775de | ||
github.com/drone/envsubst v1.0.3 | ||
github.com/go-git/go-git/v5 v5.9.0 | ||
github.com/stretchr/testify v1.8.4 | ||
github.com/urfave/cli/v2 v2.25.7 | ||
gopkg.in/yaml.v3 v3.0.1 | ||
) | ||
|
||
require ( | ||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect | ||
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 // indirect | ||
dario.cat/mergo v1.0.0 // indirect | ||
github.com/Microsoft/go-winio v0.6.1 // indirect | ||
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect | ||
github.com/acomagu/bufpipe v1.0.4 // indirect | ||
github.com/cloudflare/circl v1.3.3 // indirect | ||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect | ||
github.com/cyphar/filepath-securejoin v0.2.4 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/dlclark/regexp2 v1.7.0 // indirect | ||
github.com/emirpasic/gods v1.18.1 // indirect | ||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect | ||
github.com/go-git/go-billy/v5 v5.5.0 // indirect | ||
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect | ||
github.com/russross/blackfriday/v2 v2.0.1 // indirect | ||
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect | ||
golang.org/x/text v0.3.6 // indirect | ||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect | ||
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect | ||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect | ||
github.com/kevinburke/ssh_config v1.2.0 // indirect | ||
github.com/pjbgf/sha1cd v0.3.0 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/russross/blackfriday/v2 v2.1.0 // indirect | ||
github.com/sergi/go-diff v1.1.0 // indirect | ||
github.com/skeema/knownhosts v1.2.0 // indirect | ||
github.com/xanzy/ssh-agent v0.3.3 // indirect | ||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect | ||
golang.org/x/crypto v0.13.0 // indirect | ||
golang.org/x/mod v0.12.0 // indirect | ||
golang.org/x/net v0.15.0 // indirect | ||
golang.org/x/sys v0.12.0 // indirect | ||
golang.org/x/text v0.13.0 // indirect | ||
golang.org/x/tools v0.13.0 // indirect | ||
gopkg.in/warnings.v0 v0.1.2 // indirect | ||
) |
Oops, something went wrong.