@@ -69,6 +69,7 @@ func IssueEnterpriseLicense(fs blobfs.Interface, certs *certstore.CertStore, inf
69
69
70
70
// 1 yr domain license
71
71
license := & ProductLicense {
72
+ ID : info .ID ,
72
73
Domain : domain ,
73
74
Product : info .Product (),
74
75
Agreement : & LicenseAgreement {
@@ -78,12 +79,12 @@ func IssueEnterpriseLicense(fs blobfs.Interface, certs *certstore.CertStore, inf
78
79
}
79
80
80
81
var crtLicense []byte
81
- exists , err := fs .Exists (context .TODO (), LicenseCertPath ( license .Domain , license . Product , info .Cluster ))
82
+ exists , err := fs .Exists (context .TODO (), license .LicenseCertPath ( info .Cluster ))
82
83
if err != nil {
83
84
return nil , nil , err
84
85
}
85
86
if exists {
86
- data , err := fs .ReadFile (context .TODO (), LicenseCertPath ( license .Domain , license . Product , info .Cluster ))
87
+ data , err := fs .ReadFile (context .TODO (), license .LicenseCertPath ( info .Cluster ))
87
88
if err != nil {
88
89
return nil , nil , err
89
90
}
@@ -92,7 +93,7 @@ func IssueEnterpriseLicense(fs blobfs.Interface, certs *certstore.CertStore, inf
92
93
return nil , nil , err
93
94
}
94
95
if len (certs ) > 1 {
95
- return nil , nil , fmt .Errorf ("multiple certificates found in %s" , LicenseCertPath ( license .Domain , license . Product , info .Cluster ))
96
+ return nil , nil , fmt .Errorf ("multiple certificates found in %s" , license .LicenseCertPath ( info .Cluster ))
96
97
}
97
98
98
99
if ! certs [0 ].NotAfter .Before (license .Agreement .ExpiryDate .Time ) {
@@ -113,26 +114,29 @@ func IssueEnterpriseLicense(fs blobfs.Interface, certs *certstore.CertStore, inf
113
114
LicenseForm : info ,
114
115
Timestamp : timestamp ,
115
116
}
116
- {
117
- // record request
118
- data , err := json .MarshalIndent (accesslog , "" , " " )
119
- if err != nil {
120
- return nil , nil , err
121
- }
122
- err = fs .WriteFile (context .TODO (), FullLicenseIssueLogPath (domain , info .Product (), info .Cluster , timestamp ), data )
123
- if err != nil {
124
- return nil , nil , err
125
- }
126
- }
127
-
128
- {
129
- // mark email as verified
130
- if exists , err := fs .Exists (context .TODO (), EmailVerifiedPath (domain , info .Email )); err == nil && ! exists {
131
- err = fs .WriteFile (context .TODO (), EmailVerifiedPath (domain , info .Email ), []byte (timestamp ))
117
+ // only log for https://appscode.com/issue-license/
118
+ if license .ID <= 0 {
119
+ {
120
+ // record request
121
+ data , err := json .MarshalIndent (accesslog , "" , " " )
122
+ if err != nil {
123
+ return nil , nil , err
124
+ }
125
+ err = fs .WriteFile (context .TODO (), FullLicenseIssueLogPath (domain , info .Product (), info .Cluster , timestamp ), data )
132
126
if err != nil {
133
127
return nil , nil , err
134
128
}
135
129
}
130
+
131
+ {
132
+ // mark email as verified
133
+ if exists , err := fs .Exists (context .TODO (), EmailVerifiedPath (domain , info .Email )); err == nil && ! exists {
134
+ err = fs .WriteFile (context .TODO (), EmailVerifiedPath (domain , info .Email ), []byte (timestamp ))
135
+ if err != nil {
136
+ return nil , nil , err
137
+ }
138
+ }
139
+ }
136
140
}
137
141
138
142
return crtLicense , & accesslog , nil
@@ -176,11 +180,11 @@ func CreateLicense(fs blobfs.Interface, certs *certstore.CertStore, info License
176
180
return nil , errors .Wrap (err , "failed to generate client certificate" )
177
181
}
178
182
179
- err = fs .WriteFile (context .TODO (), LicenseCertPath ( license .Domain , license . Product , cluster ), cert .EncodeCertPEM (crt ))
183
+ err = fs .WriteFile (context .TODO (), license .LicenseCertPath ( cluster ), cert .EncodeCertPEM (crt ))
180
184
if err != nil {
181
185
return nil , err
182
186
}
183
- err = fs .WriteFile (context .TODO (), LicenseKeyPath ( license .Domain , license . Product , cluster ), cert .EncodePrivateKeyPEM (key ))
187
+ err = fs .WriteFile (context .TODO (), license .LicenseKeyPath ( cluster ), cert .EncodePrivateKeyPEM (key ))
184
188
if err != nil {
185
189
return nil , err
186
190
}
0 commit comments