Support generate-gitops for android certificates - #36457
Conversation
| if len(certSummaries) > 0 { | ||
| androidSettingsType := reflect.TypeOf(fleet.AndroidSettings{}) | ||
| certType := reflect.TypeOf(fleet.CertificateTemplateResponseFull{}) | ||
| fullCerts := make([]map[string]interface{}, 0, len(certSummaries)) | ||
| for _, certSummary := range certSummaries { | ||
| certFull, err := cmd.Client.GetCertificateTemplate(certSummary.ID, nil) | ||
| if err != nil { | ||
| fmt.Fprintf(cmd.CLI.App.ErrWriter, "Error getting certificate template details for ID %d: %s\n", certSummary.ID, err) | ||
| return nil, err | ||
| } | ||
| fullCerts = append(fullCerts, map[string]interface{}{ | ||
| jsonFieldName(certType, "Name"): certFull.Name, | ||
| jsonFieldName(certType, "CertificateAuthorityName"): certFull.CertificateAuthorityName, | ||
| jsonFieldName(certType, "SubjectName"): certFull.SubjectName, | ||
| }) | ||
| } |
There was a problem hiding this comment.
The "get certificate templates" endpoint doesn't return SubjectName, so we're forced to call the "get certificate template" endpoint once per cert here. It might be worth adding SubjectName to the "summary" response (always returning the raw summary, without tokens replaced) to optimize this.
There was a problem hiding this comment.
I was going off of #35156
https://github.com/fleetdm/fleet/pull/35156/files#diff-7246bc304b15c8865ed8eaa205e9c244d0a0314e4bae60cf553dc06147c38b64R821
GET /api/v1/fleet/certificates
{
"certificates": [
{
"id": 1,
"name": "wifi-certificate",
"certificate_authority_id": "1",
"certificate_authority_name": "PRODUCTION_SCEP_SERVER",
"created_at": "2025-11-04T00:00:00Z",
},
{
"id": 2,
"name": "vpn-certificate",
"certificate_authority_id": "1",
"certificate_authority_name": "PRODUCTION_SCEP_SERVER",
"created_at": "2025-11-04T00:00:00Z",
}
],
"meta": {
"has_next_results": false,
"has_previous_results": false
}
}But I don't see why we can't have it return the subject name with un-replaced values.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #36457 +/- ##
=======================================
Coverage 66.00% 66.00%
=======================================
Files 2134 2134
Lines 181840 181895 +55
Branches 7565 7565
=======================================
+ Hits 120027 120065 +38
- Misses 50824 50840 +16
- Partials 10989 10990 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Related issue: Resolves #36436
Details
Implements outputting
android_settings.certificateswhen runningfleetctl generate-gitops.Checklist for submitter
Testing
fleetctl generate-gitops.