Skip to content

Commit 46e0b00

Browse files
authored
Return json raw string in feedback result (#235)
* Return json raw string in feedback result Signed-off-by: Jian Qiu <[email protected]> * Add a featuregate to enable raw json string Signed-off-by: Jian Qiu <[email protected]> --------- Signed-off-by: Jian Qiu <[email protected]>
1 parent 0cbcb13 commit 46e0b00

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

feature/feature.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ const (
6363
// ManifestWorkReplicaSet will start new controller in the Hub that can be used to deploy manifestWorks to group
6464
// of clusters selected by a placement. For more info check ManifestWorkReplicaSet APIs
6565
ManifestWorkReplicaSet featuregate.Feature = "ManifestWorkReplicaSet"
66+
67+
// RawFeedbackJsonString will make the work agent to return the feedback result as a json string if the result
68+
// is not a scalar value.
69+
RawFeedbackJsonString featuregate.Feature = "RawFeedbackJsonString"
6670
)
6771

6872
// DefaultSpokeRegistrationFeatureGates consists of all known ocm-registration
@@ -98,4 +102,5 @@ var DefaultHubWorkFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec
98102
// To add a new feature, define a key for it above and add it here.
99103
var DefaultSpokeWorkFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
100104
ExecutorValidatingCaches: {Default: false, PreRelease: featuregate.Alpha},
105+
RawFeedbackJsonString: {Default: false, PreRelease: featuregate.Alpha},
101106
}

work/v1/0000_00_work.open-cluster-management.io_manifestworks.crd.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,14 @@ spec:
512512
when type is integer.
513513
format: int64
514514
type: integer
515+
jsonRaw:
516+
description: JsonRaw is a json string when
517+
type is a list or object
518+
maxLength: 1024
519+
type: string
515520
string:
516521
description: String is the string value when
517-
when type is string.
522+
type is string.
518523
type: string
519524
type:
520525
description: Type represents the type of the
@@ -523,6 +528,7 @@ spec:
523528
- Integer
524529
- String
525530
- Boolean
531+
- JsonRaw
526532
type: string
527533
required:
528534
- type

work/v1/types.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,22 +452,27 @@ type FieldValue struct {
452452
// +optional
453453
Integer *int64 `json:"integer,omitempty"`
454454

455-
// String is the string value when when type is string.
455+
// String is the string value when type is string.
456456
// +optional
457457
String *string `json:"string,omitempty"`
458458

459459
// Boolean is bool value when type is boolean.
460460
// +optional
461461
Boolean *bool `json:"boolean,omitempty"`
462+
463+
// JsonRaw is a json string when type is a list or object
464+
// +kubebuilder:validation:MaxLength=1024
465+
JsonRaw *string `json:"jsonRaw,omitempty"`
462466
}
463467

464-
// +kubebuilder:validation:Enum=Integer;String;Boolean
468+
// +kubebuilder:validation:Enum=Integer;String;Boolean;JsonRaw
465469
type ValueType string
466470

467471
const (
468472
Integer ValueType = "Integer"
469473
String ValueType = "String"
470474
Boolean ValueType = "Boolean"
475+
JsonRaw ValueType = "JsonRaw"
471476
)
472477

473478
// ManifestConditionType represents the condition type of a single

work/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

work/v1/zz_generated.swagger_doc_generated.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)