@@ -22,6 +22,8 @@ import (
22
22
"encoding/json"
23
23
"fmt"
24
24
"path"
25
+ "reflect"
26
+ "strings"
25
27
"time"
26
28
27
29
licenseapi "go.bytebuilders.dev/license-verifier/apis/licenses/v1alpha1"
@@ -74,7 +76,7 @@ func IssueEnterpriseLicense(fs blobfs.Interface, certs *certstore.CertStore, inf
74
76
Product : info .Product (),
75
77
Agreement : & LicenseAgreement {
76
78
NumClusters : 1 , // is not used currently
77
- ExpiryDate : metav1 .NewTime (time .Now ().Add (extendBy ).UTC ()),
79
+ ExpiryDate : metav1 .NewTime (time .Now ().Add (extendBy ).UTC (). Truncate ( time . Second ) ),
78
80
},
79
81
}
80
82
@@ -96,7 +98,17 @@ func IssueEnterpriseLicense(fs blobfs.Interface, certs *certstore.CertStore, inf
96
98
return nil , nil , fmt .Errorf ("multiple certificates found in %s" , license .LicenseCertPath (info .Cluster ))
97
99
}
98
100
99
- if ! certs [0 ].NotAfter .Before (license .Agreement .ExpiryDate .Time ) {
101
+ existingFeatureFlags := licenseapi.FeatureFlags {}
102
+ for _ , ff := range certs [0 ].Subject .Locality {
103
+ parts := strings .SplitN (ff , "=" , 2 )
104
+ if len (parts ) == 2 {
105
+ existingFeatureFlags [licenseapi .FeatureFlag (parts [0 ])] = parts [1 ]
106
+ }
107
+ }
108
+
109
+ if ! certs [0 ].NotAfter .Before (license .Agreement .ExpiryDate .Time ) &&
110
+ reflect .DeepEqual (existingFeatureFlags , ff ) {
111
+
100
112
// Original license is sufficiently valid. Keep using that.
101
113
crtLicense = cert .EncodeCertPEM (certs [0 ])
102
114
license .Agreement .ExpiryDate = metav1 .NewTime (certs [0 ].NotAfter .UTC ())
0 commit comments