mirror of https://github.com/docker/docs.git
Merge pull request #103 from docker/default_expiry
update default expiry times to those agreed on
This commit is contained in:
commit
ac7c05516d
|
@ -63,7 +63,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/endophage/gotuf",
|
||||
"Rev": "b1fb060403583500ba06b11e35130b7c16c74c92"
|
||||
"Rev": "31d0377282dac4a9e5800933d9a920fb09a15331"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-sql-driver/mysql",
|
||||
|
|
|
@ -14,7 +14,7 @@ from Docker should be considered the official CLI to be used with this implement
|
|||
- [X] Sign metadata files
|
||||
- [X] Refactor TufRepo to take care of signing ~~and verification~~
|
||||
- [ ] Ensure consistent capitalization in naming (TUF\_\_\_ vs Tuf\_\_\_)
|
||||
- [ ] Make caching of metadata files smarter - PR #5
|
||||
- [X] Make caching of metadata files smarter - PR #5
|
||||
- [ ] ~~Add configuration for CLI commands. Order of configuration priority from most to least: flags, config file, defaults~~ Notary should be the official CLI
|
||||
- [X] Reasses organization of data types. Possibly consolidate a few things into the data package but break up package into a few more distinct files
|
||||
- [ ] Comprehensive test cases
|
||||
|
|
|
@ -136,15 +136,16 @@ func NewDelegations() *Delegations {
|
|||
}
|
||||
}
|
||||
|
||||
var defaultExpiryTimes = map[string]time.Time{
|
||||
"root": time.Now().AddDate(1, 0, 0),
|
||||
"targets": time.Now().AddDate(0, 3, 0),
|
||||
"snapshot": time.Now().AddDate(0, 0, 7),
|
||||
"timestamp": time.Now().AddDate(0, 0, 1),
|
||||
// defines number of days in which something should expire
|
||||
var defaultExpiryTimes = map[string]int{
|
||||
"root": 365,
|
||||
"targets": 90,
|
||||
"snapshot": 7,
|
||||
"timestamp": 1,
|
||||
}
|
||||
|
||||
// SetDefaultExpiryTimes allows one to change the default expiries.
|
||||
func SetDefaultExpiryTimes(times map[string]time.Time) {
|
||||
func SetDefaultExpiryTimes(times map[string]int) {
|
||||
for key, value := range times {
|
||||
if _, ok := defaultExpiryTimes[key]; !ok {
|
||||
logrus.Errorf("Attempted to set default expiry for an unknown role: %s", key)
|
||||
|
@ -157,7 +158,7 @@ func SetDefaultExpiryTimes(times map[string]time.Time) {
|
|||
func DefaultExpires(role string) time.Time {
|
||||
var t time.Time
|
||||
if t, ok := defaultExpiryTimes[role]; ok {
|
||||
return t
|
||||
return time.Now().AddDate(0, 0, t)
|
||||
}
|
||||
return t.UTC().Round(time.Second)
|
||||
}
|
||||
|
|
|
@ -26,6 +26,16 @@ import (
|
|||
|
||||
const maxSize = 5 << 20
|
||||
|
||||
func init() {
|
||||
data.SetDefaultExpiryTimes(
|
||||
map[string]int{
|
||||
"root": 3650,
|
||||
"targets": 1095,
|
||||
"snapshot": 1095,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// ErrRepoNotInitialized is returned when trying to can publish on an uninitialized
|
||||
// notary repository
|
||||
type ErrRepoNotInitialized struct{}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/distribution/registry/auth"
|
||||
"github.com/endophage/gotuf/data"
|
||||
"github.com/endophage/gotuf/signed"
|
||||
"github.com/gorilla/mux"
|
||||
"golang.org/x/net/context"
|
||||
|
@ -17,6 +18,14 @@ import (
|
|||
"github.com/docker/notary/utils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
data.SetDefaultExpiryTimes(
|
||||
map[string]int{
|
||||
"timestamp": 14,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// Run sets up and starts a TLS server that can be cancelled using the
|
||||
// given configuration. The context it is passed is the context it should
|
||||
// use directly for the TLS server, and generate children off for requests
|
||||
|
|
Loading…
Reference in New Issue