Skip to content

Commit

Permalink
KUBESAW-43: Replace the special ToolchainClusterCondition with the st…
Browse files Browse the repository at this point in the history
…andard toolchain Condition (#38)

* KUBESAW-43: Replace the special ToolchainClusterCondition with the standard toolchain Condition

Signed-off-by: Feny Mehta <[email protected]>

* updating the dependency of api, tc with latest changes

Signed-off-by: Feny Mehta <[email protected]>

* api,tc update

Signed-off-by: Feny Mehta <[email protected]>

* Removing the duplicate conditiontype, api,tc update

Signed-off-by: Feny Mehta <[email protected]>

* replacing with condition istrue

Signed-off-by: Feny Mehta <[email protected]>

* Final Update tc, api

Signed-off-by: Feny Mehta <[email protected]>

---------

Signed-off-by: Feny Mehta <[email protected]>
  • Loading branch information
fbm3307 authored May 31, 2024
1 parent e28420e commit 6abef3e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 36 deletions.
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/kubesaw/ksctl
go 1.20

require (
github.com/codeready-toolchain/api v0.0.0-20240322110702-5ab3840476e9
github.com/codeready-toolchain/toolchain-common v0.0.0-20240417084737-d3c148491687
github.com/codeready-toolchain/api v0.0.0-20240530120602-c11598ccffb7
github.com/codeready-toolchain/toolchain-common v0.0.0-20240530121312-98aad712838f
github.com/ghodss/yaml v1.0.0
github.com/mitchellh/go-homedir v1.1.0
// using latest commit from 'github.com/openshift/api branch release-4.12'
Expand Down Expand Up @@ -64,7 +64,6 @@ require (
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/gofrs/uuid v3.3.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
Expand Down Expand Up @@ -122,7 +121,7 @@ require (
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
Expand Down
14 changes: 6 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:z
github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo=
github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA=
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
github.com/codeready-toolchain/api v0.0.0-20240322110702-5ab3840476e9 h1:Lm7bFLrzfJzrUiRGVqtsSaZMpj+akLiR/fvAFjjE9gM=
github.com/codeready-toolchain/api v0.0.0-20240322110702-5ab3840476e9/go.mod h1:cfNN6YPX4TORvhhZXMSjSPesqAHlB3nD/WAfGe4WLKQ=
github.com/codeready-toolchain/toolchain-common v0.0.0-20240417084737-d3c148491687 h1:ZPURdFfMNOsEyNKtCTzY9Gsj0jKQL13tR/uj7OAlZL4=
github.com/codeready-toolchain/toolchain-common v0.0.0-20240417084737-d3c148491687/go.mod h1:Iat3N+zBZcVgm/HWxa/ltSEoelM/YCXQUvbL9C8OSTw=
github.com/codeready-toolchain/api v0.0.0-20240530120602-c11598ccffb7 h1:o5JLcHCVS1BlZevw2mh1mH+iKwn9fLUrT1Ek8NFjvPY=
github.com/codeready-toolchain/api v0.0.0-20240530120602-c11598ccffb7/go.mod h1:ie9p4LenCCS0LsnbWp6/xwpFDdCWYE0KWzUO6Sk1g0E=
github.com/codeready-toolchain/toolchain-common v0.0.0-20240530121312-98aad712838f h1:2qfRfyh7wfEnnfxrUtQeQrvhzWlkBCN0B/UXv1YUMiA=
github.com/codeready-toolchain/toolchain-common v0.0.0-20240530121312-98aad712838f/go.mod h1:cyHrUfvBYEtsf+FbqQYmR9y0AQi9QAVtM3SUWLA5bd4=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
Expand Down Expand Up @@ -252,8 +252,6 @@ github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg78
github.com/gobuffalo/flect v0.2.3/go.mod h1:vmkQwuZYhN5Pc4ljYQZzP+1sq+NEkK+lh20jmEmX3jc=
github.com/goccy/go-yaml v1.8.1/go.mod h1:wS4gNoLalDSJxo/SpngzPQ2BN4uuZVLCmbM4S3vd4+Y=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84=
github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
Expand Down Expand Up @@ -839,8 +837,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down
10 changes: 2 additions & 8 deletions pkg/cmd/adm/register_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (

toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
"github.com/codeready-toolchain/toolchain-common/pkg/cluster"
"github.com/codeready-toolchain/toolchain-common/pkg/condition"
"github.com/kubesaw/ksctl/pkg/client"
"github.com/kubesaw/ksctl/pkg/configuration"
clicontext "github.com/kubesaw/ksctl/pkg/context"
"github.com/kubesaw/ksctl/pkg/ioutils"
"github.com/kubesaw/ksctl/pkg/utils"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/rest"
Expand Down Expand Up @@ -190,13 +190,7 @@ func waitUntilToolchainClusterReady(ctx *clicontext.CommandContext, cl runtimecl
return false, err
}

// TODO: replace with condition.IsTrue() once the ToolchainClusterCondition is replaced by the generic one.
for _, cond := range tc.Status.Conditions {
if cond.Type == toolchainv1alpha1.ToolchainClusterReady && cond.Status == corev1.ConditionTrue {
return true, nil
}
}
return false, nil
return condition.IsTrue(tc.Status.Conditions, toolchainv1alpha1.ConditionReady), nil
})
}

Expand Down
32 changes: 16 additions & 16 deletions pkg/cmd/adm/register_member_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ func TestRegisterMember(t *testing.T) {
APIEndpoint: "https://cool-server.com",
},
Status: toolchainv1alpha1.ToolchainClusterStatus{
Conditions: []toolchainv1alpha1.ToolchainClusterCondition{
Conditions: []toolchainv1alpha1.Condition{
{
Type: toolchainv1alpha1.ToolchainClusterReady,
Type: toolchainv1alpha1.ConditionReady,
Status: status,
},
},
Expand All @@ -132,9 +132,9 @@ func TestRegisterMember(t *testing.T) {
APIEndpoint: "https://cool-server.com",
},
Status: toolchainv1alpha1.ToolchainClusterStatus{
Conditions: []toolchainv1alpha1.ToolchainClusterCondition{
Conditions: []toolchainv1alpha1.Condition{
{
Type: toolchainv1alpha1.ToolchainClusterReady,
Type: toolchainv1alpha1.ConditionReady,
Status: status,
},
},
Expand Down Expand Up @@ -302,9 +302,9 @@ func TestRegisterMember(t *testing.T) {
APIEndpoint: "https://cool-server.com",
},
Status: toolchainv1alpha1.ToolchainClusterStatus{
Conditions: []toolchainv1alpha1.ToolchainClusterCondition{
Conditions: []toolchainv1alpha1.Condition{
{
Type: toolchainv1alpha1.ToolchainClusterReady,
Type: toolchainv1alpha1.ConditionReady,
Status: corev1.ConditionTrue,
},
},
Expand Down Expand Up @@ -426,9 +426,9 @@ func TestRegisterMember(t *testing.T) {
APIEndpoint: "https://not-so-cool-server.com",
},
Status: toolchainv1alpha1.ToolchainClusterStatus{
Conditions: []toolchainv1alpha1.ToolchainClusterCondition{
Conditions: []toolchainv1alpha1.Condition{
{
Type: toolchainv1alpha1.ToolchainClusterReady,
Type: toolchainv1alpha1.ConditionReady,
Status: corev1.ConditionTrue,
},
},
Expand All @@ -443,9 +443,9 @@ func TestRegisterMember(t *testing.T) {
APIEndpoint: "https://uncool-server.com",
},
Status: toolchainv1alpha1.ToolchainClusterStatus{
Conditions: []toolchainv1alpha1.ToolchainClusterCondition{
Conditions: []toolchainv1alpha1.Condition{
{
Type: toolchainv1alpha1.ToolchainClusterReady,
Type: toolchainv1alpha1.ConditionReady,
Status: corev1.ConditionTrue,
},
},
Expand Down Expand Up @@ -488,9 +488,9 @@ func TestRegisterMember(t *testing.T) {
APIEndpoint: "https://not-so-cool-server.com",
},
Status: toolchainv1alpha1.ToolchainClusterStatus{
Conditions: []toolchainv1alpha1.ToolchainClusterCondition{
Conditions: []toolchainv1alpha1.Condition{
{
Type: toolchainv1alpha1.ToolchainClusterReady,
Type: toolchainv1alpha1.ConditionReady,
Status: corev1.ConditionTrue,
},
},
Expand Down Expand Up @@ -532,9 +532,9 @@ func TestRegisterMember(t *testing.T) {
APIEndpoint: "https://cool-server.com",
},
Status: toolchainv1alpha1.ToolchainClusterStatus{
Conditions: []toolchainv1alpha1.ToolchainClusterCondition{
Conditions: []toolchainv1alpha1.Condition{
{
Type: toolchainv1alpha1.ToolchainClusterReady,
Type: toolchainv1alpha1.ConditionReady,
Status: corev1.ConditionTrue,
},
},
Expand Down Expand Up @@ -579,9 +579,9 @@ func TestRegisterMember(t *testing.T) {
APIEndpoint: "https://cool-server.com",
},
Status: toolchainv1alpha1.ToolchainClusterStatus{
Conditions: []toolchainv1alpha1.ToolchainClusterCondition{
Conditions: []toolchainv1alpha1.Condition{
{
Type: toolchainv1alpha1.ToolchainClusterReady,
Type: toolchainv1alpha1.ConditionReady,
Status: corev1.ConditionTrue,
},
},
Expand Down

0 comments on commit 6abef3e

Please sign in to comment.