mirror of
https://github.com/holos-run/holos.git
synced 2026-03-19 08:44:58 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d831070f53 | ||
|
|
340715f76c |
@@ -85,7 +85,24 @@ package holos
|
||||
usages: ["digital signature", "key encipherment", "client auth"]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Certificate: zitadel: #Certificate & {
|
||||
metadata: name: "crdb-zitadel-client"
|
||||
metadata: namespace: #TargetNamespace
|
||||
spec: {
|
||||
commonName: "zitadel"
|
||||
issuerRef: {
|
||||
group: "cert-manager.io"
|
||||
kind: "Issuer"
|
||||
name: "crdb-ca-issuer"
|
||||
}
|
||||
privateKey: algorithm: "RSA"
|
||||
privateKey: size: 2048
|
||||
renewBefore: "48h0m0s"
|
||||
secretName: "cockroachdb-zitadel"
|
||||
subject: organizations: ["Cockroach"]
|
||||
usages: ["digital signature", "key encipherment", "client auth"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,13 +14,7 @@ package holos
|
||||
}
|
||||
values: #Values
|
||||
apiObjects: {
|
||||
Issuer: {
|
||||
// https://github.com/cockroachdb/helm-charts/blob/3dcf96726ebcfe3784afb526ddcf4095a1684aea/README.md?plain=1#L196-L201
|
||||
cockroachdb: #Issuer & {
|
||||
metadata: name: #ComponentName
|
||||
metadata: namespace: #TargetNamespace
|
||||
spec: selfSigned: {}
|
||||
}
|
||||
}
|
||||
ExternalSecret: node: #ExternalSecret & {_name: "cockroachdb-node"}
|
||||
ExternalSecret: root: #ExternalSecret & {_name: "cockroachdb-root"}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,7 +478,7 @@ package holos
|
||||
copyCerts: image: "busybox"
|
||||
certs: {
|
||||
// Bring your own certs scenario. If provided, tls.init section will be ignored.
|
||||
provided: false
|
||||
provided: true | *false
|
||||
// Secret name for the client root cert.
|
||||
clientRootSecret: "cockroachdb-root"
|
||||
// Secret name for node cert.
|
||||
@@ -487,7 +487,7 @@ package holos
|
||||
caSecret: "cockroach-ca"
|
||||
// Enable if the secret is a dedicated TLS.
|
||||
// TLS secrets are created by cert-mananger, for example.
|
||||
tlsSecret: false
|
||||
tlsSecret: true | *false
|
||||
// Enable if the you want cockroach db to create its own certificates
|
||||
selfSigner: {
|
||||
// If set, the cockroach db will generate its own certificates
|
||||
|
||||
@@ -10,11 +10,9 @@ package holos
|
||||
certs: {
|
||||
// https://github.com/cockroachdb/helm-charts/blob/3dcf96726ebcfe3784afb526ddcf4095a1684aea/README.md?plain=1#L204-L215
|
||||
selfSigner: enabled: false
|
||||
certManager: true
|
||||
certManagerIssuer: {
|
||||
kind: "Issuer"
|
||||
name: #ComponentName
|
||||
}
|
||||
certManager: false
|
||||
provided: true
|
||||
tlsSecret: true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,23 +24,8 @@ let Name = "zitadel"
|
||||
ExternalSecret: masterkey: #ExternalSecret & {
|
||||
_name: "zitadel-masterkey"
|
||||
}
|
||||
Certificate: zitadel: #Certificate & {
|
||||
metadata: name: "crdb-zitadel-client"
|
||||
metadata: namespace: #TargetNamespace
|
||||
spec: {
|
||||
commonName: "zitadel"
|
||||
issuerRef: {
|
||||
group: "cert-manager.io"
|
||||
kind: "Issuer"
|
||||
name: "crdb-ca-issuer"
|
||||
}
|
||||
privateKey: algorithm: "RSA"
|
||||
privateKey: size: 2048
|
||||
renewBefore: "48h0m0s"
|
||||
secretName: "cockroachdb-zitadel"
|
||||
subject: organizations: ["Cockroach"]
|
||||
usages: ["digital signature", "key encipherment", "client auth"]
|
||||
}
|
||||
ExternalSecret: zitadel: #ExternalSecret & {
|
||||
_name: "cockroachdb-zitadel"
|
||||
}
|
||||
VirtualService: zitadel: #VirtualService & {
|
||||
metadata: name: Name
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package secret
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/holos-run/holos/pkg/cli/command"
|
||||
"github.com/holos-run/holos/pkg/holos"
|
||||
@@ -29,6 +30,7 @@ func NewCreateCmd(hc *holos.Config) *cobra.Command {
|
||||
cfg.dryRun = flagSet.Bool("dry-run", false, "dry run")
|
||||
cfg.appendHash = flagSet.Bool("append-hash", true, "append hash to kubernetes secret name")
|
||||
cfg.dataStdin = flagSet.Bool("data-stdin", false, "read data field as json from stdin if")
|
||||
cfg.trimTrailingNewlines = flagSet.Bool("trim-trailing-newlines", true, "trim trailing newlines if true")
|
||||
|
||||
cmd.Flags().SortFlags = false
|
||||
cmd.Flags().AddGoFlagSet(flagSet)
|
||||
@@ -80,7 +82,7 @@ func makeCreateRunFunc(hc *holos.Config, cfg *config) command.RunFunc {
|
||||
}
|
||||
|
||||
for _, file := range cfg.files {
|
||||
if err := filepath.WalkDir(file, makeWalkFunc(secret.Data, file)); err != nil {
|
||||
if err := filepath.WalkDir(file, makeWalkFunc(secret.Data, file, *cfg.trimTrailingNewlines)); err != nil {
|
||||
return wrapper.Wrap(err)
|
||||
}
|
||||
}
|
||||
@@ -125,7 +127,7 @@ func makeCreateRunFunc(hc *holos.Config, cfg *config) command.RunFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func makeWalkFunc(data secretData, root string) fs.WalkDirFunc {
|
||||
func makeWalkFunc(data secretData, root string, trimNewlines bool) fs.WalkDirFunc {
|
||||
return func(path string, d os.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -143,6 +145,9 @@ func makeWalkFunc(data secretData, root string) fs.WalkDirFunc {
|
||||
if data[key], err = os.ReadFile(path); err != nil {
|
||||
return wrapper.Wrap(err)
|
||||
}
|
||||
if trimNewlines {
|
||||
data[key] = bytes.TrimRight(data[key], "\r\n")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -12,15 +12,16 @@ const ClusterLabel = "holos.run/cluster.name"
|
||||
type secretData map[string][]byte
|
||||
|
||||
type config struct {
|
||||
files holos.StringSlice
|
||||
printFile *string
|
||||
extract *bool
|
||||
dryRun *bool
|
||||
appendHash *bool
|
||||
dataStdin *bool
|
||||
cluster *string
|
||||
namespace *string
|
||||
extractTo *string
|
||||
files holos.StringSlice
|
||||
printFile *string
|
||||
extract *bool
|
||||
dryRun *bool
|
||||
appendHash *bool
|
||||
dataStdin *bool
|
||||
trimTrailingNewlines *bool
|
||||
cluster *string
|
||||
namespace *string
|
||||
extractTo *string
|
||||
}
|
||||
|
||||
func newConfig() (*config, *flag.FlagSet) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Create the secret
|
||||
holos create secret directory --from-file=$WORK/fixture --dry-run
|
||||
holos create secret directory --trim-trailing-newlines=false --from-file=$WORK/fixture --dry-run
|
||||
|
||||
# Want no warnings.
|
||||
! stderr 'WRN'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Create the secret
|
||||
holos create secret directory --from-file=$WORK/want
|
||||
holos create secret directory --trim-trailing-newlines=false --from-file=$WORK/want
|
||||
stderr 'created: directory-..........'
|
||||
stderr 'secret=directory-..........'
|
||||
stderr 'name=directory'
|
||||
|
||||
17
pkg/cli/secret/testdata/create_secret_from_dir_strip_newlines.txt
vendored
Normal file
17
pkg/cli/secret/testdata/create_secret_from_dir_strip_newlines.txt
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
# Create a secret from files with trailing newlines
|
||||
holos create secret smtp --from-file=$WORK/smtp
|
||||
|
||||
# Get the secret back expecting no trailing newlines
|
||||
mkdir have
|
||||
holos get secret smtp
|
||||
stdout '"username": "holos.run@gmail.com"'
|
||||
stdout '"password": "secret"'
|
||||
|
||||
-- smtp/username --
|
||||
holos.run@gmail.com
|
||||
-- smtp/password --
|
||||
secret
|
||||
-- smtp/host --
|
||||
smtp.gmail.com
|
||||
-- smtp/port --
|
||||
587
|
||||
@@ -1,5 +1,5 @@
|
||||
# Create the secret
|
||||
holos create secret directory --from-file=$WORK/want
|
||||
holos create secret directory --trim-trailing-newlines=false --from-file=$WORK/want
|
||||
|
||||
# Get the secret back
|
||||
mkdir have
|
||||
|
||||
@@ -1 +1 @@
|
||||
1
|
||||
3
|
||||
|
||||
Reference in New Issue
Block a user