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

added some fileds to CloudRun status #1071

Merged
merged 1 commit into from
Aug 26, 2019
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
46 changes: 46 additions & 0 deletions google-beta/resource_cloud_run_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,22 @@ func resourceCloudRunService() *schema.Resource {
},
},
},
"latest_created_revision_name": {
Type: schema.TypeString,
Computed: true,
},
"latest_ready_revision_name": {
Type: schema.TypeString,
Computed: true,
},
"observed_generation": {
Type: schema.TypeInt,
Computed: true,
},
"url": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
Expand Down Expand Up @@ -734,6 +750,14 @@ func flattenCloudRunServiceStatus(v interface{}, d *schema.ResourceData) interfa
transformed := make(map[string]interface{})
transformed["conditions"] =
flattenCloudRunServiceStatusConditions(original["conditions"], d)
transformed["url"] =
flattenCloudRunServiceStatusUrl(original["url"], d)
transformed["observed_generation"] =
flattenCloudRunServiceStatusObservedGeneration(original["observedGeneration"], d)
transformed["latest_created_revision_name"] =
flattenCloudRunServiceStatusLatestCreatedRevisionName(original["latestCreatedRevisionName"], d)
transformed["latest_ready_revision_name"] =
flattenCloudRunServiceStatusLatestReadyRevisionName(original["latestReadyRevisionName"], d)
return []interface{}{transformed}
}
func flattenCloudRunServiceStatusConditions(v interface{}, d *schema.ResourceData) interface{} {
Expand Down Expand Up @@ -773,6 +797,28 @@ func flattenCloudRunServiceStatusConditionsType(v interface{}, d *schema.Resourc
return v
}

func flattenCloudRunServiceStatusUrl(v interface{}, d *schema.ResourceData) interface{} {
return v
}

func flattenCloudRunServiceStatusObservedGeneration(v interface{}, d *schema.ResourceData) interface{} {
// Handles the string fixed64 format
if strVal, ok := v.(string); ok {
if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil {
return intVal
} // let terraform core handle it if we can't convert the string to an int.
}
return v
}

func flattenCloudRunServiceStatusLatestCreatedRevisionName(v interface{}, d *schema.ResourceData) interface{} {
return v
}

func flattenCloudRunServiceStatusLatestReadyRevisionName(v interface{}, d *schema.ResourceData) interface{} {
return v
}

func flattenCloudRunServiceMetadata(v interface{}, d *schema.ResourceData) interface{} {
if v == nil {
return nil
Expand Down
21 changes: 21 additions & 0 deletions website/docs/r/cloud_run_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,27 @@ The `status` block contains:
* `conditions` -
Array of observed Service Conditions, indicating the current ready state of the service. Structure is documented below.

* `url` -
From RouteStatus. URL holds the url that will distribute traffic over the provided traffic
targets. It generally has the form
https://{route-hash}-{project-hash}-{cluster-level-suffix}.a.run.app

* `observed_generation` -
ObservedGeneration is the 'Generation' of the Route that was last processed by the
controller.
Clients polling for completed reconciliation should poll until observedGeneration =
metadata.generation and the Ready condition's status is True or False.

* `latest_created_revision_name` -
From ConfigurationStatus. LatestCreatedRevisionName is the last revision that was created
from this Service's Configuration. It might not be ready yet, for that use
LatestReadyRevisionName.

* `latest_ready_revision_name` -
From ConfigurationStatus. LatestReadyRevisionName holds the name of the latest Revision
stamped out from this Service's Configuration that has had its "Ready" condition become
"True".


The `conditions` block contains:

Expand Down