@@ -1031,6 +1031,46 @@ controller.
1031
1031
Clients polling for completed reconciliation should poll until observedGeneration =
1032
1032
metadata.generation and the Ready condition's status is True or False.` ,
1033
1033
},
1034
+ "traffic" : {
1035
+ Type : schema .TypeList ,
1036
+ Computed : true ,
1037
+ Description : `Traffic specifies how to distribute traffic over a collection of Knative Revisions
1038
+ and Configurations` ,
1039
+ Elem : & schema.Resource {
1040
+ Schema : map [string ]* schema.Schema {
1041
+ "latest_revision" : {
1042
+ Type : schema .TypeBool ,
1043
+ Computed : true ,
1044
+ Description : `LatestRevision may be optionally provided to indicate that the latest ready
1045
+ Revision of the Configuration should be used for this traffic target. When
1046
+ provided LatestRevision must be true if RevisionName is empty; it must be
1047
+ false when RevisionName is non-empty.` ,
1048
+ },
1049
+ "percent" : {
1050
+ Type : schema .TypeInt ,
1051
+ Computed : true ,
1052
+ Description : `Percent specifies percent of the traffic to this Revision or Configuration.` ,
1053
+ },
1054
+ "revision_name" : {
1055
+ Type : schema .TypeString ,
1056
+ Computed : true ,
1057
+ Description : `RevisionName of a specific revision to which to send this portion of traffic.` ,
1058
+ },
1059
+ "tag" : {
1060
+ Type : schema .TypeString ,
1061
+ Computed : true ,
1062
+ Description : `Tag is optionally used to expose a dedicated url for referencing this target exclusively.` ,
1063
+ },
1064
+ "url" : {
1065
+ Type : schema .TypeString ,
1066
+ Computed : true ,
1067
+ Description : `URL displays the URL for accessing tagged traffic targets. URL is displayed in status,
1068
+ and is disallowed on spec. URL must contain a scheme (e.g. http://) and a hostname,
1069
+ but may not contain anything else (e.g. basic auth, url path, etc.)` ,
1070
+ },
1071
+ },
1072
+ },
1073
+ },
1034
1074
"url" : {
1035
1075
Type : schema .TypeString ,
1036
1076
Computed : true ,
@@ -2518,6 +2558,8 @@ func flattenCloudRunServiceStatus(v interface{}, d *schema.ResourceData, config
2518
2558
flattenCloudRunServiceStatusLatestCreatedRevisionName (original ["latestCreatedRevisionName" ], d , config )
2519
2559
transformed ["latest_ready_revision_name" ] =
2520
2560
flattenCloudRunServiceStatusLatestReadyRevisionName (original ["latestReadyRevisionName" ], d , config )
2561
+ transformed ["traffic" ] =
2562
+ flattenCloudRunServiceStatusTraffic (original ["traffic" ], d , config )
2521
2563
return []interface {}{transformed }
2522
2564
}
2523
2565
func flattenCloudRunServiceStatusConditions (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
@@ -2586,6 +2628,61 @@ func flattenCloudRunServiceStatusLatestReadyRevisionName(v interface{}, d *schem
2586
2628
return v
2587
2629
}
2588
2630
2631
+ func flattenCloudRunServiceStatusTraffic (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
2632
+ if v == nil {
2633
+ return v
2634
+ }
2635
+ l := v .([]interface {})
2636
+ transformed := make ([]interface {}, 0 , len (l ))
2637
+ for _ , raw := range l {
2638
+ original := raw .(map [string ]interface {})
2639
+ if len (original ) < 1 {
2640
+ // Do not include empty json objects coming back from the api
2641
+ continue
2642
+ }
2643
+ transformed = append (transformed , map [string ]interface {}{
2644
+ "revision_name" : flattenCloudRunServiceStatusTrafficRevisionName (original ["revisionName" ], d , config ),
2645
+ "percent" : flattenCloudRunServiceStatusTrafficPercent (original ["percent" ], d , config ),
2646
+ "tag" : flattenCloudRunServiceStatusTrafficTag (original ["tag" ], d , config ),
2647
+ "latest_revision" : flattenCloudRunServiceStatusTrafficLatestRevision (original ["latestRevision" ], d , config ),
2648
+ "url" : flattenCloudRunServiceStatusTrafficUrl (original ["url" ], d , config ),
2649
+ })
2650
+ }
2651
+ return transformed
2652
+ }
2653
+ func flattenCloudRunServiceStatusTrafficRevisionName (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
2654
+ return v
2655
+ }
2656
+
2657
+ func flattenCloudRunServiceStatusTrafficPercent (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
2658
+ // Handles the string fixed64 format
2659
+ if strVal , ok := v .(string ); ok {
2660
+ if intVal , err := tpgresource .StringToFixed64 (strVal ); err == nil {
2661
+ return intVal
2662
+ }
2663
+ }
2664
+
2665
+ // number values are represented as float64
2666
+ if floatVal , ok := v .(float64 ); ok {
2667
+ intVal := int (floatVal )
2668
+ return intVal
2669
+ }
2670
+
2671
+ return v // let terraform core handle it otherwise
2672
+ }
2673
+
2674
+ func flattenCloudRunServiceStatusTrafficTag (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
2675
+ return v
2676
+ }
2677
+
2678
+ func flattenCloudRunServiceStatusTrafficLatestRevision (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
2679
+ return v
2680
+ }
2681
+
2682
+ func flattenCloudRunServiceStatusTrafficUrl (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
2683
+ return v
2684
+ }
2685
+
2589
2686
func flattenCloudRunServiceMetadata (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
2590
2687
if v == nil {
2591
2688
return nil
0 commit comments