Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/chart-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:

- name: Install plugin unittest
run: |
helm plugin install https://github.com/helm-unittest/helm-unittest
helm plugin install https://github.com/helm-unittest/helm-unittest --version 1.0.3

# Python is required because `ct lint` runs Yamale (https://github.com/23andMe/Yamale) and
# yamllint (https://github.com/adrienverge/yamllint) which require Python
Expand Down
16 changes: 14 additions & 2 deletions api/v1alpha1/streamnativecloudconnection_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ import (
// StreamNativeCloudConnectionSpec defines the desired state of StreamNativeCloudConnection
type StreamNativeCloudConnectionSpec struct {
// Server is the URL of the API server
// +required
Server string `json:"server"`
// +kubebuilder:default="https://api.streamnative.cloud"
// +optional
Server string `json:"server,omitempty"`

// Auth defines the authentication configuration
// +required
Expand All @@ -42,6 +43,17 @@ type StreamNativeCloudConnectionSpec struct {
Organization string `json:"organization,omitempty"`
}

// DefaultStreamNativeCloudServer is the default API server URL
const DefaultStreamNativeCloudServer = "https://api.streamnative.cloud"

// GetServer returns the server URL, using the default if not specified
func (s *StreamNativeCloudConnectionSpec) GetServer() string {
if s.Server == "" {
return DefaultStreamNativeCloudServer
}
return s.Server
}
Comment on lines +49 to +55
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

The GetServer method implements default value logic that should be tested. Consider adding unit tests to verify that:

  1. GetServer returns the default URL when Server is empty
  2. GetServer returns the specified Server when it is set
    This will ensure the default value functionality works correctly.

Copilot uses AI. Check for mistakes.

// AuthConfig defines the authentication configuration
type AuthConfig struct {
// CredentialsRef is the reference to the service account credentials secret
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ spec:
If not specified, the operator will use the connection name as the organization
type: string
server:
default: https://api.streamnative.cloud
description: Server is the URL of the API server
type: string
required:
- auth
- server
type: object
status:
description: StreamNativeCloudConnectionStatus defines the observed state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ spec:
If not specified, the operator will use the connection name as the organization
type: string
server:
default: https://api.streamnative.cloud
description: Server is the URL of the API server
type: string
required:
- auth
- server
type: object
status:
description: StreamNativeCloudConnectionStatus defines the observed state
Expand Down
6 changes: 3 additions & 3 deletions pkg/streamnativecloud/api_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (c *APIConnection) connect() error {
ClientSecret: c.credentials.ClientSecret,
TokenURL: config.TokenEndpoint,
EndpointParams: url.Values{
"audience": []string{c.config.Spec.Server},
"audience": []string{c.config.Spec.GetServer()},
},
}

Expand All @@ -101,7 +101,7 @@ func (c *APIConnection) Test(ctx context.Context) error {
if c.client == nil {
return fmt.Errorf("waiting for client")
}
req, err := http.NewRequestWithContext(ctx, "GET", c.config.Spec.Server+"/healthz", http.NoBody)
req, err := http.NewRequestWithContext(ctx, "GET", c.config.Spec.GetServer()+"/healthz", http.NoBody)
if err != nil {
return err
}
Expand Down Expand Up @@ -134,7 +134,7 @@ func (c *APIConnection) NeedsUpdate(
if c.credentials == nil {
return true
}
return c.config.Spec.Server != config.Spec.Server ||
return c.config.Spec.GetServer() != config.Spec.GetServer() ||
c.credentials.ClientID != creds.ClientID ||
c.credentials.ClientSecret != creds.ClientSecret ||
c.credentials.IssuerURL != creds.IssuerURL
Expand Down