changeset 1696:ad5e1cddaa09

Imports: Resolved the remaining golint issues with this package.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 04 Jan 2019 13:41:07 +0100
parents be78b429ef6e
children f1c3fe8b79f5 b38a71d1c08a
files pkg/imports/bn.go pkg/imports/config.go pkg/imports/fa.go pkg/imports/gm.go pkg/imports/wx.go
diffstat 5 files changed, 57 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/imports/bn.go	Fri Jan 04 10:00:11 2019 +0100
+++ b/pkg/imports/bn.go	Fri Jan 04 13:41:07 2019 +0100
@@ -35,7 +35,7 @@
 	Insecure bool `json:"insecure"`
 }
 
-// BNJobKind is import queue type identifier.
+// BNJobKind is the import queue type identifier.
 const BNJobKind JobKind = "bn"
 
 const (
--- a/pkg/imports/config.go	Fri Jan 04 10:00:11 2019 +0100
+++ b/pkg/imports/config.go	Fri Jan 04 13:41:07 2019 +0100
@@ -19,22 +19,41 @@
 	"encoding/json"
 	"fmt"
 
+	"github.com/robfig/cron"
+
 	"gemma.intevation.de/gemma/pkg/auth"
-	"github.com/robfig/cron"
 )
 
 type (
-	CronSpec   string
+	// CronSpec is a string containing a cron line.
+	CronSpec string
+
+	// ImportKind is a string which has to be one
+	// of the registered import types.
 	ImportKind string
 
+	// Config is JSON serialized form of a import configuration.
 	Config struct {
-		Kind       ImportKind `json:"kind"`
-		SendEMail  bool       `json:"send-email"`
-		AutoAccept bool       `json:"auto-accept"`
-		Cron       *CronSpec  `json:"cron"`
-		URL        *string    `json:"url"`
+		// Kind is the import type.
+		Kind ImportKind `json:"kind"`
+		// SendEMail indicates if a mail should be be send
+		// when the import was changed to states
+		// 'pending' or 'failed'.
+		SendEMail bool `json:"send-email"`
+		// AutoAccept indicates that an import
+		// automatically will change from state
+		// 'pending' to state 'accepted'.
+		AutoAccept bool `json:"auto-accept"`
+		// Cron is the cron schedule
+		// of this configuration if this value is not
+		// nil. If nil the import is not scheduled.
+		Cron *CronSpec `json:"cron"`
+		// URL is an optional URL used by the import.
+		URL *string `json:"url"`
 	}
 
+	// IDConfig is the same as Config with an ID.
+	// Mainly used for server delivered configurations.
 	IDConfig struct {
 		ID         int64      `json:"id"`
 		User       string     `json:"user"`
@@ -46,6 +65,8 @@
 	}
 )
 
+// UnmarshalJSON checks if the incoming string
+// is a registered import type.
 func (ik *ImportKind) UnmarshalJSON(data []byte) error {
 	var s string
 	if err := json.Unmarshal(data, &s); err != nil {
@@ -61,6 +82,8 @@
 	return nil
 }
 
+// UnmarshalJSON checks if the incoming string is
+// a valid cron line.
 func (cs *CronSpec) UnmarshalJSON(data []byte) error {
 	var spec string
 	if err := json.Unmarshal(data, &spec); err != nil {
--- a/pkg/imports/fa.go	Fri Jan 04 10:00:11 2019 +0100
+++ b/pkg/imports/fa.go	Fri Jan 04 13:41:07 2019 +0100
@@ -26,11 +26,17 @@
 	"gemma.intevation.de/gemma/pkg/soap/ifaf"
 )
 
+// FairwayAvailability imports fairway availability data
+// from an IFAF SOAP service.
 type FairwayAvailability struct {
-	URL      string `json:"url"`
-	Insecure bool   `json:"insecure"`
+	// URL is the URL of the SOAP service.
+	URL string `json:"url"`
+	// Insecure indicates if HTTPS traffic
+	// should validate certificates or not.
+	Insecure bool `json:"insecure"`
 }
 
+// FAJobKind is import queue type identifier.
 const FAJobKind JobKind = "fa"
 
 const (
--- a/pkg/imports/gm.go	Fri Jan 04 10:00:11 2019 +0100
+++ b/pkg/imports/gm.go	Fri Jan 04 13:41:07 2019 +0100
@@ -24,11 +24,17 @@
 	"gemma.intevation.de/gemma/pkg/soap/nts"
 )
 
+// GaugeMeasurement is an import job to import
+// gauges measurement data from a NtS SOAP service.
 type GaugeMeasurement struct {
-	URL      string `json:"url"`
-	Insecure bool   `json:"insecure"`
+	// URL is the URL of the SOAP service.
+	URL string `json:"url"`
+	// Insecure indicates if HTTPS traffic
+	// should validate certificates or not.
+	Insecure bool `json:"insecure"`
 }
 
+// GMJobKind is the import queue type identifier.
 const GMJobKind JobKind = "gm"
 
 const (
--- a/pkg/imports/wx.go	Fri Jan 04 10:00:11 2019 +0100
+++ b/pkg/imports/wx.go	Fri Jan 04 13:41:07 2019 +0100
@@ -30,12 +30,20 @@
 	"gemma.intevation.de/gemma/pkg/wfs"
 )
 
+// WaterwayAxis is an import job to import
+// the waterway axes in form of line string geometries
+// and attribute data from a WFS service.
 type WaterwayAxis struct {
-	URL         string `json:"url"`
+	// URL the GetCapabilities URL of the WFS service.
+	URL string `json:"url"`
+	// FeatureType selects the feature type of the WFS service.
 	FeatureType string `json:"feature-type"`
-	SortBy      string `json:"sort-by"`
+	// SortBy works around misconfigured services to
+	// establish a sort order to get the features.
+	SortBy string `json:"sort-by"`
 }
 
+// WXJobKind is the import queue type identifier.
 const WXJobKind JobKind = "wx"
 
 type wxJobCreator struct{}