Skip to content

Support generate-gitops for android certificates - #36457

Merged
sgress454 merged 1 commit into
mainfrom
sgress454/android-certs-generate-gitops
Dec 2, 2025
Merged

Support generate-gitops for android certificates#36457
sgress454 merged 1 commit into
mainfrom
sgress454/android-certs-generate-gitops

Conversation

@sgress454

Copy link
Copy Markdown
Contributor

Related issue: Resolves #36436

Details

Implements outputting android_settings.certificates when running fleetctl generate-gitops.

Checklist for submitter

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually
  • Added a certificate authority via the UI, then added some certificates via GitOps, and verified that the certificates were outputted correctly when using fleetctl generate-gitops.

@sgress454
sgress454 requested a review from a team as a code owner December 1, 2025 02:11
Comment on lines +1084 to +1099
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,
})
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

codecov Bot commented Dec 1, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.00%. Comparing base (23b60d7) to head (2e68807).
⚠️ Report is 86 commits behind head on main.

Files with missing lines Patch % Lines
server/service/client_android_certificates.go 0.00% 10 Missing ⚠️
cmd/fleetctl/fleetctl/generate_gitops.go 80.00% 4 Missing and 2 partials ⚠️
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     
Flag Coverage Δ
backend 67.58% <60.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sgress454
sgress454 merged commit ee1eaf2 into main Dec 2, 2025
45 checks passed
@sgress454
sgress454 deleted the sgress454/android-certs-generate-gitops branch December 2, 2025 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

android certificates - output certificate templates in generate-gitops

2 participants