Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion api/v1beta1/vaultpkisecret_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ type VaultPKISecretSpec struct {
// ExcludeCNFromSans from DNS or Email Subject Alternate Names.
// Default: false
ExcludeCNFromSans bool `json:"excludeCNFromSans,omitempty"`
// +kubebuilder:default=true
RemoveRootsFromChain bool `json:"removeRootsFromChain,omitempty"`
}

// VaultPKISecretStatus defines the observed state of VaultPKISecret
Expand Down Expand Up @@ -163,7 +165,7 @@ func (v *VaultPKISecret) GetIssuerAPIData() map[string]interface{} {
"ttl": v.Spec.TTL,
"not_after": v.Spec.NotAfter,
"exclude_cn_from_sans": v.Spec.ExcludeCNFromSans,
"remove_roots_from_chain": true,
"remove_roots_from_chain": v.Spec.RemoveRootsFromChain,
}

if v.Spec.Format != "" {
Expand Down
30 changes: 30 additions & 0 deletions api/v1beta1/vaultpkisecret_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,36 @@ func TestVaultPKISecret_GetIssuerAPIData(t *testing.T) {
"remove_roots_from_chain": true,
},
},
{
name: "remove-roots-false",
spec: VaultPKISecretSpec{
CommonName: "qux",
AltNames: []string{"foo", "baz"},
IPSans: []string{"buz", "qux"},
URISans: []string{"*.foo.net", "*.baz.net"},
OtherSans: []string{"other1", "other2"},
UserIDs: []string{"12345", "67890"},
TTL: "30s",
NotAfter: "2026-05-01T00:00:00Z",
Format: "pem",
PrivateKeyFormat: "rsa",
RemoveRootsFromChain: false,
},
want: map[string]interface{}{
"common_name": "qux",
"alt_names": "foo,baz",
"ip_sans": "buz,qux",
"uri_sans": "*.foo.net,*.baz.net",
"other_sans": "other1,other2",
"user_ids": "12345,67890",
"ttl": "30s",
"not_after": "2026-05-01T00:00:00Z",
"exclude_cn_from_sans": false,
"format": "pem",
"private_key_format": "rsa",
"remove_roots_from_chain": false,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Loading