Skip to content

Commit

Permalink
Automated DCL import.
Browse files Browse the repository at this point in the history
  - 4316a82be2406824f2dd01535bbbd81c2c459693 Automatic import from cloud_mmv2_dcl_20220509_1531_RC00 by DCL Team <[email protected]>

GitOrigin-RevId: 4316a82be2406824f2dd01535bbbd81c2c459693
  • Loading branch information
DCL Team authored and copybara-github committed May 9, 2022
1 parent aec774b commit cb224b3
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 53 deletions.
2 changes: 1 addition & 1 deletion python/proto/run/alpha/job.proto
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ message RunAlphaJobTemplateTemplateVolumesSecretItems {
}

message RunAlphaJobTemplateTemplateVolumesCloudSqlInstance {
repeated string connections = 1;
repeated string instances = 1;
}

message RunAlphaJobTemplateTemplateVPCAccess {
Expand Down
10 changes: 5 additions & 5 deletions python/services/run/alpha/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,17 +927,17 @@ def from_proto(self, resources):


class JobTemplateTemplateVolumesCloudSqlInstance(object):
def __init__(self, connections: list = None):
self.connections = connections
def __init__(self, instances: list = None):
self.instances = instances

@classmethod
def to_proto(self, resource):
if not resource:
return None

res = job_pb2.RunAlphaJobTemplateTemplateVolumesCloudSqlInstance()
if Primitive.to_proto(resource.connections):
res.connections.extend(Primitive.to_proto(resource.connections))
if Primitive.to_proto(resource.instances):
res.instances.extend(Primitive.to_proto(resource.instances))
return res

@classmethod
Expand All @@ -946,7 +946,7 @@ def from_proto(self, resource):
return None

return JobTemplateTemplateVolumesCloudSqlInstance(
connections=Primitive.from_proto(resource.connections),
instances=Primitive.from_proto(resource.instances),
)


Expand Down
12 changes: 6 additions & 6 deletions python/services/run/alpha/job_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ func ProtoToRunAlphaJobTemplateTemplateVolumesCloudSqlInstance(p *alphapb.RunAlp
return nil
}
obj := &alpha.JobTemplateTemplateVolumesCloudSqlInstance{}
for _, r := range p.GetConnections() {
obj.Connections = append(obj.Connections, r)
for _, r := range p.GetInstances() {
obj.Instances = append(obj.Instances, r)
}
return obj
}
Expand Down Expand Up @@ -886,11 +886,11 @@ func RunAlphaJobTemplateTemplateVolumesCloudSqlInstanceToProto(o *alpha.JobTempl
return nil
}
p := &alphapb.RunAlphaJobTemplateTemplateVolumesCloudSqlInstance{}
sConnections := make([]string, len(o.Connections))
for i, r := range o.Connections {
sConnections[i] = r
sInstances := make([]string, len(o.Instances))
for i, r := range o.Instances {
sInstances[i] = r
}
p.SetConnections(sConnections)
p.SetInstances(sInstances)
return p
}

Expand Down
6 changes: 3 additions & 3 deletions services/google/run/alpha/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -1155,8 +1155,8 @@ func (r *JobTemplateTemplateVolumesSecretItems) HashCode() string {
}

type JobTemplateTemplateVolumesCloudSqlInstance struct {
empty bool `json:"-"`
Connections []string `json:"connections"`
empty bool `json:"-"`
Instances []string `json:"instances"`
}

type jsonJobTemplateTemplateVolumesCloudSqlInstance JobTemplateTemplateVolumesCloudSqlInstance
Expand All @@ -1174,7 +1174,7 @@ func (r *JobTemplateTemplateVolumesCloudSqlInstance) UnmarshalJSON(data []byte)
*r = *EmptyJobTemplateTemplateVolumesCloudSqlInstance
} else {

r.Connections = res.Connections
r.Instances = res.Instances

}
return nil
Expand Down
4 changes: 2 additions & 2 deletions services/google/run/alpha/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -717,9 +717,9 @@ components:
x-dcl-conflicts:
- secret
properties:
connections:
instances:
type: array
x-dcl-go-name: Connections
x-dcl-go-name: Instances
description: 'The Cloud SQL instance connection names,
as can be found in https://console.cloud.google.com/sql/instances.
Visit https://cloud.google.com/sql/docs/mysql/connect-run
Expand Down
6 changes: 3 additions & 3 deletions services/google/run/alpha/job_alpha_yaml_embed.go

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions services/google/run/alpha/job_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2551,10 +2551,10 @@ func canonicalizeJobTemplateTemplateVolumesCloudSqlInstance(des, initial *JobTem

cDes := &JobTemplateTemplateVolumesCloudSqlInstance{}

if dcl.StringArrayCanonicalize(des.Connections, initial.Connections) {
cDes.Connections = initial.Connections
if dcl.StringArrayCanonicalize(des.Instances, initial.Instances) {
cDes.Instances = initial.Instances
} else {
cDes.Connections = des.Connections
cDes.Instances = des.Instances
}

return cDes
Expand Down Expand Up @@ -2602,8 +2602,8 @@ func canonicalizeNewJobTemplateTemplateVolumesCloudSqlInstance(c *Client, des, n
return nil
}

if dcl.StringArrayCanonicalize(des.Connections, nw.Connections) {
nw.Connections = des.Connections
if dcl.StringArrayCanonicalize(des.Instances, nw.Instances) {
nw.Instances = des.Instances
}

return nw
Expand Down Expand Up @@ -4232,7 +4232,7 @@ func compareJobTemplateTemplateVolumesCloudSqlInstanceNewStyle(d, a interface{},
actual = &actualNotPointer
}

if ds, err := dcl.Diff(desired.Connections, actual.Connections, dcl.Info{OperationSelector: dcl.TriggersOperation("updateJobUpdateJobOperation")}, fn.AddNest("Connections")); len(ds) != 0 || err != nil {
if ds, err := dcl.Diff(desired.Instances, actual.Instances, dcl.Info{OperationSelector: dcl.TriggersOperation("updateJobUpdateJobOperation")}, fn.AddNest("Instances")); len(ds) != 0 || err != nil {
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -6390,8 +6390,8 @@ func expandJobTemplateTemplateVolumesCloudSqlInstance(c *Client, f *JobTemplateT
}

m := make(map[string]interface{})
if v := f.Connections; v != nil {
m["connections"] = v
if v := f.Instances; v != nil {
m["instances"] = v
}

return m, nil
Expand All @@ -6410,7 +6410,7 @@ func flattenJobTemplateTemplateVolumesCloudSqlInstance(c *Client, i interface{},
if dcl.IsEmptyValueIndirect(i) {
return EmptyJobTemplateTemplateVolumesCloudSqlInstance
}
r.Connections = dcl.FlattenStringSlice(m["connections"])
r.Instances = dcl.FlattenStringSlice(m["instances"])

return r
}
Expand Down
2 changes: 1 addition & 1 deletion services/google/run/samples/create.job.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "{{name}}",
"project": "run-v2-deploy-e2e",
"location": "{{region}}",
"launchStage": "ALPHA",
"launchStage": "BETA",
"template": {
"template": {
"containers": [ {
Expand Down
3 changes: 1 addition & 2 deletions services/google/run/samples/create_bin_auth.job.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
"name": "{{name}}",
"project": "run-v2-deploy-e2e",
"location": "{{region}}",
"launchStage": "ALPHA",
"launchStage": "BETA",
"binaryAuthorization": {
"useDefault": true,
"policy": "projects/{{project}}/platforms/cloudRun/foo",
"breakglassJustification": "Some justification"
},
"template": {
Expand Down
4 changes: 2 additions & 2 deletions services/google/run/samples/create_cloudsql.job.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"name": "{{name}}",
"project": "run-v2-deploy-e2e",
"location": "{{region}}",
"launchStage": "ALPHA",
"launchStage": "BETA",
"template": {
"template": {
"volumes": [ {
"name": "cloudsql",
"cloudSqlInstance": {
"connections": ["careful-yew-216722:us-central1:testing-v2"]
"instances": ["careful-yew-216722:us-central1:testing-v2"]
}
} ],
"containers": [ {
Expand Down
2 changes: 1 addition & 1 deletion services/google/run/samples/create_secrets.job.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "{{name}}",
"project": "run-v2-deploy-e2e",
"location": "{{region}}",
"launchStage": "ALPHA",
"launchStage": "BETA",
"template": {
"template": {
"volumes": [ {
Expand Down
2 changes: 1 addition & 1 deletion services/google/run/samples/create_vpc_access.job.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "{{name}}",
"project": "run-v2-deploy-e2e",
"location": "{{region}}",
"launchStage": "ALPHA",
"launchStage": "BETA",
"template": {
"template": {
"containers": [ {
Expand Down
5 changes: 0 additions & 5 deletions services/google/run/samples/run_job_bin_auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@ type: job
versions:
- alpha
resource: samples/create_bin_auth.job.json
updates:
- resource: samples/update_bin_auth.job.json
dependencies: []
variables:
- name: name
type: resource_name
- name: project
type: project
- name: region
type: region
2 changes: 1 addition & 1 deletion services/google/run/samples/update.job.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "{{name}}",
"project": "run-v2-deploy-e2e",
"location": "{{region}}",
"launchStage": "ALPHA",
"launchStage": "BETA",
"client": "DCL",
"clientVersion": "v1",
"labels": {"label-key": "label-value"},
Expand Down
4 changes: 2 additions & 2 deletions services/google/run/samples/update_cloudsql.job.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"name": "{{name}}",
"project": "run-v2-deploy-e2e",
"location": "{{region}}",
"launchStage": "ALPHA",
"launchStage": "BETA",
"template": {
"template": {
"volumes": [ {
"name": "cloudsql",
"cloudSqlInstance": {
"connections": ["careful-yew-216722:us-central1:testing-v22"]
"instances": ["careful-yew-216722:us-central1:testing-v22"]
}
} ],
"containers": [ {
Expand Down
2 changes: 1 addition & 1 deletion services/google/run/samples/update_secrets.job.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "{{name}}",
"project": "run-v2-deploy-e2e",
"location": "{{region}}",
"launchStage": "ALPHA",
"launchStage": "BETA",
"template": {
"template": {
"volumes": [ {
Expand Down
16 changes: 8 additions & 8 deletions unstructured/google/run/alpha/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,11 @@ func JobToUnstructured(r *dclService.Job) *unstructured.Resource {
rTemplateTemplateVolumesObject := make(map[string]interface{})
if rTemplateTemplateVolumesVal.CloudSqlInstance != nil && rTemplateTemplateVolumesVal.CloudSqlInstance != dclService.EmptyJobTemplateTemplateVolumesCloudSqlInstance {
rTemplateTemplateVolumesValCloudSqlInstance := make(map[string]interface{})
var rTemplateTemplateVolumesValCloudSqlInstanceConnections []interface{}
for _, rTemplateTemplateVolumesValCloudSqlInstanceConnectionsVal := range rTemplateTemplateVolumesVal.CloudSqlInstance.Connections {
rTemplateTemplateVolumesValCloudSqlInstanceConnections = append(rTemplateTemplateVolumesValCloudSqlInstanceConnections, rTemplateTemplateVolumesValCloudSqlInstanceConnectionsVal)
var rTemplateTemplateVolumesValCloudSqlInstanceInstances []interface{}
for _, rTemplateTemplateVolumesValCloudSqlInstanceInstancesVal := range rTemplateTemplateVolumesVal.CloudSqlInstance.Instances {
rTemplateTemplateVolumesValCloudSqlInstanceInstances = append(rTemplateTemplateVolumesValCloudSqlInstanceInstances, rTemplateTemplateVolumesValCloudSqlInstanceInstancesVal)
}
rTemplateTemplateVolumesValCloudSqlInstance["connections"] = rTemplateTemplateVolumesValCloudSqlInstanceConnections
rTemplateTemplateVolumesValCloudSqlInstance["instances"] = rTemplateTemplateVolumesValCloudSqlInstanceInstances
rTemplateTemplateVolumesObject["cloudSqlInstance"] = rTemplateTemplateVolumesValCloudSqlInstance
}
if rTemplateTemplateVolumesVal.Name != nil {
Expand Down Expand Up @@ -922,15 +922,15 @@ func UnstructuredToJob(u *unstructured.Resource) (*dclService.Job, error) {
if _, ok := objval["cloudSqlInstance"]; ok {
if rTemplateTemplateVolumesCloudSqlInstance, ok := objval["cloudSqlInstance"].(map[string]interface{}); ok {
rTemplateTemplateVolumes.CloudSqlInstance = &dclService.JobTemplateTemplateVolumesCloudSqlInstance{}
if _, ok := rTemplateTemplateVolumesCloudSqlInstance["connections"]; ok {
if s, ok := rTemplateTemplateVolumesCloudSqlInstance["connections"].([]interface{}); ok {
if _, ok := rTemplateTemplateVolumesCloudSqlInstance["instances"]; ok {
if s, ok := rTemplateTemplateVolumesCloudSqlInstance["instances"].([]interface{}); ok {
for _, ss := range s {
if strval, ok := ss.(string); ok {
rTemplateTemplateVolumes.CloudSqlInstance.Connections = append(rTemplateTemplateVolumes.CloudSqlInstance.Connections, strval)
rTemplateTemplateVolumes.CloudSqlInstance.Instances = append(rTemplateTemplateVolumes.CloudSqlInstance.Instances, strval)
}
}
} else {
return nil, fmt.Errorf("rTemplateTemplateVolumes.CloudSqlInstance.Connections: expected []interface{}")
return nil, fmt.Errorf("rTemplateTemplateVolumes.CloudSqlInstance.Instances: expected []interface{}")
}
}
} else {
Expand Down

0 comments on commit cb224b3

Please sign in to comment.