Review of platform detection (#56)

* Leave default image platform empty for static provider (see FAQ doc)
* Handle platform variant
* Add database migration process
* Switch to Open Container Specification labels as label-schema.org ones are deprecated
* Remove unneeded `diun.os` and `diun.arch` docker labels

Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2020-03-31 23:27:10 +02:00
committed by GitHub
parent 2893414f59
commit 9c797f1616
28 changed files with 661 additions and 221 deletions

View File

@@ -66,6 +66,12 @@ func New(cfg *config.Config, location *time.Location) (*Diun, error) {
func (di *Diun) Start() error {
var err error
// Migrate db
err = di.db.Migrate()
if err != nil {
return err
}
// Run on startup
di.Run()

View File

@@ -51,8 +51,7 @@ func (di *Diun) createJob(job model.Job) {
// Set defaults
if err := mergo.Merge(&job.Image, model.Image{
Os: "linux",
Arch: "amd64",
Platform: model.ImagePlatform{},
WatchRepo: false,
MaxTags: 0,
}); err != nil {
@@ -75,13 +74,14 @@ func (di *Diun) createJob(job model.Job) {
}
job.Registry, err = registry.New(registry.Options{
Os: job.Image.Os,
Arch: job.Image.Arch,
Username: regUser,
Password: regPassword,
Timeout: time.Duration(regOpts.Timeout) * time.Second,
InsecureTLS: regOpts.InsecureTLS,
UserAgent: di.userAgent,
Username: regUser,
Password: regPassword,
Timeout: time.Duration(regOpts.Timeout) * time.Second,
InsecureTLS: regOpts.InsecureTLS,
UserAgent: di.userAgent,
ImageOs: job.Image.Platform.Os,
ImageArch: job.Image.Platform.Arch,
ImageVariant: job.Image.Platform.Variant,
})
if err != nil {
sublog.Error().Err(err).Msg("Cannot create registry client")