Some cleanup based on goreportcard linters (#517)

This commit is contained in:
Danny Lockard
2018-10-02 13:54:10 -05:00
committed by Victor Vrantchan
parent c146e224d7
commit f45a0469f0
14 changed files with 20 additions and 22 deletions

View File

@@ -118,7 +118,10 @@ func migrateServerConfig(configName string) error {
}
err = switchServerConfig(configName)
if err != nil {
fmt.Errorf("Failed to set %s as active config", configName)
err = fmt.Errorf("Failed to set %s as active config", configName)
if err != nil {
return errors.Wrapf(err, "Failed to set %s as active config", configName)
}
}
fmt.Println("Successfully migrated old config.")
return nil

View File

@@ -123,7 +123,7 @@ func (out *devicesTableOutput) BasicFooter() {
func (cmd *getCommand) getDevices(args []string) error {
flagset := flag.NewFlagSet("devices", flag.ExitOnError)
var (
flFilterSerials = flagset.String("serials", "", "comma seperated list of serials to search")
flFilterSerials = flagset.String("serials", "", "comma separated list of serials to search")
)
flagset.Usage = usageFor(flagset, "mdmctl get devices [flags]")
if err := flagset.Parse(args); err != nil {

View File

@@ -24,8 +24,8 @@ type Account struct {
OrgEmail string `json:"org_email"`
OrgPhone string `json:"org_phone"`
OrgAddress string `json:"org_address"`
OrgID string `json"org_id"`
OrgIDHash string `json"org_id_hash"`
OrgID string `json:"org_id"`
OrgIDHash string `json:"org_id_hash"`
URLs []URL `json:"urls"`
OrgType string `json:"org_type"`
OrgVersion string `json:"org_version"`

View File

@@ -96,7 +96,7 @@ func Create(file File, url string, opts ...Option) (*Manifest, error) {
// make a manifest
m := Manifest{
ManifestItems: []Item{
Item{
{
Assets: []Asset{ast},
},
},

View File

@@ -53,7 +53,7 @@ func NewService(topic TopicProvider, sub pubsub.Subscriber, scepURL, scepChallen
continue
}
subjectKeyValue := strings.Split(element, "=")
subject = append(subject, [][]string{[]string{subjectKeyValue[0], subjectKeyValue[1]}})
subject = append(subject, [][]string{{subjectKeyValue[0], subjectKeyValue[1]}})
}
// fetch the push topic from the db.

View File

@@ -182,7 +182,7 @@ type RemoveApplication struct {
}
type InviteToProgram struct {
ProgramID string `plist:",omitempty" json"program_id,omitempty"`
ProgramID string `plist:",omitempty" json:"program_id,omitempty"`
InvitationURL string `plist:",omitempty" json:"invitation_url,omitempty"`
}
@@ -262,7 +262,7 @@ type ScheduleOSUpdateScan struct {
}
type ActiveNSExtensions struct {
FilterExtensionPoints []string `plist:",omitempty json:"filter_extensions_points,omitempty"`
FilterExtensionPoints []string `plist:",omitempty" json:"filter_extensions_points,omitempty"`
}
type RotateFileVaultKey struct {

View File

@@ -84,7 +84,7 @@ func populateDeviceCertificateFromSignRequestHeader(ctx context.Context, r *http
}
// TODO: If we ever use Go client cert auth we can use
// r.TLS.PeerCertificates to return the client cert. Unecessary
// r.TLS.PeerCertificates to return the client cert. Unnecessary
// now as default config is uses Mdm-Signature header method instead
// (for better compatilibity with proxies, etc.)
// func populateDeviceCertificateFromTLSPeerCertificates()

View File

@@ -12,7 +12,7 @@ import (
"github.com/micromdm/micromdm/pkg/crypto"
)
// immitate an Mdm-Signature header
// imitate a Mdm-Signature header
func mdmSignRequest(body []byte) (*x509.Certificate, string, error) {
key, cert, err := crypto.SimpleSelfSignedRSAKeypair("test", 365)
if err != nil {

View File

@@ -149,7 +149,7 @@ func NewCSR(priv *rsa.PrivateKey, email, country, cname string) ([]byte, error)
subj := pkix.Name{
Country: []string{country},
CommonName: cname,
ExtraNames: []pkix.AttributeTypeAndValue{pkix.AttributeTypeAndValue{
ExtraNames: []pkix.AttributeTypeAndValue{{
Type: []int{1, 2, 840, 113549, 1, 9, 1},
Value: email,
}},

View File

@@ -32,7 +32,7 @@ func (db *DB) ApplyToDevice(ctx context.Context, svc command.Service, bp *bluepr
SkipPrimarySetupAccountCreation: bp.SkipPrimarySetupAccountCreation,
SetPrimarySetupAccountAsRegularUser: bp.SetPrimarySetupAccountAsRegularUser,
AutoSetupAdminAccounts: []mdm.AdminAccount{
mdm.AdminAccount{
{
ShortName: u.UserShortname,
FullName: u.UserLongname,
PasswordHash: u.PasswordHash,

View File

@@ -27,10 +27,8 @@ func (db *DB) AddToken(consumerKey string, json []byte) error {
if err != nil {
return err
}
if err := db.Publisher.Publish(context.TODO(), config.DEPTokenTopic, json); err != nil {
return err
}
return nil
err = db.Publisher.Publish(context.TODO(), config.DEPTokenTopic, json)
return err
}
func (db *DB) DEPTokens() ([]config.DEPToken, error) {

View File

@@ -102,5 +102,4 @@ func (mw *udidCertAuthMiddleware) Checkin(ctx context.Context, req mdm.CheckinEv
default:
return errors.Errorf("unknown checkin message type %s", req.Command.MessageType)
}
return mw.next.Checkin(ctx, req)
}

View File

@@ -109,7 +109,7 @@ func TestNext_Idle(t *testing.T) {
CommandUUID: "xCmd",
Status: "Idle",
}
for i, _ := range dc.Commands {
for i := range dc.Commands {
cmd, err := store.nextCommand(ctx, resp)
if err != nil {
t.Fatalf("expected nil, but got err: %s", err)

View File

@@ -125,11 +125,9 @@ func (c *Server) Setup(logger log.Logger) error {
return err
}
if err := c.setupEnrollmentService(); err != nil {
return err
}
err := c.setupEnrollmentService()
return nil
return err
}
func (c *Server) setupProfileDB() error {