Skip to content
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

Validate private network for cloudsql is in expected format #374

Merged
Merged
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
3 changes: 2 additions & 1 deletion apis/database/v1beta1/cloudsql_instance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,12 @@ type IPConfiguration struct {

// PrivateNetwork: The resource link for the VPC network from which the
// Cloud SQL instance is accessible for private IP. For example,
// /projects/myProject/global/networks/default. This setting can be updated,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is indeed the same comment as the one gcloud API: https://cloud.google.com/sql/docs/mysql/admin-api/rest/v1beta4/instances#IpConfiguration

However, using this format (with leading /) does not work actually:

create failed: cannot create new CloudSQL instance: googleapi: Error 400: Invalid request: Project redacted-project has invalid private network name /projects/redacted-project/global/networks/default., invalid

// projects/myProject/global/networks/default. This setting can be updated,
// but it cannot be removed after it is set. The Network must have an active
// Service Networking connection peering before resolution will proceed.
// https://cloud.google.com/vpc/docs/configure-private-services-access
// +optional
// +kubebuilder:validation:Pattern=^projects\/.+
PrivateNetwork *string `json:"privateNetwork,omitempty"`

// PrivateNetworkRef sets the PrivateNetwork field by resolving the resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,12 @@ spec:
privateNetwork:
description: 'PrivateNetwork: The resource link for the
VPC network from which the Cloud SQL instance is accessible
for private IP. For example, /projects/myProject/global/networks/default.
for private IP. For example, projects/myProject/global/networks/default.
This setting can be updated, but it cannot be removed
after it is set. The Network must have an active Service
Networking connection peering before resolution will
proceed. https://cloud.google.com/vpc/docs/configure-private-services-access'
pattern: ^projects\/.+
type: string
privateNetworkRef:
description: PrivateNetworkRef sets the PrivateNetwork
Expand Down