Skip to content

Commit 464202c

Browse files
Merge pull request #609 from openshift-bot/synchronize-upstream
NO-ISSUE: Synchronize From Upstream Repositories
2 parents e7e63bc + 057d3c3 commit 464202c

File tree

63 files changed

+152
-180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+152
-180
lines changed

staging/operator-lifecycle-manager/OWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ approvers:
99
- grokspawn
1010
- joelanford
1111
- tmshort
12+
- ncdc
1213
# review == this code is good /lgtm
1314
reviewers:
1415
- kevinrizza
@@ -26,3 +27,4 @@ reviewers:
2627
- dtfranz
2728
- tmshort
2829
- stevekuznetsov
30+
- ncdc

staging/operator-lifecycle-manager/pkg/controller/registry/reconciler/grpc.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strings"
88
"time"
99

10+
"github.com/google/go-cmp/cmp"
1011
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/install"
1112
"github.com/pkg/errors"
1213
"github.com/sirupsen/logrus"
@@ -202,10 +203,14 @@ func (c *GrpcRegistryReconciler) currentPodsWithCorrectImageAndSpec(logger *logr
202203
newPod := source.Pod(serviceAccount)
203204
for _, p := range pods {
204205
images, hash := correctImages(source, p), podHashMatch(p, newPod)
205-
logger.WithFields(logrus.Fields{
206+
logger = logger.WithFields(logrus.Fields{
206207
"current-pod.namespace": p.Namespace, "current-pod.name": p.Name,
207208
"correctImages": images, "correctHash": hash,
208-
}).Info("evaluating current pod")
209+
})
210+
logger.Info("evaluating current pod")
211+
if !hash {
212+
logger.Infof("pod spec diff: %s", cmp.Diff(p.Spec, newPod.Spec))
213+
}
209214
if correctImages(source, p) && podHashMatch(p, newPod) {
210215
found = append(found, p)
211216
}

staging/operator-registry/alpha/action/init.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package action
33
import (
44
"fmt"
55
"io"
6-
"io/ioutil"
76

87
"github.com/h2non/filetype"
98

@@ -25,15 +24,15 @@ func (i Init) Run() (*declcfg.Package, error) {
2524
DefaultChannel: i.DefaultChannel,
2625
}
2726
if i.DescriptionReader != nil {
28-
descriptionData, err := ioutil.ReadAll(i.DescriptionReader)
27+
descriptionData, err := io.ReadAll(i.DescriptionReader)
2928
if err != nil {
3029
return nil, fmt.Errorf("read description: %v", err)
3130
}
3231
pkg.Description = string(descriptionData)
3332
}
3433

3534
if i.IconReader != nil {
36-
iconData, err := ioutil.ReadAll(i.IconReader)
35+
iconData, err := io.ReadAll(i.IconReader)
3736
if err != nil {
3837
return nil, fmt.Errorf("read icon: %v", err)
3938
}

staging/operator-registry/alpha/action/migrate.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package action
33
import (
44
"context"
55
"fmt"
6-
"io/ioutil"
76
"os"
87

98
"github.com/operator-framework/operator-registry/alpha/declcfg"
@@ -20,7 +19,7 @@ type Migrate struct {
2019
}
2120

2221
func (m Migrate) Run(ctx context.Context) error {
23-
entries, err := ioutil.ReadDir(m.OutputDir)
22+
entries, err := os.ReadDir(m.OutputDir)
2423
if err != nil && !os.IsNotExist(err) {
2524
return err
2625
}

staging/operator-registry/alpha/action/render.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"encoding/json"
77
"errors"
88
"fmt"
9-
"io/ioutil"
9+
"io"
1010
"os"
1111
"path/filepath"
1212
"sort"
@@ -60,7 +60,7 @@ type Render struct {
6060

6161
func nullLogger() *logrus.Entry {
6262
logger := logrus.New()
63-
logger.SetOutput(ioutil.Discard)
63+
logger.SetOutput(io.Discard)
6464
return logrus.NewEntry(logger)
6565
}
6666

@@ -155,7 +155,7 @@ func (r Render) imageToDeclcfg(ctx context.Context, imageRef string) (*declcfg.D
155155
if err != nil {
156156
return nil, err
157157
}
158-
tmpDir, err := ioutil.TempDir("", "render-unpack-")
158+
tmpDir, err := os.MkdirTemp("", "render-unpack-")
159159
if err != nil {
160160
return nil, err
161161
}

staging/operator-registry/cmd/opm/alpha/bundle/unpack.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"crypto/x509"
66
"fmt"
7-
"io/ioutil"
87
"os"
98
"path/filepath"
109

@@ -99,7 +98,7 @@ func unpackBundle(cmd *cobra.Command, args []string) error {
9998
}
10099
if rootCA != "" {
101100
rootCAs := x509.NewCertPool()
102-
certs, err := ioutil.ReadFile(rootCA)
101+
certs, err := os.ReadFile(rootCA)
103102
if err != nil {
104103
return err
105104
}
@@ -129,7 +128,7 @@ func unpackBundle(cmd *cobra.Command, args []string) error {
129128
return err
130129
}
131130

132-
dir, err := ioutil.TempDir("", "bundle-")
131+
dir, err := os.MkdirTemp("", "bundle-")
133132
if err != nil {
134133
return err
135134
}

staging/operator-registry/cmd/opm/alpha/bundle/validate.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package bundle
22

33
import (
44
"fmt"
5-
"io/ioutil"
65
"os"
76
"path/filepath"
87

@@ -80,7 +79,7 @@ func validateFunc(cmd *cobra.Command, _ []string) error {
8079
}
8180
imageValidator := bundle.NewImageValidator(registry, logger, optional)
8281

83-
dir, err := ioutil.TempDir("", "bundle-")
82+
dir, err := os.MkdirTemp("", "bundle-")
8483
logger.Infof("Create a temp directory at %s", dir)
8584
if err != nil {
8685
return err

staging/operator-registry/cmd/opm/alpha/template/basic.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package template
22

33
import (
44
"io"
5-
"io/ioutil"
65
"log"
76
"os"
87

@@ -50,7 +49,7 @@ When FILE is '-' or not provided, the template is read from standard input`,
5049
// The bundle loading impl is somewhat verbose, even on the happy path,
5150
// so discard all logrus default logger logs. Any important failures will be
5251
// returned from template.Render and logged as fatal errors.
53-
logrus.SetOutput(ioutil.Discard)
52+
logrus.SetOutput(io.Discard)
5453

5554
reg, err := util.CreateCLIRegistry(cmd)
5655
if err != nil {

staging/operator-registry/cmd/opm/alpha/template/semver.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package template
33
import (
44
"fmt"
55
"io"
6-
"io/ioutil"
76
"log"
87
"os"
98

@@ -53,7 +52,7 @@ When FILE is '-' or not provided, the template is read from standard input`,
5352
// The bundle loading impl is somewhat verbose, even on the happy path,
5453
// so discard all logrus default logger logs. Any important failures will be
5554
// returned from template.Render and logged as fatal errors.
56-
logrus.SetOutput(ioutil.Discard)
55+
logrus.SetOutput(io.Discard)
5756

5857
reg, err := util.CreateCLIRegistry(cmd)
5958
if err != nil {

staging/operator-registry/cmd/opm/internal/util/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package util
22

33
import (
44
"errors"
5-
"io/ioutil"
5+
"io"
66
"os"
77

88
"github.com/operator-framework/operator-registry/pkg/image/containerdregistry"
@@ -69,6 +69,6 @@ func CreateCLIRegistry(cmd *cobra.Command) (*containerdregistry.Registry, error)
6969

7070
func nullLogger() *logrus.Entry {
7171
logger := logrus.New()
72-
logger.SetOutput(ioutil.Discard)
72+
logger.SetOutput(io.Discard)
7373
return logrus.NewEntry(logger)
7474
}

staging/operator-registry/cmd/opm/render/cmd.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package render
22

33
import (
44
"io"
5-
"io/ioutil"
65
"log"
76
"os"
87

@@ -45,7 +44,7 @@ database files.
4544
// The bundle loading impl is somewhat verbose, even on the happy path,
4645
// so discard all logrus default logger logs. Any important failures will be
4746
// returned from render.Run and logged as fatal errors.
48-
logrus.SetOutput(ioutil.Discard)
47+
logrus.SetOutput(io.Discard)
4948

5049
reg, err := util.CreateCLIRegistry(cmd)
5150
if err != nil {
@@ -72,6 +71,6 @@ database files.
7271

7372
func nullLogger() *logrus.Entry {
7473
logger := logrus.New()
75-
logger.SetOutput(ioutil.Discard)
74+
logger.SetOutput(io.Discard)
7675
return logrus.NewEntry(logger)
7776
}

staging/operator-registry/pkg/configmap/configmap_writer.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package configmap
33
import (
44
"context"
55
"fmt"
6-
"io/ioutil"
76
"os"
87
"regexp"
98

@@ -85,7 +84,7 @@ func (c *ConfigMapWriter) Populate(maxDataSizeLimit uint64) error {
8584
var totalSize uint64
8685
for _, dir := range subDirs {
8786
completePath := c.manifestsDir + dir
88-
files, err := ioutil.ReadDir(completePath)
87+
files, err := os.ReadDir(completePath)
8988
if err != nil {
9089
logrus.Errorf("read dir failed: %v", err)
9190
return err
@@ -95,7 +94,7 @@ func (c *ConfigMapWriter) Populate(maxDataSizeLimit uint64) error {
9594
log := logrus.WithField("file", completePath+file.Name())
9695
log.Info("Reading file")
9796

98-
content, err := ioutil.ReadFile(completePath + file.Name())
97+
content, err := os.ReadFile(completePath + file.Name())
9998
if err != nil {
10099
log.Errorf("read failed: %v", err)
101100
return err

staging/operator-registry/pkg/image/mock.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"errors"
66
"io/fs"
7-
"io/ioutil"
87
"os"
98
"path/filepath"
109
"sync"
@@ -40,7 +39,7 @@ func (i *MockImage) unpack(dir string) error {
4039
if err := os.MkdirAll(pathDir, 0777); err != nil {
4140
return err
4241
}
43-
return ioutil.WriteFile(path, data, 0666)
42+
return os.WriteFile(path, data, 0666)
4443
})
4544
}
4645

staging/operator-registry/pkg/image/registry_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"crypto/x509"
66
"errors"
77
"fmt"
8-
"io/ioutil"
98
"math"
109
"math/rand"
1110
"net/http"
@@ -35,7 +34,7 @@ type newRegistryFunc func(t *testing.T, cafile string) (image.Registry, cleanupF
3534

3635
func poolForCertFile(t *testing.T, file string) *x509.CertPool {
3736
rootCAs := x509.NewCertPool()
38-
certs, err := ioutil.ReadFile(file)
37+
certs, err := os.ReadFile(file)
3938
require.NoError(t, err)
4039
require.True(t, rootCAs.AppendCertsFromPEM(certs))
4140
return rootCAs

staging/operator-registry/pkg/lib/bundle/chartutil.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ limitations under the License.
1919
package bundle
2020

2121
import (
22-
"io/ioutil"
2322
"os"
2423
"path/filepath"
2524

@@ -125,7 +124,7 @@ func IsChartDir(dirName string) (bool, error) {
125124
return false, errors.Errorf("no %s exists in directory %q", ChartfileName, dirName)
126125
}
127126

128-
chartYamlContent, err := ioutil.ReadFile(chartYaml)
127+
chartYamlContent, err := os.ReadFile(chartYaml)
129128
if err != nil {
130129
return false, errors.Errorf("cannot read %s in directory %q", ChartfileName, dirName)
131130
}

staging/operator-registry/pkg/lib/bundle/exporter.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package bundle
22

33
import (
44
"context"
5-
"io/ioutil"
65
"os"
76
"path/filepath"
87

@@ -34,7 +33,7 @@ func (i *BundleExporter) Export(skipTLSVerify, plainHTTP bool) error {
3433

3534
log := logrus.WithField("img", i.image)
3635

37-
tmpDir, err := ioutil.TempDir("./", "bundle_tmp")
36+
tmpDir, err := os.MkdirTemp("./", "bundle_tmp")
3837
if err != nil {
3938
return err
4039
}

staging/operator-registry/pkg/lib/bundle/generate.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package bundle
33
import (
44
"fmt"
55
"io"
6-
"io/ioutil"
76
"os"
87
"path/filepath"
98
"strings"
@@ -180,7 +179,7 @@ func CopyYamlOutput(annotationsContent []byte, manifestDir, outputDir, workingDi
180179
}
181180

182181
// Now, generate the `metadata/` dir and write the annotations
183-
file, err := ioutil.ReadFile(filepath.Join(copyDir, MetadataDir, AnnotationsFile))
182+
file, err := os.ReadFile(filepath.Join(copyDir, MetadataDir, AnnotationsFile))
184183
if os.IsNotExist(err) || overwrite {
185184
writeDir := filepath.Join(copyDir, MetadataDir)
186185
err = WriteFile(AnnotationsFile, writeDir, annotationsContent)
@@ -209,7 +208,7 @@ func GetMediaType(directory string) (string, error) {
209208
k8sFiles := make(map[string]*unstructured.Unstructured)
210209

211210
// Read all file names in directory
212-
items, _ := ioutil.ReadDir(directory)
211+
items, _ := os.ReadDir(directory)
213212
for _, item := range items {
214213
if item.IsDir() {
215214
continue
@@ -218,7 +217,7 @@ func GetMediaType(directory string) (string, error) {
218217
files = append(files, item.Name())
219218

220219
fileWithPath := filepath.Join(directory, item.Name())
221-
fileBlob, err := ioutil.ReadFile(fileWithPath)
220+
fileBlob, err := os.ReadFile(fileWithPath)
222221
if err != nil {
223222
return "", fmt.Errorf("Unable to read file %s in bundle", fileWithPath)
224223
}
@@ -367,7 +366,7 @@ func WriteFile(fileName, directory string, content []byte) error {
367366
}
368367
}
369368
log.Infof("Writing %s in %s", fileName, directory)
370-
err := ioutil.WriteFile(filepath.Join(directory, fileName), content, DefaultPermission)
369+
err := os.WriteFile(filepath.Join(directory, fileName), content, DefaultPermission)
371370
if err != nil {
372371
return err
373372
}
@@ -376,7 +375,7 @@ func WriteFile(fileName, directory string, content []byte) error {
376375

377376
// copy the contents of a potentially nested manifest dir into an output dir.
378377
func copyManifestDir(from, to string, overwrite bool) error {
379-
fromFiles, err := ioutil.ReadDir(from)
378+
fromFiles, err := os.ReadDir(from)
380379
if err != nil {
381380
return err
382381
}
@@ -431,7 +430,11 @@ func copyManifestDir(from, to string, overwrite bool) error {
431430
return err
432431
}
433432

434-
err = os.Chmod(toFilePath, fromFile.Mode())
433+
info, err := fromFile.Info()
434+
if err != nil {
435+
return err
436+
}
437+
err = os.Chmod(toFilePath, info.Mode())
435438
if err != nil {
436439
return err
437440
}

0 commit comments

Comments
 (0)