mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #38036 # Checklist for submitter If some of the following don't apply, delete the relevant line. - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. ## Testing - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * GitOps now correctly orders operations so certificate authorities can be removed only after referencing certificate templates are handled, preventing failed deletions during config updates. * Improved user-facing error when a CA cannot be deleted because certificate templates still reference it, with guidance to remove templates first. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
35 lines
1.6 KiB
Go
35 lines
1.6 KiB
Go
package service
|
|
|
|
import "github.com/fleetdm/fleet/v4/server/fleet"
|
|
|
|
// GetCertificateAuthoritiesSpec fetches the certificate authorities stored on the server
|
|
func (c *Client) GetCertificateAuthoritiesSpec(includeSecrets bool) (*fleet.GroupedCertificateAuthorities, error) {
|
|
verb, path := "GET", "/api/latest/fleet/spec/certificate_authorities"
|
|
var responseBody getCertificateAuthoritiesSpecResponse
|
|
query := ""
|
|
if includeSecrets {
|
|
query = "include_secrets=true"
|
|
}
|
|
err := c.authenticatedRequestWithQuery(nil, verb, path, &responseBody, query)
|
|
return responseBody.CertificateAuthorities, err
|
|
}
|
|
|
|
// ApplyCertificateAuthoritiesSpec applies the certificate authorities.
|
|
func (c *Client) ApplyCertificateAuthoritiesSpec(groupedCAs fleet.GroupedCertificateAuthorities, specOpts fleet.ApplySpecOptions, opts fleet.BatchApplyCertificateAuthoritiesOpts) error {
|
|
req := batchApplyCertificateAuthoritiesRequest{
|
|
CertificateAuthorities: groupedCAs,
|
|
DryRun: specOpts.DryRun,
|
|
SkipDeletes: opts.SkipDeletes,
|
|
}
|
|
verb, path := "POST", "/api/latest/fleet/spec/certificate_authorities"
|
|
var responseBody batchApplyCertificateAuthoritiesResponse
|
|
return c.authenticatedRequestWithQuery(req, verb, path, &responseBody, specOpts.RawQuery())
|
|
}
|
|
|
|
// GetCertificateAuthorities fetches the list of certificate authorities
|
|
func (c *Client) GetCertificateAuthorities() ([]*fleet.CertificateAuthoritySummary, error) {
|
|
verb, path := "GET", "/api/latest/fleet/certificate_authorities"
|
|
var responseBody listCertificateAuthoritiesResponse
|
|
err := c.authenticatedRequest(nil, verb, path, &responseBody)
|
|
return responseBody.CertificateAuthorities, err
|
|
}
|