Skip to content

Commit

Permalink
put some remarks from PR discussion
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksandr Krutko <alexander.krutko@gmail.com>
  • Loading branch information
arsenalzp committed Jul 10, 2024
1 parent 4cb0887 commit 979221b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/bundle/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type bundleData struct {
// is each bundle is concatenated together with a new line character.
func (b *bundle) buildSourceBundle(ctx context.Context, sources []trustapi.BundleSource, formats *trustapi.AdditionalFormats) (bundleData, error) {
var resolvedBundle bundleData
var certPool = util.NewCertPool(util.WithFilteredExpiredCerts(b.FilterExpiredCerts))
certPool := util.NewCertPool(util.WithFilteredExpiredCerts(b.FilterExpiredCerts))

for _, source := range sources {
var (
Expand Down
2 changes: 1 addition & 1 deletion pkg/fspkg/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (p *Package) Validate() error {
// Ignore the sanitized bundle here and preserve the bundle as-is.
// We'll sanitize later, when building a bundle on a reconcile.

var certPool = util.NewCertPool(util.WithFilteredExpiredCerts(false))
certPool := util.NewCertPool(util.WithFilteredExpiredCerts(false))

err := util.ValidateAndSplitPEMBundle(certPool, []byte(p.Bundle))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/cert_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func WithFilteredExpiredCerts(filterExpired bool) Option {

// newCertPool returns a new, empty CertPool.
func NewCertPool(options ...Option) *CertPool {
var certPool = &CertPool{
certPool := &CertPool{
certificates: make([]*x509.Certificate, 0),
certificatesHashes: make(map[[32]byte]struct{}),
}
Expand Down
6 changes: 2 additions & 4 deletions test/env/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,9 @@ func CheckBundleSyncedStartsWith(ctx context.Context, cl client.Client, name str
return fmt.Errorf("received data didn't start with expected data")
}

var certPool = util.NewCertPool(util.WithFilteredExpiredCerts(false))

remaining := strings.TrimPrefix(got, startingData)

// check that there are a nonzero number of valid certs remaining
certPool := util.NewCertPool(util.WithFilteredExpiredCerts(false))

err := util.ValidateAndSplitPEMBundle(certPool, []byte(remaining))
if err != nil {
Expand Down Expand Up @@ -337,7 +335,7 @@ func CheckJKSFileSynced(jksData []byte, expectedPassword string, expectedCertPEM
// that the count is the same

aliasCount := len(ks.Aliases())
expectedPEMCount := len(util.AsSplitPEMBundle(certPool))
expectedPEMCount := util.GetCertificatesQuantity(certPool)

if aliasCount != expectedPEMCount {
return fmt.Errorf("expected %d certificates in JKS but found %d", expectedPEMCount, aliasCount)
Expand Down

0 comments on commit 979221b

Please sign in to comment.