Skip to content

Commit

Permalink
*: fix staticcheck warnings
Browse files Browse the repository at this point in the history
Fixes part of coreos#1121
  • Loading branch information
sohankunkerkar committed Dec 7, 2020
1 parent e3b3888 commit a47976a
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion config/merge/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package merge

import (
Expand Down Expand Up @@ -213,6 +212,7 @@ func MergeStructTranscribe(parent, child interface{}) (interface{}, Transcript)
// parent and child MUST be the same type
// we transcribe all leaf fields, and all intermediate structs that wholly
// originate from either parent or child
// nolint:staticcheck
func mergeStruct(parent reflect.Value, parentPath path.ContextPath, child reflect.Value, childPath path.ContextPath, resultPath path.ContextPath, transcript *Transcript) reflect.Value {
// use New() so it's settable, addr-able, etc
result := reflect.New(parent.Type()).Elem()
Expand Down
2 changes: 0 additions & 2 deletions internal/exec/stages/disks/disks.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ func (creator) Name() string {

type stage struct {
util.Util

client *resource.HttpClient
}

func (stage) Name() string {
Expand Down
4 changes: 2 additions & 2 deletions internal/exec/stages/disks/partitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ func partitionMatchesCommon(existing util.PartitionInfo, spec sgdisk.Partition)
if spec.StartSector != nil && *spec.StartSector != existing.StartSector {
return fmt.Errorf("starting sector did not match (specified %d, got %d)", *spec.StartSector, existing.StartSector)
}
if spec.GUID != nil && *spec.GUID != "" && strings.ToLower(*spec.GUID) != strings.ToLower(existing.GUID) {
if spec.GUID != nil && *spec.GUID != "" && !strings.EqualFold(*spec.GUID, existing.GUID) {
return fmt.Errorf("GUID did not match (specified %q, got %q)", *spec.GUID, existing.GUID)
}
if spec.TypeGUID != nil && *spec.TypeGUID != "" && strings.ToLower(*spec.TypeGUID) != strings.ToLower(existing.TypeGUID) {
if spec.TypeGUID != nil && *spec.TypeGUID != "" && !strings.EqualFold(*spec.TypeGUID, existing.TypeGUID) {
return fmt.Errorf("type GUID did not match (specified %q, got %q)", *spec.TypeGUID, existing.TypeGUID)
}
if spec.Label != nil && *spec.Label != existing.Label {
Expand Down
2 changes: 1 addition & 1 deletion internal/exec/util/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (u Util) PerformFetch(f FetchOp) error {
}
defer targetFile.Close()

if _, err = tmp.Seek(0, os.SEEK_SET); err != nil {
if _, err = tmp.Seek(0, io.SeekStart); err != nil {
return err
}
if _, err = io.Copy(targetFile, tmp); err != nil {
Expand Down
3 changes: 1 addition & 2 deletions internal/resource/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,7 @@ func (f *Fetcher) fetchFromS3(u url.URL, dest s3target, opts FetchOptions) error
}
if opts.Hash != nil {
opts.Hash.Reset()
_, err = dest.Seek(0, os.SEEK_SET)
if err != nil {
if _, err = dest.Seek(0, io.SeekStart); err != nil {
return err
}
_, err = io.Copy(opts.Hash, dest)
Expand Down
10 changes: 7 additions & 3 deletions internal/util/tools/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ const (
type sectionState int

const (
notInSection sectionState = 0
expectingSection = 1
inSection = 2
notInSection sectionState = iota
expectingSection
inSection
)

func main() {
Expand All @@ -62,6 +62,10 @@ func main() {
}

if err := filepath.Walk(flags.root, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}

if !strings.HasSuffix(info.Name(), ".md") || info.IsDir() {
return nil
}
Expand Down
4 changes: 3 additions & 1 deletion tests/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,19 @@ func umountPartition(p *types.Partition) error {
}

// returns true if no error, false if error
// nolint:staticcheck
func runIgnition(t *testing.T, ctx context.Context, stage, root, cwd string, appendEnv []string) error {
args := []string{"-platform", "file", "-stage", stage,
"-root", root, "-log-to-stdout", "--config-cache", filepath.Join(cwd, "ignition.json")}
cmd := exec.CommandContext(ctx, "ignition", args...)
t.Log("ignition", args)
cmd.Dir = cwd
cmd.Env = append(os.Environ(), appendEnv...)
out, err := cmd.CombinedOutput()
t.Log("ignition", args)
if cmd != nil && cmd.Process != nil {
t.Logf("PID: %d", cmd.Process.Pid)
}

t.Logf("Ignition output:\n%s", string(out))
if strings.Contains(string(out), "panic") {
return fmt.Errorf("ignition panicked")
Expand Down

0 comments on commit a47976a

Please sign in to comment.