-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat crd autodiscovery #57
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work, left few comments 🥇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Left some comments
@@ -118,7 +100,8 @@ func Test_InitIntegration_InitDefaults_CreateDefaultResources_False(t *testing.T | |||
_, err := integration.GetIntegration(f.portClient, f.stateKey) | |||
assert.Nil(t, err) | |||
|
|||
checkResourcesDoesNotExist(f, []string{"workload", "namespace", "cluster"}, []string{"workload_overview_dashboard", "availability_scorecard_dashboard"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why it changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just extracted it to the utils because we have common logic outside.
test_utils/cleanup.go
Outdated
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func CheckResourcesExist(portClient *cli.PortClient, t *testing.T, blueprints []string, pages []string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you can have a base function and call it twice, with a flag of "exists". The functions are exactly the same except assert.Nil vs assert.NotNil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, let me work it through
test_utils/cleanup.go
Outdated
func CheckResourcesDoesNotExist(portClient *cli.PortClient, t *testing.T, blueprints []string, pages []string) { | ||
for _, bp := range blueprints { | ||
_, err := blueprint.GetBlueprint(portClient, bp) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why if err != nil (means that the blueprint does not exists), it tries to delete it? Shouldn't be the opposite? The same with pages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's complicated I actually talked it out with @yairsimantov20 to understand, seems like this logic deleted the entities just in case it doesn't gets an error, but fails the test anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh just took another look on this, and yea I get what you mean. Let me fix it :)
pkg/crd/crd_test.go
Outdated
portClient: portClient, | ||
apiextensionClient: &apiExtensionsFakeClient, | ||
portConfig: &port.IntegrationAppConfig{ | ||
CRDSToDiscover: "true", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why always true
? Not worth to test it as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I will add a test to cover it as well 👍
Description
What - Added auto discovery for CRDs & XRDs into the Portal embedded in the K8s exporter
Why - In order to allow seamless integration to k8s API
How - introduced a new
discoverResourceDefinitionPattern
which automatically creates the resource mapping using a new '*' key. As well as creating the blueprint + actions out of the voxType of change