Skip to content

Commit 78dbc63

Browse files
caxu-rhacornett21
authored andcommitted
cmd: remove dependency on gobuffalo/envy
We aren't using any of the more sophisticated features of this library. For our purposes, the os GetEnv/LookupEnv functions are enough. Signed-off-by: Caleb Xu <caxu@redhat.com>
1 parent 61efbd6 commit 78dbc63

5 files changed

Lines changed: 14 additions & 32 deletions

File tree

cmd/checkhealth.go

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ package cmd
66
import (
77
"context"
88
"log"
9+
"os"
910
"strconv"
1011
"time"
1112

12-
"github.com/gobuffalo/envy"
1313
osconfigv1 "github.com/openshift/api/config/v1"
1414
"github.com/spf13/cobra"
1515
"k8s.io/apimachinery/pkg/runtime"
@@ -34,6 +34,7 @@ Progrssing status is not true.'`,
3434
var (
3535
kclient *kubernetes.Clientset
3636
oclient ctrlrtc.Client
37+
timeout int
3738
)
3839

3940
func init() {
@@ -56,17 +57,20 @@ func checkhealthPreRun(cmd *cobra.Command, args []string) {
5657
if err != nil {
5758
log.Fatalf("Error getting OpenShift config client: %s", err)
5859
}
60+
61+
if val, found := os.LookupEnv("OPERATOR_HEALTH_TIMEOUT"); found {
62+
timeout, err = strconv.Atoi(val)
63+
if err != nil {
64+
log.Fatalf("Error converting OPERATOR_HEALTH_TIMEOUT envvar to int: %s", err)
65+
}
66+
} else {
67+
timeout = 10
68+
}
5969
}
6070

6171
func checkhealthRun(cmd *cobra.Command, args []string) {
6272
checkreadyz()
6373

64-
oht := envy.Get("OPERATOR_HEALTH_TIMEOUT", "10")
65-
timeout, err := strconv.Atoi(oht)
66-
if err != nil {
67-
log.Fatalf("Error converting OPERATOR_HEALTH_TIMEOUT envvar to int: %s", err)
68-
}
69-
7074
for i := 0; i < timeout; i++ {
7175
var cvok bool
7276
cook := checkclusteroperators()
@@ -84,11 +88,6 @@ func checkhealthRun(cmd *cobra.Command, args []string) {
8488

8589
func checkreadyz() {
8690
var readyz []byte
87-
oht := envy.Get("OPERATOR_HEALTH_TIMEOUT", "10")
88-
timeout, err := strconv.Atoi(oht)
89-
if err != nil {
90-
log.Fatalf("Error converting OPERATOR_HEALTH_TIMEOUT envvar to int: %s", err)
91-
}
9291

9392
for i := 0; i < timeout; i++ {
9493
// TODO: do we want to catch this error or ignore it? Ignoring for now
@@ -126,14 +125,8 @@ func checkclusterversion() bool {
126125
}
127126

128127
func checkclusteroperators() bool {
129-
oht := envy.Get("OPERATOR_HEALTH_TIMEOUT", "10")
130-
_, err := strconv.Atoi(oht)
131-
if err != nil {
132-
log.Fatalf("Error converting OPERATOR_HEALTH_TIMEOUT envvar to int: %s", err)
133-
}
134-
135128
col := osconfigv1.ClusterOperatorList{}
136-
err = oclient.List(context.Background(), &col)
129+
err := oclient.List(context.Background(), &col)
137130
if err != nil {
138131
log.Fatalf("Unable to list cluster operators: %v", err)
139132
}

cmd/decrypt.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"os"
99

1010
"github.com/ProtonMail/gopenpgp/v2/crypto"
11-
"github.com/gobuffalo/envy"
1211
"github.com/spf13/cobra"
1312
)
1413

@@ -28,7 +27,7 @@ func init() {
2827
}
2928

3029
func decryptPreRun(cmd *cobra.Command, args []string) {
31-
CommandFlags.GPGPassphrase = envy.Get("GPG_PASSPHRASE", "")
30+
CommandFlags.GPGPassphrase = os.Getenv("GPG_PASSPHRASE")
3231
}
3332

3433
func decryptRun(cmd *cobra.Command, args []string) {

cmd/encrypt.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"os"
99

1010
"github.com/ProtonMail/gopenpgp/v2/crypto"
11-
"github.com/gobuffalo/envy"
1211
"github.com/spf13/cobra"
1312
)
1413

@@ -28,7 +27,7 @@ func init() {
2827
}
2928

3029
func encryptPreRun(cmd *cobra.Command, args []string) {
31-
CommandFlags.GPGPassphrase = envy.Get("GPG_PASSPHRASE", "")
30+
CommandFlags.GPGPassphrase = os.Getenv("GPG_PASSPHRASE")
3231
if CommandFlags.GPGEncryptionPublicKey == "" || CommandFlags.GPGEncryptionPrivateKey == "" {
3332
log.Fatalf("GPG_ENCRYPTION_PUBLIC_KEY and GPG_ENCRYPTION_PRIVATE_KEY must be set")
3433
}

go.mod

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go 1.25.7
55
require (
66
github.com/ProtonMail/gopenpgp/v2 v2.9.0
77
github.com/ghodss/yaml v1.0.0
8-
github.com/gobuffalo/envy v1.10.2
98
github.com/google/go-github/v56 v56.0.0
109
github.com/onsi/ginkgo/v2 v2.28.1
1110
github.com/onsi/gomega v1.39.1
@@ -114,7 +113,6 @@ require (
114113
github.com/hashicorp/golang-lru v1.0.2 // indirect
115114
github.com/inconshreveable/mousetrap v1.1.0 // indirect
116115
github.com/jmespath/go-jmespath v0.4.0 // indirect
117-
github.com/joho/godotenv v1.4.0 // indirect
118116
github.com/josharian/intern v1.0.0 // indirect
119117
github.com/json-iterator/go v1.1.12 // indirect
120118
github.com/mailru/easyjson v0.7.7 // indirect
@@ -131,7 +129,6 @@ require (
131129
github.com/prometheus/common v0.66.1 // indirect
132130
github.com/prometheus/procfs v0.16.1 // indirect
133131
github.com/prometheus/statsd_exporter v0.22.7 // indirect
134-
github.com/rogpeppe/go-internal v1.14.1 // indirect
135132
github.com/russross/blackfriday/v2 v2.1.0 // indirect
136133
github.com/shurcooL/githubv4 v0.0.0-20210725200734-83ba7b4c9228 // indirect
137134
github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f // indirect

go.sum

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,6 @@ github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ
273273
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
274274
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
275275
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
276-
github.com/gobuffalo/envy v1.10.2 h1:EIi03p9c3yeuRCFPOKcSfajzkLb3hrRjEpHGI8I2Wo4=
277-
github.com/gobuffalo/envy v1.10.2/go.mod h1:qGAGwdvDsaEtPhfBzb3o0SfDea8ByGn9j8bKmVft9z8=
278276
github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
279277
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
280278
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
@@ -417,8 +415,6 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y
417415
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
418416
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
419417
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
420-
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
421-
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
422418
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
423419
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
424420
github.com/joshdk/go-junit v1.0.0 h1:S86cUKIdwBHWwA6xCmFlf3RTLfVXYQfvanM5Uh+K6GE=
@@ -494,7 +490,6 @@ github.com/openshift/api v0.0.0-20251015135203-5d856d3e8354 h1:o12+Pt5Db7Zc4Y/hB
494490
github.com/openshift/api v0.0.0-20251015135203-5d856d3e8354/go.mod h1:d5uzF0YN2nQQFA0jIEWzzOZ+edmo6wzlGLvx5Fhz4uY=
495491
github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI=
496492
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
497-
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
498493
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
499494
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
500495
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
@@ -538,7 +533,6 @@ github.com/prometheus/statsd_exporter v0.22.7 h1:7Pji/i2GuhK6Lu7DHrtTkFmNBCudCPT
538533
github.com/prometheus/statsd_exporter v0.22.7/go.mod h1:N/TevpjkIh9ccs6nuzY3jQn9dFqnUakOjnEuMPJJJnI=
539534
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
540535
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
541-
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
542536
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
543537
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
544538
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=

0 commit comments

Comments
 (0)