Skip to content

Commit

Permalink
Merge pull request #102 from danilo-gemoli/chore/remove-ci-tools-dep
Browse files Browse the repository at this point in the history
Remove openshift/ci-tools dependency
  • Loading branch information
openshift-merge-bot[bot] committed Jul 10, 2024
2 parents 6271af3 + a7b9cec commit 608a3c0
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 249 deletions.
28 changes: 28 additions & 0 deletions cmd/jira-lifecycle-plugin/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package main

import (
"bytes"
"compress/gzip"
"fmt"
"io"
"os"

"k8s.io/apimachinery/pkg/util/sets"
)
Expand Down Expand Up @@ -401,3 +405,27 @@ func (b *Config) OptionsForRepo(org, repo string) map[string]JiraBranchOptions {

return options
}

// ReadFileMaybeGZIP wraps util.ReadBytesMaybeGZIP, returning the decompressed contents
// if the file is gzipped, or otherwise the raw contents
func ReadFileMaybeGZIP(path string) ([]byte, error) {
b, err := os.ReadFile(path)
if err != nil {
return nil, err
}
return ReadBytesMaybeGZIP(b)
}

func ReadBytesMaybeGZIP(data []byte) ([]byte, error) {
// check if data contains gzip header: http://www.zlib.org/rfc-gzip.html
if !bytes.HasPrefix(data, []byte("\x1F\x8B")) {
// go ahead and return the contents if not gzipped
return data, nil
}
// otherwise decode
gzipReader, err := gzip.NewReader(bytes.NewBuffer(data))
if err != nil {
return nil, err
}
return io.ReadAll(gzipReader)
}
8 changes: 3 additions & 5 deletions cmd/jira-lifecycle-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
"sigs.k8s.io/prow/prow/logrusutil"
"sigs.k8s.io/prow/prow/pjutil"
"sigs.k8s.io/yaml"

"github.com/openshift/ci-tools/pkg/util/gzip"
)

type options struct {
Expand Down Expand Up @@ -73,7 +71,7 @@ func (o *options) Validate() error {
return err
}

bytes, err := gzip.ReadFileMaybeGZIP(o.configPath)
bytes, err := ReadFileMaybeGZIP(o.configPath)
if err != nil {
return fmt.Errorf("couldn't read configuration file: %v", o.configPath)
}
Expand All @@ -97,7 +95,7 @@ func (o *options) getConfigWatchAndUpdate() (func(ctx context.Context), error) {
}

eventFunc := func() error {
bytes, err := gzip.ReadFileMaybeGZIP(o.configPath)
bytes, err := ReadFileMaybeGZIP(o.configPath)
if err != nil {
return fmt.Errorf("couldn't read configuration file %s: %w", o.configPath, err)
}
Expand Down Expand Up @@ -128,7 +126,7 @@ func main() {

o := gatherOptions()
if o.validateConfig != "" {
bytes, err := gzip.ReadFileMaybeGZIP(o.validateConfig)
bytes, err := ReadFileMaybeGZIP(o.validateConfig)
if err != nil {
logger.Fatalf("couldn't read configuration file %s: %v", o.configPath, err)
}
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ require (
github.com/andygrunwald/go-jira v1.15.1
github.com/google/go-cmp v0.5.9
github.com/openshift/build-machinery-go v0.0.0-20220429084610-baff9f8d23b3
github.com/openshift/ci-tools v0.0.0-20221125132251-82b14fbc45df
github.com/shurcooL/githubv4 v0.0.0-20220520033151-0b4e3294ff00
github.com/sirupsen/logrus v1.9.0
github.com/trivago/tgo v1.0.7
Expand Down Expand Up @@ -144,7 +143,7 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.27.2 // indirect
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible // indirect
k8s.io/client-go v0.27.2 // indirect
k8s.io/component-base v0.27.2 // indirect
k8s.io/gengo v0.0.0-20221011193443-fad74ee6edd9 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,6 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/openshift/build-machinery-go v0.0.0-20220429084610-baff9f8d23b3 h1:M7ttIUk99wNgpBImKJEbE/QgmuRK+HZ4xUh8ZpH/r3Y=
github.com/openshift/build-machinery-go v0.0.0-20220429084610-baff9f8d23b3/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE=
github.com/openshift/ci-tools v0.0.0-20221125132251-82b14fbc45df h1:lFSN/EioSQ6kcVc3BVcR3ji7BeuL7bQ0ryTrfnZ1OcY=
github.com/openshift/ci-tools v0.0.0-20221125132251-82b14fbc45df/go.mod h1:+v6edduOOB6Sm9h+1sSpaM6/ConMZwRuBYF4lE+xZ/4=
github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI=
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
191 changes: 0 additions & 191 deletions vendor/github.com/openshift/ci-tools/LICENSE

This file was deleted.

45 changes: 0 additions & 45 deletions vendor/github.com/openshift/ci-tools/pkg/util/gzip/gzip.go

This file was deleted.

5 changes: 1 addition & 4 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,6 @@ github.com/openshift/build-machinery-go/make/targets/golang
github.com/openshift/build-machinery-go/make/targets/openshift
github.com/openshift/build-machinery-go/make/targets/openshift/operator
github.com/openshift/build-machinery-go/scripts
# github.com/openshift/ci-tools v0.0.0-20221125132251-82b14fbc45df
## explicit; go 1.18
github.com/openshift/ci-tools/pkg/util/gzip
# github.com/peterbourgon/diskv v2.0.1+incompatible
## explicit
github.com/peterbourgon/diskv
Expand Down Expand Up @@ -793,7 +790,7 @@ k8s.io/apimachinery/pkg/version
k8s.io/apimachinery/pkg/watch
k8s.io/apimachinery/third_party/forked/golang/json
k8s.io/apimachinery/third_party/forked/golang/reflect
# k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible => k8s.io/client-go v0.27.2
# k8s.io/client-go v0.27.2 => k8s.io/client-go v0.27.2
## explicit; go 1.20
k8s.io/client-go/applyconfigurations/admissionregistration/v1
k8s.io/client-go/applyconfigurations/admissionregistration/v1alpha1
Expand Down

0 comments on commit 608a3c0

Please sign in to comment.