-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #274 from perfectsense/feature/cloudsql
Implement cloudsql
- Loading branch information
Showing
34 changed files
with
4,915 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
google::database-instance database-instance-example | ||
name: "gyro-db-test" | ||
|
||
settings | ||
activation-policy: "ALWAYS" | ||
availability-type: "REGIONAL" | ||
connector-enforcement: "NOT_REQUIRED" | ||
data-disk-size-gb: 20 | ||
data-disk-type: 'PD_SSD' | ||
deletion-protection-enabled: false | ||
pricing-plan: "PER_USE" | ||
storage-auto-resize: true | ||
storage-auto-resize-limit: 100 | ||
tier: "db-perf-optimized-N-2" | ||
edition: "ENTERPRISE_PLUS" | ||
|
||
data-cache-config | ||
data-cache-enabled: true | ||
end | ||
|
||
backup-configuration | ||
enabled: true | ||
start-time: "09:00" | ||
transaction-log-retention-days: 14 | ||
binary-log-enabled: true | ||
|
||
backup-retention-settings | ||
retention-unit: "COUNT" | ||
retained-backups: 15 | ||
end | ||
end | ||
|
||
user-labels: { | ||
"example": "example" | ||
} | ||
|
||
ip-configuration | ||
ipv4-enabled: true | ||
server-ca-mode: 'GOOGLE_MANAGED_INTERNAL_CA' | ||
ssl-mode: 'ALLOW_UNENCRYPTED_AND_ENCRYPTED' | ||
private-network: $(external-query google::compute-network { name: "test-db" }) | ||
|
||
authorized-networks | ||
name: "example-QA-enviroment" | ||
value: "3.131.207.174/32" | ||
end | ||
end | ||
|
||
location-preference | ||
zone: 'us-central1-c' | ||
secondary-zone: 'us-central1-b' | ||
end | ||
|
||
password-validation-policy | ||
complexity: "COMPLEXITY_DEFAULT" | ||
disallow-username-substring: true | ||
enable-password-policy: true | ||
min-length: 8 | ||
reuse-interval: 1 | ||
end | ||
end | ||
|
||
database-version: "MYSQL_8_0_31" | ||
gce-zone: "us-central1-c" | ||
secondary-gce-zone: "us-central1-b" | ||
instance-type: "CLOUD_SQL_INSTANCE" | ||
region: "us-central1" | ||
backend-type: "SECOND_GEN" | ||
|
||
scheduled-maintenance | ||
can-reschedule: true | ||
schedule-deadline-time: "2024-08-30T23:59:59.00Z" | ||
start-time: "2024-12-31T23:59:59.00Z" | ||
end | ||
end | ||
|
||
google::database-instance database-instance-example-replica | ||
name: "gyro-db-test-replica" | ||
master-instance: $(google::database-instance database-instance-example) | ||
|
||
settings | ||
edition: "ENTERPRISE_PLUS" | ||
tier: "db-perf-optimized-N-2" | ||
|
||
ip-configuration | ||
ipv4-enabled: true | ||
end | ||
|
||
location-preference | ||
zone: 'us-central1-c' | ||
secondary-zone: 'us-central1-b' | ||
end | ||
end | ||
end |
60 changes: 60 additions & 0 deletions
60
src/main/java/gyro/google/cloudsql/DatabaseInstanceFinder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2024, Brightspot. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package gyro.google.cloudsql; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.google.api.services.sqladmin.SQLAdmin; | ||
import com.google.api.services.sqladmin.model.DatabaseInstance; | ||
import gyro.core.Type; | ||
import gyro.google.GoogleFinder; | ||
|
||
/** | ||
* Query a database instance. | ||
* | ||
* .. code-block:: gyro | ||
* | ||
* database-instance: $(external-query google::database-instance {name: 'database-instance-name'}) | ||
*/ | ||
@Type("database-instance") | ||
public class DatabaseInstanceFinder extends GoogleFinder<SQLAdmin, DatabaseInstance, DatabaseInstanceResource> { | ||
|
||
private String name; | ||
|
||
/** | ||
* The name of the Database Instance. | ||
*/ | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
protected List<DatabaseInstance> findAllGoogle(SQLAdmin client) throws Exception { | ||
return client.instances().list(getProjectId()).execute().getItems(); | ||
} | ||
|
||
@Override | ||
protected List<DatabaseInstance> findGoogle(SQLAdmin client, Map<String, String> filters) throws Exception { | ||
return Collections.singletonList(client.instances().get(getProjectId(), filters.get("name")).execute()); | ||
} | ||
} |
Oops, something went wrong.