From 8ac7d17aefbfac1899c45e306dd02dacda56107d Mon Sep 17 00:00:00 2001 From: andrii-codefresh Date: Fri, 20 Oct 2023 22:01:03 +0300 Subject: [PATCH] review coments --- assets/swagger.json | 9 +- controller/state.go | 2 - pkg/apiclient/events/events.pb.go | 106 +++++++++--------- .../version_config_manager.go | 13 ++- reposerver/apiclient/repository.pb.go | 19 ++-- reposerver/repository/app_version.go | 7 +- reposerver/repository/repository.proto | 5 + .../application/application_event_reporter.go | 33 +++++- server/application/events.proto | 7 +- 9 files changed, 122 insertions(+), 79 deletions(-) diff --git a/assets/swagger.json b/assets/swagger.json index 4389e17d22dd5..34abbb9d57612 100644 --- a/assets/swagger.json +++ b/assets/swagger.json @@ -5029,13 +5029,16 @@ "type": "object", "properties": { "deps": { - "type": "string" + "type": "string", + "title": "Content of Cart.yaml/dependencies" }, "lock": { - "type": "string" + "type": "string", + "title": "Content of Chart.lock" }, "requirements": { - "type": "string" + "type": "string", + "title": "Content of requirements.yaml" } } }, diff --git a/controller/state.go b/controller/state.go index 3560df65946fd..40033571f9813 100644 --- a/controller/state.go +++ b/controller/state.go @@ -180,8 +180,6 @@ func (m *appStateManager) getRepoObjs(app *v1alpha1.Application, sources []v1alp ts.AddCheckpoint("version_ms") log.Debugf("Generating Manifest for source %s revision %s", source, revisions[i]) - - // versionConfig := manifestInfo, err := repoClient.GenerateManifest(context.Background(), &apiclient.ManifestRequest{ Repo: repo, Repos: permittedHelmRepos, diff --git a/pkg/apiclient/events/events.pb.go b/pkg/apiclient/events/events.pb.go index 71ea24084b18b..939664e1f51d6 100644 --- a/pkg/apiclient/events/events.pb.go +++ b/pkg/apiclient/events/events.pb.go @@ -163,8 +163,9 @@ type EventPayload struct { // The object source information Source *ObjectSource `protobuf:"bytes,3,req,name=source" json:"source,omitempty"` // The errors of this object - Errors []*ObjectError `protobuf:"bytes,4,rep,name=errors" json:"errors,omitempty"` - AppVersions *ApplicationVersions `protobuf:"bytes,24,opt,name=appVersions" json:"appVersions,omitempty"` + Errors []*ObjectError `protobuf:"bytes,4,rep,name=errors" json:"errors,omitempty"` + // A version of the application and its dependencies + AppVersions *ApplicationVersions `protobuf:"bytes,5,opt,name=appVersions" json:"appVersions,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -537,8 +538,11 @@ func (m *ObjectError) GetLastSeen() v1.Time { } type Dependencies struct { - Lock *string `protobuf:"bytes,1,opt,name=lock" json:"lock,omitempty"` - Deps *string `protobuf:"bytes,2,opt,name=deps" json:"deps,omitempty"` + // Content of Chart.lock + Lock *string `protobuf:"bytes,1,opt,name=lock" json:"lock,omitempty"` + // Content of Cart.yaml/dependencies + Deps *string `protobuf:"bytes,2,opt,name=deps" json:"deps,omitempty"` + // Content of requirements.yaml Requirements *string `protobuf:"bytes,3,opt,name=requirements" json:"requirements,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -601,7 +605,8 @@ func (m *Dependencies) GetRequirements() string { type ApplicationVersions struct { // Application version presented by single value - AppVersion *string `protobuf:"bytes,1,opt,name=appVersion" json:"appVersion,omitempty"` + AppVersion *string `protobuf:"bytes,1,opt,name=appVersion" json:"appVersion,omitempty"` + // Yaml content of dependencies Dependencies *Dependencies `protobuf:"bytes,2,opt,name=dependencies" json:"dependencies,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -669,7 +674,7 @@ func init() { func init() { proto.RegisterFile("server/application/events.proto", fileDescriptor_3ad9267ec62b112f) } var fileDescriptor_3ad9267ec62b112f = []byte{ - // 1008 bytes of a gzipped FileDescriptorProto + // 1009 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xdd, 0x6e, 0x1c, 0xb5, 0x17, 0xff, 0xcf, 0xe6, 0xfb, 0xec, 0x26, 0xed, 0xdf, 0x49, 0x5a, 0x2b, 0x0a, 0xe9, 0x6a, 0x15, 0xa1, 0x55, 0xd5, 0xce, 0x92, 0xf0, 0xa1, 0xb6, 0x42, 0x48, 0xa9, 0x12, 0x44, 0x20, 0x01, 0x34, @@ -693,46 +698,47 @@ var fileDescriptor_3ad9267ec62b112f = []byte{ 0x17, 0xba, 0xad, 0x7e, 0xfb, 0x70, 0x3b, 0xae, 0x13, 0x12, 0x7f, 0xe3, 0x09, 0x55, 0x58, 0x49, 0x4d, 0x22, 0x8f, 0x60, 0x19, 0xb5, 0x96, 0xda, 0xd0, 0xc5, 0xee, 0x42, 0xbf, 0x7d, 0xb8, 0x75, 0x83, 0x7e, 0xe2, 0x94, 0x49, 0xcd, 0x21, 0x9f, 0x41, 0x9b, 0x29, 0xf5, 0x12, 0xb5, 0x71, 0x1f, - 0x8c, 0xd2, 0x6e, 0xd4, 0x6f, 0x1f, 0xee, 0xce, 0x4d, 0x8e, 0xae, 0x33, 0x39, 0xe3, 0x24, 0xa1, - 0x41, 0xef, 0xa7, 0x35, 0xe8, 0x84, 0xcf, 0x20, 0x31, 0xdc, 0xc9, 0xd0, 0x70, 0x8d, 0xd9, 0x39, - 0x13, 0xfc, 0x35, 0x1a, 0x4b, 0xa3, 0x6e, 0x34, 0x8f, 0xf7, 0xa6, 0x92, 0x3c, 0x82, 0x0d, 0x96, - 0xda, 0x31, 0x2b, 0xe6, 0xf4, 0x56, 0x40, 0xbf, 0xa1, 0x23, 0xef, 0x43, 0x3b, 0xe7, 0x76, 0x4e, - 0x5d, 0x08, 0xa8, 0xa1, 0x82, 0xec, 0xc1, 0x8a, 0x46, 0x25, 0x5f, 0x24, 0x67, 0x74, 0x31, 0xe0, - 0xcc, 0x40, 0x42, 0x61, 0x51, 0x31, 0x3b, 0xa4, 0x4b, 0x81, 0xd2, 0x23, 0xa4, 0x0b, 0xab, 0x1a, - 0x27, 0xdc, 0x45, 0x47, 0x97, 0x03, 0xed, 0x1c, 0x25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4f, 0xfc, 0x57, 0x38, 0xa5, 0xf7, 0x02, 0x83, 0xdb, 0x08, 0xae, + 0xb3, 0xad, 0x66, 0xe9, 0x88, 0x8b, 0xfc, 0x1c, 0xed, 0x50, 0x66, 0xf4, 0x7e, 0xd8, 0xd9, 0x4d, + 0xdd, 0xce, 0xa7, 0xb0, 0xd1, 0x2c, 0x36, 0x72, 0x17, 0x16, 0x46, 0x38, 0xad, 0xa6, 0x47, 0xe2, + 0x8e, 0x64, 0x0b, 0x96, 0x26, 0xac, 0x18, 0x63, 0x35, 0x22, 0x92, 0x4a, 0x78, 0xd6, 0x7a, 0x12, + 0xf5, 0x7e, 0x89, 0xa0, 0x1d, 0x8c, 0x37, 0xd7, 0xdf, 0x76, 0xaa, 0xb0, 0x31, 0x7a, 0x3c, 0x42, + 0x76, 0x60, 0xa9, 0xc0, 0x09, 0x16, 0x8d, 0x31, 0x53, 0x41, 0x2e, 0x63, 0x65, 0x9d, 0xd1, 0x70, + 0xb2, 0xcc, 0x40, 0x72, 0x06, 0xab, 0x05, 0x33, 0xf6, 0x02, 0x51, 0xf8, 0xb1, 0xf2, 0x5f, 0x4a, + 0x78, 0xee, 0xa1, 0xf7, 0x0a, 0x3a, 0xc7, 0xa8, 0x50, 0x64, 0x28, 0x52, 0x8e, 0xc6, 0xad, 0x98, + 0x42, 0xa6, 0xa3, 0x3a, 0x60, 0x7f, 0x76, 0x58, 0x86, 0xca, 0xd4, 0x01, 0xfb, 0xb3, 0xab, 0x50, + 0x8d, 0x3f, 0x8c, 0xb9, 0xc6, 0xd2, 0x6d, 0xe9, 0xea, 0xa9, 0x49, 0x03, 0xeb, 0x29, 0xd8, 0xbc, + 0x65, 0x74, 0x93, 0x3d, 0x80, 0xeb, 0xe1, 0x5d, 0x5f, 0x14, 0x20, 0xe4, 0x29, 0x74, 0xb2, 0xe0, + 0x49, 0xfe, 0xda, 0x70, 0xe1, 0x84, 0xef, 0x4d, 0x1a, 0xd4, 0x43, 0x84, 0x55, 0xbf, 0xf1, 0xb8, + 0xc8, 0xc9, 0xf7, 0x70, 0xd7, 0x37, 0x69, 0xb8, 0x75, 0xaf, 0xd7, 0x50, 0x80, 0xee, 0x6c, 0x34, + 0xd1, 0xde, 0x7b, 0x3f, 0xfe, 0xf6, 0xe7, 0xcf, 0xad, 0xfb, 0x64, 0xdb, 0xaf, 0xf2, 0xc9, 0xc1, + 0xc0, 0x58, 0x8d, 0xac, 0xac, 0x7f, 0x48, 0x3e, 0x88, 0x9e, 0x1f, 0xbd, 0xbd, 0xda, 0x8b, 0x7e, + 0xbd, 0xda, 0x8b, 0xfe, 0xb8, 0xda, 0x8b, 0x5e, 0x7d, 0xf8, 0xef, 0xfe, 0x48, 0xd2, 0x82, 0xa3, + 0xb0, 0xb5, 0x93, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xc3, 0x5b, 0xa5, 0x9e, 0xf1, 0x08, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -964,9 +970,7 @@ func (m *EventPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintEvents(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xc2 + dAtA[i] = 0x2a } if len(m.Errors) > 0 { for iNdEx := len(m.Errors) - 1; iNdEx >= 0; iNdEx-- { @@ -1427,7 +1431,7 @@ func (m *EventPayload) Size() (n int) { } if m.AppVersions != nil { l = m.AppVersions.Size() - n += 2 + l + sovEvents(uint64(l)) + n += 1 + l + sovEvents(uint64(l)) } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) @@ -1995,7 +1999,7 @@ func (m *EventPayload) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 24: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AppVersions", wireType) } diff --git a/pkg/version_config_manager/version_config_manager.go b/pkg/version_config_manager/version_config_manager.go index 1609d4a527321..c4be2e79ca946 100644 --- a/pkg/version_config_manager/version_config_manager.go +++ b/pkg/version_config_manager/version_config_manager.go @@ -5,6 +5,11 @@ import ( log "github.com/sirupsen/logrus" ) +const ( + CodefreshAPIProviderType = "CodereshAPI" + ConfigMapProviderType = "ConfigMap" +) + type VersionConfig struct { ProductLabel string `json:"productLabel"` JsonPath string `json:"jsonPath"` @@ -23,7 +28,7 @@ type ConfigMapProvider struct { ConfigMapPath string } -func (CodereshAPI *CodereshAPIConfigProvider) GetConfig() (*VersionConfig, error) { +func (codereshAPI *CodereshAPIConfigProvider) GetConfig() (*VersionConfig, error) { // Implement logic to fetch config from the CodereshAPI here. // For this example, we'll just return a mock config. return &VersionConfig{ @@ -50,9 +55,9 @@ type VersionConfigManager struct { func NewVersionConfigManager(providerType string, source string) (*VersionConfigManager, error) { var provider ConfigProvider switch providerType { - case "CodereshAPI": + case CodefreshAPIProviderType: provider = &CodereshAPIConfigProvider{CodereshAPIEndpoint: source} - case "ConfigMap": + case ConfigMapProviderType: provider = &ConfigMapProvider{ConfigMapPath: source} default: return nil, errors.New("Invalid provider type") @@ -67,7 +72,7 @@ func (v *VersionConfigManager) ObtainConfig() (*VersionConfig, error) { func GetVersionConfig() *VersionConfig { versionConfigManager, err := NewVersionConfigManager("ConfigMap", "some-product-cm") if err != nil { - log.Printf("ERROR: Failed to create VersionConfigManager: %v", err) + log.Errorf("ERROR: Failed to create VersionConfigManager: %v", err) return nil } diff --git a/reposerver/apiclient/repository.pb.go b/reposerver/apiclient/repository.pb.go index 644a8abedcb8b..b0d39b11178dc 100644 --- a/reposerver/apiclient/repository.pb.go +++ b/reposerver/apiclient/repository.pb.go @@ -805,8 +805,11 @@ func (m *Manifest) GetLine() int32 { } type Dependencies struct { - Lock string `protobuf:"bytes,1,opt,name=lock,proto3" json:"lock,omitempty"` - Deps string `protobuf:"bytes,2,opt,name=deps,proto3" json:"deps,omitempty"` + // Content of Chart.lock + Lock string `protobuf:"bytes,1,opt,name=lock,proto3" json:"lock,omitempty"` + // Content of Cart.yaml/dependencies + Deps string `protobuf:"bytes,2,opt,name=deps,proto3" json:"deps,omitempty"` + // Content of requirements.yaml Requirements string `protobuf:"bytes,3,opt,name=requirements,proto3" json:"requirements,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -869,7 +872,8 @@ func (m *Dependencies) GetRequirements() string { type ApplicationVersions struct { // Application version presented by single value - AppVersion string `protobuf:"bytes,1,opt,name=appVersion,proto3" json:"appVersion,omitempty"` + AppVersion string `protobuf:"bytes,1,opt,name=appVersion,proto3" json:"appVersion,omitempty"` + // Yaml content of dependencies Dependencies *Dependencies `protobuf:"bytes,2,opt,name=dependencies,proto3" json:"dependencies,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -931,10 +935,11 @@ type ManifestResponse struct { Revision string `protobuf:"bytes,4,opt,name=revision,proto3" json:"revision,omitempty"` SourceType string `protobuf:"bytes,6,opt,name=sourceType,proto3" json:"sourceType,omitempty"` // Raw response of git verify-commit operation (always the empty string for Helm) - VerifyResult string `protobuf:"bytes,7,opt,name=verifyResult,proto3" json:"verifyResult,omitempty"` - CommitMessage string `protobuf:"bytes,8,opt,name=commitMessage,proto3" json:"commitMessage,omitempty"` - CommitAuthor string `protobuf:"bytes,9,opt,name=commitAuthor,proto3" json:"commitAuthor,omitempty"` - CommitDate *v1.Time `protobuf:"bytes,10,opt,name=commitDate,proto3" json:"commitDate,omitempty"` + VerifyResult string `protobuf:"bytes,7,opt,name=verifyResult,proto3" json:"verifyResult,omitempty"` + CommitMessage string `protobuf:"bytes,8,opt,name=commitMessage,proto3" json:"commitMessage,omitempty"` + CommitAuthor string `protobuf:"bytes,9,opt,name=commitAuthor,proto3" json:"commitAuthor,omitempty"` + CommitDate *v1.Time `protobuf:"bytes,10,opt,name=commitDate,proto3" json:"commitDate,omitempty"` + // A version of the application and its dependencies ApplicationVersions *ApplicationVersions `protobuf:"bytes,11,opt,name=applicationVersions,proto3" json:"applicationVersions,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` diff --git a/reposerver/repository/app_version.go b/reposerver/repository/app_version.go index 8387ae5cd40b1..40e4843729df6 100644 --- a/reposerver/repository/app_version.go +++ b/reposerver/repository/app_version.go @@ -1,11 +1,11 @@ package repository import ( - "fmt" "os" "path/filepath" "strings" + log "github.com/sirupsen/logrus" "gopkg.in/yaml.v2" "k8s.io/client-go/util/jsonpath" ) @@ -90,9 +90,6 @@ func convertToJSONCompatible(i interface{}) (interface{}, error) { } func getAppVersions(appPath string, resourceName string, jsonPathExpression string) (*Result, error) { - // TODO: remove mock - // appPath = "/home/andrii/projects/codefresh/test-chart" - // Defaults if resourceName == "" { resourceName = "Chart.yaml" @@ -106,7 +103,7 @@ func getAppVersions(appPath string, resourceName string, jsonPathExpression stri if err != nil { return nil, err } - fmt.Printf("appVersion value: %v\n", *appVersion) + log.Printf("appVersion value: %v\n", *appVersion) result := &Result{ AppVersion: *appVersion, diff --git a/reposerver/repository/repository.proto b/reposerver/repository/repository.proto index 4e42843648b2a..1189d5e9944d6 100644 --- a/reposerver/repository/repository.proto +++ b/reposerver/repository/repository.proto @@ -100,14 +100,18 @@ message Manifest { } message Dependencies { + // Content of Chart.lock string lock = 1; + // Content of Cart.yaml/dependencies string deps = 2; + // Content of requirements.yaml string requirements = 3; } message ApplicationVersions { // Application version presented by single value string appVersion = 1; + // Yaml content of dependencies Dependencies dependencies = 2; } @@ -123,6 +127,7 @@ message ManifestResponse { string commitMessage = 8; string commitAuthor = 9; k8s.io.apimachinery.pkg.apis.meta.v1.Time commitDate = 10; + // A version of the application and its dependencies ApplicationVersions applicationVersions = 11; } diff --git a/server/application/application_event_reporter.go b/server/application/application_event_reporter.go index 3af17a6b59830..9019238bbf07e 100644 --- a/server/application/application_event_reporter.go +++ b/server/application/application_event_reporter.go @@ -466,8 +466,17 @@ func getResourceEventPayload( syncStarted = metav1.Now() syncFinished *metav1.Time errors = []*events.ObjectError{} + logCtx *log.Entry ) + if originalApplication != nil { + logCtx = log.WithField("application", originalApplication.Name) + } else if parentApplication != nil { + logCtx = log.WithField("application", parentApplication.Name) + } else { + logCtx = log.NewEntry(log.StandardLogger()) + } + object := []byte(*actualState.Manifest) if originalAppRevisionMetadata != nil && len(object) != 0 { @@ -556,9 +565,10 @@ func getResourceEventPayload( } } - applicationVersionsEvents := &events.ApplicationVersions{} - applicationVersionsData, _ := json.Marshal(applicationVersions) - json.Unmarshal(applicationVersionsData, applicationVersionsEvents) + applicationVersionsEvents, err := repoAppVersionsToEvent(applicationVersions) + if err != nil { + logCtx.Errorf("failed to convert appVersions: %v", err) + } source := events.ObjectSource{ DesiredManifest: desiredState.CompiledManifest, @@ -672,9 +682,10 @@ func (s *applicationEventReporter) getApplicationEventPayload( logCtx.Info("reporting application deletion event") } - applicationVersionsEvents := &events.ApplicationVersions{} - applicationVersionsData, _ := json.Marshal(applicationVersions) - json.Unmarshal(applicationVersionsData, applicationVersionsEvents) + applicationVersionsEvents, err := repoAppVersionsToEvent(applicationVersions) + if err != nil { + logCtx.Errorf("failed to convert appVersions: %v", err) + } hs := string(a.Status.Health.Status) source := &events.ObjectSource{ @@ -778,3 +789,13 @@ func addCommitDetailsToLabels(u *unstructured.Unstructured, revisionMetadata *ap return u } + +func repoAppVersionsToEvent(applicationVersions *apiclient.ApplicationVersions) (*events.ApplicationVersions, error) { + applicationVersionsEvents := &events.ApplicationVersions{} + applicationVersionsData, _ := json.Marshal(applicationVersions) + err := json.Unmarshal(applicationVersionsData, applicationVersionsEvents) + if err != nil { + return nil, err + } + return applicationVersionsEvents, nil +} diff --git a/server/application/events.proto b/server/application/events.proto index 7be4596e843a7..18c865b712b5c 100644 --- a/server/application/events.proto +++ b/server/application/events.proto @@ -49,7 +49,8 @@ message EventPayload { required ObjectSource source = 3; // The errors of this object repeated ObjectError errors = 4; - optional ApplicationVersions appVersions = 24; + // A version of the application and its dependencies + optional ApplicationVersions appVersions = 5; } /** @@ -92,14 +93,18 @@ message ObjectError { } message Dependencies { + // Content of Chart.lock optional string lock = 1; + // Content of Cart.yaml/dependencies optional string deps = 2; + // Content of requirements.yaml optional string requirements = 3; } message ApplicationVersions { // Application version presented by single value optional string appVersion = 1; + // Yaml content of dependencies optional Dependencies dependencies = 2; }