1
0
mirror of https://github.com/openshift/source-to-image.git synced 2026-02-05 12:44:54 +01:00

fix(deps): update module github.com/go-imports-organizer/goio to v1.5.0

Signed-off-by: red-hat-konflux <126015336+red-hat-konflux[bot]@users.noreply.github.com>
This commit is contained in:
red-hat-konflux[bot]
2025-02-23 12:52:14 +00:00
committed by GitHub
parent fc4f542998
commit a62620dd1d
11 changed files with 128 additions and 41 deletions

4
go.mod
View File

@@ -7,7 +7,7 @@ require (
github.com/distribution/reference v0.6.0
github.com/docker/docker v27.3.1+incompatible
github.com/docker/go-connections v0.5.0
github.com/go-imports-organizer/goio v1.3.3
github.com/go-imports-organizer/goio v1.5.0
github.com/moby/buildkit v0.16.0
github.com/opencontainers/image-spec v1.1.0
github.com/spf13/cobra v1.8.1
@@ -76,7 +76,7 @@ require (
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.29.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect

8
go.sum
View File

@@ -73,8 +73,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/go-imports-organizer/goio v1.3.3 h1:JNhCzgh8ti8YvzQ3R6JwAjM+0c3rKrpndcxbJ6OOSmM=
github.com/go-imports-organizer/goio v1.3.3/go.mod h1:CgKd4H6yUHNGhSdxNou67Zi3SIjE7mwDTApEwRnC4jg=
github.com/go-imports-organizer/goio v1.5.0 h1:1dd8nLdvOkx3yRYyZpwEaUsHxz94xiOclelWgckSWM0=
github.com/go-imports-organizer/goio v1.5.0/go.mod h1:dlehECfRN4ahArk7MFpkjpPPWKXILwIQ9ZZT6ScDfQo=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
@@ -245,8 +245,8 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=

View File

@@ -1,3 +0,0 @@
go 1.19
use .

View File

@@ -35,9 +35,11 @@ import (
)
var (
wg sync.WaitGroup
files = make(chan string)
pathList v1alpha1.PathListFlags
wg sync.WaitGroup
files = make(chan string)
resultsChan = make(chan string)
hasResults = false
pathList v1alpha1.PathListFlags
)
func main() {
@@ -100,9 +102,21 @@ func main() {
// Build the Regular Expressions and DisplayOrder for the group definitions
groupRegExpMatchers, displayOrder := groups.Build(conf.Groups, goModuleName)
// Read results from the resultsChan and write them to stdout
go func() {
for {
r := <-resultsChan
if len(r) != 0 {
fmt.Fprintf(os.Stdout, "%s\n", r)
}
}
}()
// Add one (1) to the WaitGroup so that we can know when the Formatting in completed
wg.Add(1)
// Start up the Format worker so that it is ready when we start queuing up files
go imports.Format(&files, &wg, groupRegExpMatchers, displayOrder, listOnly)
go imports.Format(&files, &resultsChan, &hasResults, &wg, groupRegExpMatchers, displayOrder, listOnly)
// Set the basePath for use later
basePath := goModulePath + "/"
@@ -179,6 +193,9 @@ func main() {
// Wait for all files to be processed
wg.Wait()
// Close the resultsChan as all formatting should be completed
close(resultsChan)
// set MEMPROFILE=<filename> to create a <filename>.pprof memory profile file
if len(os.Getenv("MEMPROFILE")) != 0 {
fmt.Fprintf(os.Stdout, "Logging MEMORY profiling information to %s\n", os.Getenv(("MEMPROFILE")))
@@ -194,6 +211,9 @@ func main() {
os.Exit(1)
}
}
if *listOnly && hasResults {
os.Exit(1)
}
}
func findFile(path, fileName string) (string, bool, error) {

View File

@@ -137,7 +137,7 @@ func InsertGroups(f *ast.File, importGroups map[string][]ast.ImportSpec, display
}
// Format processes files as they are added to the queue and organizes the imports
func Format(files *chan string, wg *sync.WaitGroup, groupRegExpMatchers []v1alpha1.RegExpMatcher, displayOrder []string, listOnly *bool) {
func Format(files *chan string, resultsChan *chan string, hasResults *bool, wg *sync.WaitGroup, groupRegExpMatchers []v1alpha1.RegExpMatcher, displayOrder []string, listOnly *bool) {
defer wg.Done()
for path := range *files {
if len(path) == 0 {
@@ -195,17 +195,17 @@ func Format(files *chan string, wg *sync.WaitGroup, groupRegExpMatchers []v1alph
fmt.Fprintf(os.Stderr, "unable to format source %q, %s", path, err.Error())
}
if *listOnly {
oldFile, err := os.ReadFile(path)
if err != nil {
fmt.Fprintf(os.Stderr, "unable to read file %q: %s", path, err.Error())
continue
}
if !bytes.Equal(oldFile, out) {
fmt.Fprintf(os.Stdout, "%s is not organized \n", path)
}
oldFile, err := os.ReadFile(path)
if err != nil {
fmt.Fprintf(os.Stderr, "unable to read file %q: %s", path, err.Error())
continue
}
if !bytes.Equal(oldFile, out) {
*hasResults = true
*resultsChan <- path
}
} else {
if !*listOnly {
info, err = os.Stat(path)
if err != nil {
fmt.Fprintf(os.Stderr, "unable to stat %q: %s", path, err.Error())
@@ -217,6 +217,7 @@ func Format(files *chan string, wg *sync.WaitGroup, groupRegExpMatchers []v1alph
}
if err = os.WriteFile(path, out, info.Mode()); err != nil {
fmt.Fprintf(os.Stderr, "unable to write to path %q, %s", path, err.Error())
continue
}
}

4
vendor/golang.org/x/mod/LICENSE generated vendored
View File

@@ -1,4 +1,4 @@
Copyright (c) 2009 The Go Authors. All rights reserved.
Copyright 2009 The Go Authors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer.
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

View File

@@ -226,8 +226,9 @@ func (x *FileSyntax) Cleanup() {
continue
}
if ww == 1 && len(stmt.RParen.Comments.Before) == 0 {
// Collapse block into single line.
line := &Line{
// Collapse block into single line but keep the Line reference used by the
// parsed File structure.
*stmt.Line[0] = Line{
Comments: Comments{
Before: commentsAdd(stmt.Before, stmt.Line[0].Before),
Suffix: commentsAdd(stmt.Line[0].Suffix, stmt.Suffix),
@@ -235,7 +236,7 @@ func (x *FileSyntax) Cleanup() {
},
Token: stringsAdd(stmt.Token, stmt.Line[0].Token),
}
x.Stmt[w] = line
x.Stmt[w] = stmt.Line[0]
w++
continue
}

View File

@@ -43,6 +43,7 @@ type File struct {
Exclude []*Exclude
Replace []*Replace
Retract []*Retract
Tool []*Tool
Syntax *FileSyntax
}
@@ -93,6 +94,12 @@ type Retract struct {
Syntax *Line
}
// A Tool is a single tool statement.
type Tool struct {
Path string
Syntax *Line
}
// A VersionInterval represents a range of versions with upper and lower bounds.
// Intervals are closed: both bounds are included. When Low is equal to High,
// the interval may refer to a single version ('v1.2.3') or an interval
@@ -297,7 +304,7 @@ func parseToFile(file string, data []byte, fix VersionFixer, strict bool) (parse
})
}
continue
case "module", "godebug", "require", "exclude", "replace", "retract":
case "module", "godebug", "require", "exclude", "replace", "retract", "tool":
for _, l := range x.Line {
f.add(&errs, x, l, x.Token[0], l.Token, fix, strict)
}
@@ -509,6 +516,21 @@ func (f *File) add(errs *ErrorList, block *LineBlock, line *Line, verb string, a
Syntax: line,
}
f.Retract = append(f.Retract, retract)
case "tool":
if len(args) != 1 {
errorf("tool directive expects exactly one argument")
return
}
s, err := parseString(&args[0])
if err != nil {
errorf("invalid quoted string: %v", err)
return
}
f.Tool = append(f.Tool, &Tool{
Path: s,
Syntax: line,
})
}
}
@@ -1567,6 +1589,36 @@ func (f *File) DropRetract(vi VersionInterval) error {
return nil
}
// AddTool adds a new tool directive with the given path.
// It does nothing if the tool line already exists.
func (f *File) AddTool(path string) error {
for _, t := range f.Tool {
if t.Path == path {
return nil
}
}
f.Tool = append(f.Tool, &Tool{
Path: path,
Syntax: f.Syntax.addLine(nil, "tool", path),
})
f.SortBlocks()
return nil
}
// RemoveTool removes a tool directive with the given path.
// It does nothing if no such tool directive exists.
func (f *File) DropTool(path string) error {
for _, t := range f.Tool {
if t.Path == path {
t.Syntax.markRemoved()
*t = Tool{}
}
}
return nil
}
func (f *File) SortBlocks() {
f.removeDups() // otherwise sorting is unsafe
@@ -1593,9 +1645,9 @@ func (f *File) SortBlocks() {
}
}
// removeDups removes duplicate exclude and replace directives.
// removeDups removes duplicate exclude, replace and tool directives.
//
// Earlier exclude directives take priority.
// Earlier exclude and tool directives take priority.
//
// Later replace directives take priority.
//
@@ -1605,10 +1657,10 @@ func (f *File) SortBlocks() {
// retract directives are not de-duplicated since comments are
// meaningful, and versions may be retracted multiple times.
func (f *File) removeDups() {
removeDups(f.Syntax, &f.Exclude, &f.Replace)
removeDups(f.Syntax, &f.Exclude, &f.Replace, &f.Tool)
}
func removeDups(syntax *FileSyntax, exclude *[]*Exclude, replace *[]*Replace) {
func removeDups(syntax *FileSyntax, exclude *[]*Exclude, replace *[]*Replace, tool *[]*Tool) {
kill := make(map[*Line]bool)
// Remove duplicate excludes.
@@ -1649,6 +1701,24 @@ func removeDups(syntax *FileSyntax, exclude *[]*Exclude, replace *[]*Replace) {
}
*replace = repl
if tool != nil {
haveTool := make(map[string]bool)
for _, t := range *tool {
if haveTool[t.Path] {
kill[t.Syntax] = true
continue
}
haveTool[t.Path] = true
}
var newTool []*Tool
for _, t := range *tool {
if !kill[t.Syntax] {
newTool = append(newTool, t)
}
}
*tool = newTool
}
// Duplicate require and retract directives are not removed.
// Drop killed statements from the syntax tree.

View File

@@ -331,5 +331,5 @@ func (f *WorkFile) SortBlocks() {
// retract directives are not de-duplicated since comments are
// meaningful, and versions may be retracted multiple times.
func (f *WorkFile) removeDups() {
removeDups(f.Syntax, nil, &f.Replace)
removeDups(f.Syntax, nil, &f.Replace, nil)
}

View File

@@ -506,7 +506,6 @@ var badWindowsNames = []string{
"PRN",
"AUX",
"NUL",
"COM0",
"COM1",
"COM2",
"COM3",
@@ -516,7 +515,6 @@ var badWindowsNames = []string{
"COM7",
"COM8",
"COM9",
"LPT0",
"LPT1",
"LPT2",
"LPT3",

8
vendor/modules.txt vendored
View File

@@ -220,8 +220,8 @@ github.com/docker/go-units
# github.com/felixge/httpsnoop v1.0.4
## explicit; go 1.13
github.com/felixge/httpsnoop
# github.com/go-imports-organizer/goio v1.3.3
## explicit; go 1.19
# github.com/go-imports-organizer/goio v1.5.0
## explicit; go 1.22.0
github.com/go-imports-organizer/goio
github.com/go-imports-organizer/goio/pkg/api/v1alpha1
github.com/go-imports-organizer/goio/pkg/config
@@ -405,8 +405,8 @@ go.opentelemetry.io/otel/trace/embedded
# golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
## explicit; go 1.20
golang.org/x/exp/maps
# golang.org/x/mod v0.18.0
## explicit; go 1.18
# golang.org/x/mod v0.21.0
## explicit; go 1.22.0
golang.org/x/mod/internal/lazyregexp
golang.org/x/mod/modfile
golang.org/x/mod/module