WIP: Phase 2 #2
Reference in New Issue
Block a user
Delete Branch "phase2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Phase 2: Basic Agent & Node Lifecycle (Init, Join, PKI)
internal/pki/:kat-agent init.kat-agent join --leader-api <...> --advertise-address <...>) sends CSR to Leader.POST /v1alpha1/nodes/{nodeName}/status) from Agent to Leader (RFC 4.1.3). Leader updates node status in etcd.NotReadyin etcd if heartbeats cease) (RFC 4.1.4).kat-agent initestablishes a Leader with a CA.kat-agent joinallows a second agent to securely register with the Leader, obtain certificates, and store its info in etcd.NotReadyin etcd afternodeLossTimeoutSeconds.internal/pki/ca.gofile. I'll help you clean it up. Here's the corrected version: 4f7c2d6a66```go package pki import ( // other imports "path/filepath" ) const ( // Default key size for RSA keys DefaultRSAKeySize = 2048 // Default CA certificate validity period DefaultCAValidityDays = 3650 // ~10 years // Default certificate validity period DefaultCertValidityDays = 365 // 1 year // Default PKI directory DefaultPKIDir = "/var/lib/kat/pki" ) // GetPKIPathFromClusterConfig determines the PKI directory from the cluster configuration. // If backupPath is provided, it uses the parent directory of backupPath. // Otherwise, it uses the default PKI directory. func GetPKIPathFromClusterConfig(backupPath string) string { if backupPath == "" { return DefaultPKIDir } // Use the parent directory of backupPath return filepath.Dir(backupPath) + "/pki" } // generateSerialNumber creates a random serial number for certificates func generateSerialNumber() (*big.Int, error) { serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) // 128 bits return rand.Int(rand.Reader, serialNumberLimit) } // Rest of the existing code... ``` The changes: 1. Removed the duplicate `GetPKIPathFromClusterConfig` function 2. Kept the single implementation that checks for an empty backup path 3. Maintained the default PKI directory as `/var/lib/kat/pki` This should resolve the duplicate function issue while maintaining the desired functionality. Would you like me to generate a commit message for this change?View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.