-
Couldn't load subscription status.
- Fork 18
add blueray cluster support for saving the cluster information #63
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
base: main
Are you sure you want to change the base?
Conversation
| } | ||
|
|
||
| // Check if the cluster FQDN matches the blueray pattern | ||
| if regexp.MustCompile(`.+\.cloud\.ibm\.com`).MatchString(clusterFQDN) { |
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.
Do you know if we can use our internal fork?
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.
Hi @yabinma thanks for making this change. Two major pieces of feedback:
- In the new checks you added for BlueRay we do not need to use regular expressions.
- Recommended to use test libraries to simplify the test code.
|
|
||
| func (p *PulumiMySQLRunRecorder) findBluerayStackFromClusterFQDN(ctx context.Context, clusterFQDN string) *PulumiResource { | ||
| // Extract cluster name as the first part of the FQDN (before the first dot) | ||
| parts := regexp.MustCompile(`\.`).Split(clusterFQDN, 2) |
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.
Here you do not need to use regex because you just need to get the part before the dot.
| parts := regexp.MustCompile(`\.`).Split(clusterFQDN, 2) | |
| parts := strings.SplitN(clusterFQDN, ".", 2) |
|
|
||
| func (p *PulumiMySQLRunRecorder) findStackFromClusterFQDN(ctx context.Context, clusterFQDN string) *PulumiResource { | ||
| // Check if the cluster FQDN matches the Presto DB pattern | ||
| if regexp.MustCompile(`.+\.ibm\.prestodb\.dev`).MatchString(clusterFQDN) { |
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.
| if regexp.MustCompile(`.+\.ibm\.prestodb\.dev`).MatchString(clusterFQDN) { | |
| if strings.HasSuffix(clusterFQDN, ".ibm.prestodb.dev") { |
| } | ||
|
|
||
| // Check if the cluster FQDN matches the blueray pattern | ||
| if regexp.MustCompile(`.+\.cloud\.ibm\.com`).MatchString(clusterFQDN) { |
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.
| if regexp.MustCompile(`.+\.cloud\.ibm\.com`).MatchString(clusterFQDN) { | |
| if strings.HasSuffix(clusterFQDN, ".cloud.ibm.com") { |
| return nil | ||
| } | ||
|
|
||
| func (p *PulumiMySQLRunRecorder) findBluerayStackFromClusterFQDN(ctx context.Context, clusterFQDN string) *PulumiResource { |
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.
you actually do not need a context.Context here
|
|
||
| import ( | ||
| "context" | ||
| "testing" |
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.
You can import "github.com/stretchr/testify/assert" and "github.com/stretchr/testify/require" here and use assert/require libraries below. You can check client_test.go as an example.
| expectedClusterName := "xlarge-b109n-yabin-eng" | ||
|
|
||
| // Call the function | ||
| ctx := context.Background() |
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.
context can be removed from findBluerayStackFromClusterFQDN
| resource := recorder.findBluerayStackFromClusterFQDN(ctx, testFQDN) | ||
|
|
||
| // Verify resource is not nil | ||
| if resource == 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.
You can do
require.NotNil(t, resource)| } | ||
|
|
||
| // Verify the cluster FQDN | ||
| if resource.Outputs.ClusterFQDN != testFQDN { |
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.
You can do
assert.Equal(t, testFQDN, resource.Outputs.ClusterFQDN)| } | ||
|
|
||
| // Verify Created timestamp is not zero | ||
| if resource.Created.IsZero() { |
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.
you can do
assert.False(t, resource.Created.IsZero())
No description provided.