Mercurial > gemma
view pkg/models/importconfig.go @ 1567:ed67857a2079
layout
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Wed, 12 Dec 2018 13:01:52 +0100 |
parents | fe633765e05b |
children |
line wrap: on
line source
package models import ( "encoding/json" "fmt" "github.com/robfig/cron" "gemma.intevation.de/gemma/pkg/scheduler" ) // This is Free Software under GNU Affero General Public License v >= 3.0 // without warranty, see README.md and license for details. // // SPDX-License-Identifier: AGPL-3.0-or-later // License-Filename: LICENSES/AGPL-3.0.txt // // Copyright (C) 2018 by via donau // – Österreichische Wasserstraßen-Gesellschaft mbH // Software engineering by Intevation GmbH // // Author(s): // * Sascha L. Teichmann <sascha.teichmann@intevation.de> type ( CronSpec string ImportKind string ImportConfig struct { Kind ImportKind `json:"kind"` Cron CronSpec `json:"cron"` URL *string `json:"url"` } ) func (ik *ImportKind) UnmarshalJSON(data []byte) error { var s string if err := json.Unmarshal(data, &s); err != nil { return err } if !scheduler.HasAction(s) { return fmt.Errorf("Unknown kind '%s'", s) } *ik = ImportKind(s) return nil } func (cs *CronSpec) UnmarshalJSON(data []byte) error { var spec string if err := json.Unmarshal(data, &spec); err != nil { return err } if _, err := cron.Parse(spec); err != nil { return err } *cs = CronSpec(spec) return nil }