diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b9244aac..eb6f5f18 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -11,7 +11,7 @@ jobs: name: Build, test, and format strategy: matrix: - go-version: [1.16.x, 1.17.x] + go-version: [1.18.x, 1.19.x, 1.20.x] platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index 302f2973..06182075 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ ## [Unreleased](https://github.com/micromdm/micromdm/compare/v1.11.0...main) +- Add `-log-time` flag to include timestamps in log messages (#890) +- Add `-device-signature-skew` flag to allow configuring clock skew when verifying device signatures (#887) +- Tidy code for Go 1.20, and update Go version for Docker and CI +- Project dependency updates (#888, #889, #900) + +Thanks to our contributors: @jamesez, @korylprince + ## [v1.11.0](https://github.com/micromdm/micromdm/compare/v1.10.1...v1.11.0) This release includes new features and fixes. diff --git a/Dockerfile b/Dockerfile index 4ec8d1ff..1789eeee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.17 as builder +FROM golang:1.20 as builder WORKDIR /go/src/github.com/micromdm/micromdm/ diff --git a/cmd/mdmctl/apply.go b/cmd/mdmctl/apply.go index c881e4d2..37040541 100644 --- a/cmd/mdmctl/apply.go +++ b/cmd/mdmctl/apply.go @@ -100,8 +100,9 @@ Examples: # Apply a DEP Profile. mdmctl apply dep-profiles -f /path/to/dep-profile.json + ` - fmt.Println(applyUsage) + fmt.Print(applyUsage) return nil } @@ -296,8 +297,8 @@ func (cmd *applyCommand) applyProfile(args []string) error { ) flagset.Usage = func() { fmt.Fprintf(os.Stderr, "%s\n", - `Upload profiles to the server. - + `Upload profiles to the server. + Uploaded profiles can also be specified in a blueprint, which will be applied on device enrollment. This command can also be used to replace the enrollment profile. Profiles can be signed before upload. diff --git a/cmd/mdmctl/apply_dep_autoassigner.go b/cmd/mdmctl/apply_dep_autoassigner.go index ac13d573..888aeea1 100644 --- a/cmd/mdmctl/apply_dep_autoassigner.go +++ b/cmd/mdmctl/apply_dep_autoassigner.go @@ -24,7 +24,7 @@ func (cmd *applyCommand) applyDEPAutoAssigner(args []string) error { return errors.New("bad input: must provide both -filter and -uuid") } - assigner := sync.AutoAssigner{*flFilter, *flProfileUUID} + assigner := sync.AutoAssigner{Filter: *flFilter, ProfileUUID: *flProfileUUID} err := cmd.depsyncsvc.ApplyAutoAssigner(context.TODO(), &assigner) if err != nil { diff --git a/cmd/mdmctl/config.go b/cmd/mdmctl/config.go index ad03edb5..ebc736e8 100644 --- a/cmd/mdmctl/config.go +++ b/cmd/mdmctl/config.go @@ -79,8 +79,9 @@ func (cmd *configCommand) Usage() error { mdmctl config print mdmctl config set -h mdmctl config switch -h + ` - fmt.Println(help) + fmt.Print(help) return nil } @@ -108,7 +109,7 @@ func migrateServerConfig(configName string) error { var serverCfg *ServerConfig err = json.Unmarshal(cfgData, &serverCfg) if err != nil { - return errors.Wrapf(err, "failed to unmarshal %s", configPath) + return fmt.Errorf("failed to unmarshal %s: %w", configPath, err) } if err = saveServerConfig(serverCfg, configName); err != nil { return err @@ -116,13 +117,10 @@ func migrateServerConfig(configName string) error { if err = os.Remove(configPath); err != nil { return err } - err = switchServerConfig(configName) - if err != nil { - 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) - } + if err = switchServerConfig(configName); err != nil { + return fmt.Errorf("failed to set %s as active config: %w", configName, err) } + fmt.Println("Successfully migrated old config.") return nil } @@ -309,8 +307,7 @@ func LoadServerConfig() (*ServerConfig, error) { if err != nil { return nil, err } - var serverCfg ServerConfig - serverCfg = cfg.Servers[cfg.Active] + var serverCfg ServerConfig = cfg.Servers[cfg.Active] return &serverCfg, nil } diff --git a/cmd/mdmctl/get.go b/cmd/mdmctl/get.go index faed766f..01b67b46 100644 --- a/cmd/mdmctl/get.go +++ b/cmd/mdmctl/get.go @@ -103,8 +103,9 @@ Examples: # Get a device by serial (TODO implement filtering) mdmctl get devices -serials=C02ABCDEF + ` - fmt.Println(getUsage) + fmt.Print(getUsage) return nil } diff --git a/cmd/mdmctl/get_dep_profiles.go b/cmd/mdmctl/get_dep_profiles.go index ecb28080..dc4a88ae 100644 --- a/cmd/mdmctl/get_dep_profiles.go +++ b/cmd/mdmctl/get_dep_profiles.go @@ -20,10 +20,11 @@ func (out *depProfilesTableOutput) BasicFooter() { out.w.Flush() } -const noUUIDText = `The DEP API does not support listing profiles. +const noUUIDText = `The DEP API does not support listing profiles. A UUID flag must be specified. To get currently assigned profile UUIDs run mdmctl get dep-devices -serials=serial1,serial2,serial3 The output of the dep-devices response will contain the profile UUIDs. + ` func (cmd *getCommand) getDEPProfiles(args []string) error { @@ -38,7 +39,7 @@ func (cmd *getCommand) getDEPProfiles(args []string) error { } if *flUUID == "" { - fmt.Println(noUUIDText) + fmt.Printf(noUUIDText) flagset.Usage() os.Exit(1) } diff --git a/cmd/mdmctl/mdmcert.download.go b/cmd/mdmctl/mdmcert.download.go index b145035a..6b860cc2 100644 --- a/cmd/mdmctl/mdmcert.download.go +++ b/cmd/mdmctl/mdmcert.download.go @@ -72,8 +72,9 @@ Upload this file to https://identity.apple.com and download the signed certificate. Then use the 'mdmctl mdmcert upload' command to upload it, (and the above private key) into MicroMDM. + ` - fmt.Println(usageText) + fmt.Print(usageText) return nil } @@ -279,7 +280,7 @@ func sendMdmcertDownloadRequest(client *http.Client, req *http.Request) error { return err } if jsn.Result != "success" { - return fmt.Errorf("got unexpected result body: %q\n", jsn.Result) + return fmt.Errorf("got unexpected result body: %q", jsn.Result) } return nil } diff --git a/cmd/mdmctl/mdmcert.go b/cmd/mdmctl/mdmcert.go index f0ec0d23..157d41d6 100644 --- a/cmd/mdmctl/mdmcert.go +++ b/cmd/mdmctl/mdmcert.go @@ -60,8 +60,9 @@ Commands: vendor push upload + ` - fmt.Println(usageText) + fmt.Print(usageText) return nil } diff --git a/cmd/mdmctl/remove.go b/cmd/mdmctl/remove.go index 3aa1efc7..68597b10 100644 --- a/cmd/mdmctl/remove.go +++ b/cmd/mdmctl/remove.go @@ -69,8 +69,9 @@ Valid resource types: * profiles * block * dep-autoassigner + ` - fmt.Println(getUsage) + fmt.Print(getUsage) return nil }