Skip to content

Conversation

@yabinma
Copy link
Member

@yabinma yabinma commented Oct 3, 2025

No description provided.

@yabinma yabinma requested a review from ethanyzhang as a code owner October 3, 2025 22:11
@yabinma yabinma requested a review from wanglinsong October 3, 2025 22:11
}

// Check if the cluster FQDN matches the blueray pattern
if regexp.MustCompile(`.+\.cloud\.ibm\.com`).MatchString(clusterFQDN) {
Copy link
Member

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?

Copy link
Collaborator

@ethanyzhang ethanyzhang left a 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:

  1. In the new checks you added for BlueRay we do not need to use regular expressions.
  2. 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)
Copy link
Collaborator

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.

Suggested change
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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 {
Copy link
Collaborator

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"
Copy link
Collaborator

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()
Copy link
Collaborator

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 {
Copy link
Collaborator

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 {
Copy link
Collaborator

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() {
Copy link
Collaborator

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())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants