diff --git a/application/comparator.go b/application/comparator.go index 7b527265730c9..f7970a4f77e00 100644 --- a/application/comparator.go +++ b/application/comparator.go @@ -2,6 +2,7 @@ package application import ( "context" + "encoding/json" "fmt" "path" "time" @@ -62,17 +63,23 @@ func (ks *KsonnetAppComparator) CompareAppState(appRepoPath string, app *v1alpha if err != nil { return nil, err } - asciiDiffs := make([]string, len(diffResults.Diffs)) deltaDiffs := make([]string, len(diffResults.Diffs)) for i, diffRes := range diffResults.Diffs { - asciiDiffs[i] = diffRes.ASCIIDiff deltaDiffs[i] = diffRes.DeltaDiff } + targetState := make([]string, len(objs)) + for i, obj := range objs { + str, err := json.Marshal(obj.Object) + if err != nil { + return nil, err + } + targetState[i] = string(str) + } compResult := v1alpha1.ComparisonResult{ - ComparedTo: app.Spec.Source, - ComparedAt: metav1.Time{Time: time.Now().UTC()}, - ASCIIDiffs: asciiDiffs, - DeltaDiffs: deltaDiffs, + TargetState: targetState, + ComparedTo: app.Spec.Source, + ComparedAt: metav1.Time{Time: time.Now().UTC()}, + DeltaDiffs: deltaDiffs, } if diffResults.Modified { if *diffResults.AdditionsOnly { diff --git a/pkg/apis/application/v1alpha1/generated.pb.go b/pkg/apis/application/v1alpha1/generated.pb.go index 8aeaf87a2eb43..78da0927c45ab 100644 --- a/pkg/apis/application/v1alpha1/generated.pb.go +++ b/pkg/apis/application/v1alpha1/generated.pb.go @@ -454,8 +454,8 @@ func (m *ComparisonResult) MarshalTo(dAtA []byte) (int, error) { i++ i = encodeVarintGenerated(dAtA, i, uint64(len(m.Status))) i += copy(dAtA[i:], m.Status) - if len(m.ASCIIDiffs) > 0 { - for _, s := range m.ASCIIDiffs { + if len(m.TargetState) > 0 { + for _, s := range m.TargetState { dAtA[i] = 0x22 i++ l = len(s) @@ -731,8 +731,8 @@ func (m *ComparisonResult) Size() (n int) { n += 1 + l + sovGenerated(uint64(l)) l = len(m.Status) n += 1 + l + sovGenerated(uint64(l)) - if len(m.ASCIIDiffs) > 0 { - for _, s := range m.ASCIIDiffs { + if len(m.TargetState) > 0 { + for _, s := range m.TargetState { l = len(s) n += 1 + l + sovGenerated(uint64(l)) } @@ -919,7 +919,7 @@ func (this *ComparisonResult) String() string { `ComparedAt:` + strings.Replace(strings.Replace(this.ComparedAt.String(), "Time", "k8s_io_apimachinery_pkg_apis_meta_v1.Time", 1), `&`, ``, 1) + `,`, `ComparedTo:` + strings.Replace(strings.Replace(this.ComparedTo.String(), "ApplicationSource", "ApplicationSource", 1), `&`, ``, 1) + `,`, `Status:` + fmt.Sprintf("%v", this.Status) + `,`, - `ASCIIDiffs:` + fmt.Sprintf("%v", this.ASCIIDiffs) + `,`, + `TargetState:` + fmt.Sprintf("%v", this.TargetState) + `,`, `DeltaDiffs:` + fmt.Sprintf("%v", this.DeltaDiffs) + `,`, `Error:` + fmt.Sprintf("%v", this.Error) + `,`, `}`, @@ -2193,7 +2193,7 @@ func (m *ComparisonResult) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ASCIIDiffs", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TargetState", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2218,7 +2218,7 @@ func (m *ComparisonResult) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ASCIIDiffs = append(m.ASCIIDiffs, string(dAtA[iNdEx:postIndex])) + m.TargetState = append(m.TargetState, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 5: if wireType != 2 { @@ -2849,12 +2849,12 @@ func init() { } var fileDescriptorGenerated = []byte{ - // 1138 bytes of a gzipped FileDescriptorProto + // 1140 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcf, 0x6f, 0x23, 0xb5, 0x17, 0xef, 0xb4, 0x69, 0x9a, 0xbe, 0x74, 0xdb, 0x7e, 0xfd, 0x15, 0x10, 0xf5, 0x90, 0x56, 0x83, 0x80, 0x82, 0xd8, 0x09, 0x2d, 0xbf, 0x39, 0x20, 0x75, 0xd2, 0x22, 0x4a, 0xcb, 0xb2, 0x72, 0xb3, 0x42, 0x42, 0x08, 0x70, 0x27, 0x6e, 0xe2, 0x26, 0x33, 0x1e, 0xd9, 0x4e, 0x56, 0x3d, 0x20, 0xed, - 0x0d, 0x09, 0x09, 0x09, 0xfe, 0x0a, 0xee, 0x1c, 0xf8, 0x0f, 0x90, 0x7a, 0x5c, 0x09, 0x24, 0x56, + 0x0d, 0x09, 0x09, 0x09, 0xfe, 0x0a, 0xee, 0xdc, 0xf8, 0x03, 0x90, 0x7a, 0x5c, 0x09, 0x24, 0x56, 0x08, 0x55, 0x34, 0x7b, 0xe1, 0x6f, 0xd8, 0x13, 0xb2, 0xc7, 0x99, 0x99, 0x24, 0xaa, 0x76, 0xa1, 0xd1, 0xde, 0xc6, 0xef, 0x7d, 0xfc, 0x79, 0x1f, 0x3f, 0xbf, 0xf7, 0x3c, 0xb0, 0xdf, 0x62, 0xaa, 0xdd, 0x3b, 0xf6, 0x02, 0x1e, 0xd6, 0x88, 0x68, 0xf1, 0x58, 0xf0, 0x53, 0xf3, 0x71, 0x33, 0x68, @@ -2905,21 +2905,21 @@ var fileDescriptorGenerated = []byte{ 0xcb, 0x2b, 0x4f, 0x76, 0xba, 0x06, 0x0b, 0x69, 0xf6, 0xfa, 0xd7, 0x53, 0x16, 0x9c, 0x63, 0x44, 0xf7, 0x9c, 0x2c, 0x40, 0x83, 0xdb, 0x3e, 0x9e, 0xee, 0x4c, 0x9d, 0x90, 0xd0, 0xe0, 0x38, 0x17, 0x13, 0xbd, 0x37, 0xf2, 0x53, 0xb0, 0xe8, 0xbb, 0xa3, 0xcf, 0xf8, 0xa3, 0x91, 0xb9, 0x37, 0xfa, - 0xb4, 0x23, 0x0f, 0x80, 0xc8, 0x80, 0xb1, 0x5d, 0x76, 0x72, 0x22, 0x2b, 0x85, 0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xf1, 0x09, 0xa1, 0xd3, 0xc3, 0x22, 0x49, 0x83, 0x9e, 0x48, + 0x66, 0x66, 0x29, 0x53, 0xbb, 0x6f, 0xed, 0x38, 0x45, 0xa0, 0x6d, 0x80, 0xe4, 0x45, 0xb8, 0x95, + 0x25, 0x3f, 0xad, 0xd1, 0xa3, 0xd4, 0x83, 0x73, 0x28, 0xb4, 0x09, 0xa5, 0x80, 0x0a, 0xb5, 0xab, + 0xf3, 0xa7, 0x2f, 0x60, 0xc9, 0x5f, 0xd2, 0xec, 0x75, 0x6b, 0xc3, 0xa9, 0x17, 0xbd, 0x00, 0x0b, + 0x1d, 0x7a, 0x66, 0x80, 0x05, 0x03, 0x2c, 0xeb, 0x7f, 0xa6, 0x83, 0xc4, 0x84, 0x87, 0x3e, 0xe4, + 0x42, 0x31, 0x20, 0x06, 0x35, 0x6f, 0x50, 0x60, 0x1e, 0x87, 0x1d, 0x03, 0xb2, 0x1e, 0xdf, 0x3b, + 0xbf, 0xac, 0xce, 0xdc, 0xbf, 0xac, 0xce, 0x3c, 0xb8, 0xac, 0xce, 0xdc, 0x1b, 0x54, 0x9d, 0xf3, + 0x41, 0xd5, 0xb9, 0x3f, 0xa8, 0x3a, 0x0f, 0x06, 0x55, 0xe7, 0xaf, 0x41, 0xd5, 0xf9, 0xfe, 0x61, + 0x75, 0xe6, 0xb3, 0xd2, 0x30, 0x77, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x4e, 0xd3, 0x81, 0x57, + 0xc7, 0x0d, 0x00, 0x00, } diff --git a/pkg/apis/application/v1alpha1/generated.proto b/pkg/apis/application/v1alpha1/generated.proto index 6bcdeec0cea0a..625829c8bdd5a 100644 --- a/pkg/apis/application/v1alpha1/generated.proto +++ b/pkg/apis/application/v1alpha1/generated.proto @@ -113,7 +113,7 @@ message ComparisonResult { optional string status = 3; - repeated string asciiDiffs = 4; + repeated string targetState = 4; repeated string deltaDiffs = 5; diff --git a/pkg/apis/application/v1alpha1/types.go b/pkg/apis/application/v1alpha1/types.go index d25b9d88ef1ad..07c0ede2a5354 100644 --- a/pkg/apis/application/v1alpha1/types.go +++ b/pkg/apis/application/v1alpha1/types.go @@ -71,12 +71,12 @@ type ApplicationStatus struct { // ComparisonResult is a comparison result of application spec and deployed application. type ComparisonResult struct { - ComparedAt metav1.Time `json:"comparedAt" protobuf:"bytes,1,opt,name=comparedAt"` - ComparedTo ApplicationSource `json:"comparedTo" protobuf:"bytes,2,opt,name=comparedTo"` - Status ComparisonStatus `json:"status" protobuf:"bytes,3,opt,name=status,casttype=ComparisonStatus"` - ASCIIDiffs []string `json:"asciiDiffs,omitempty" protobuf:"bytes,4,opt,name=asciiDiffs"` - DeltaDiffs []string `json:"deltaDiffs,omitempty" protobuf:"bytes,5,opt,name=deltaDiffs"` - Error string `json:"error,omitempty" protobuf:"bytes,6,opt,name=error"` + ComparedAt metav1.Time `json:"comparedAt" protobuf:"bytes,1,opt,name=comparedAt"` + ComparedTo ApplicationSource `json:"comparedTo" protobuf:"bytes,2,opt,name=comparedTo"` + Status ComparisonStatus `json:"status" protobuf:"bytes,3,opt,name=status,casttype=ComparisonStatus"` + TargetState []string `json:"targetState,omitempty" protobuf:"bytes,4,opt,name=targetState"` + DeltaDiffs []string `json:"deltaDiffs,omitempty" protobuf:"bytes,5,opt,name=deltaDiffs"` + Error string `json:"error,omitempty" protobuf:"bytes,6,opt,name=error"` } // Cluster is the definition of a cluster resource diff --git a/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go index 807d5b4aaa6ad..b752111169fe8 100644 --- a/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go @@ -199,8 +199,8 @@ func (in *ComparisonResult) DeepCopyInto(out *ComparisonResult) { *out = *in in.ComparedAt.DeepCopyInto(&out.ComparedAt) out.ComparedTo = in.ComparedTo - if in.ASCIIDiffs != nil { - in, out := &in.ASCIIDiffs, &out.ASCIIDiffs + if in.TargetState != nil { + in, out := &in.TargetState, &out.TargetState *out = make([]string, len(*in)) copy(*out, *in) }