diff --git a/controller/state.go b/controller/state.go index 0b70c4a0d8af9..3560df65946fd 100644 --- a/controller/state.go +++ b/controller/state.go @@ -28,7 +28,6 @@ import ( "github.com/argoproj/argo-cd/v2/controller/metrics" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" appclientset "github.com/argoproj/argo-cd/v2/pkg/client/clientset/versioned" - "github.com/argoproj/argo-cd/v2/pkg/version_config_manager" "github.com/argoproj/argo-cd/v2/reposerver/apiclient" "github.com/argoproj/argo-cd/v2/util/argo" argodiff "github.com/argoproj/argo-cd/v2/util/argo/diff" @@ -107,26 +106,6 @@ type appStateManager struct { persistResourceHealth bool } -func getVersionConfig() *apiclient.VersionConfig { - versionConfigManager, err := version_config_manager.NewVersionConfigManager("ConfigMap", "some-product-cm") - if err != nil { - log.Fatalf("Failed to create VersionConfigManager: %v", err) - return nil - } - - versionConfig, err := versionConfigManager.ObtainConfig() - if err != nil { - log.Fatalf("Failed to obtain config: %v", err) - return nil - } - - return &apiclient.VersionConfig{ - ProductLabel: versionConfig.ProductLabel, - ResourceName: versionConfig.ResourceName, - JsonPath: versionConfig.JsonPath, - } -} - func (m *appStateManager) getRepoObjs(app *v1alpha1.Application, sources []v1alpha1.ApplicationSource, appLabelKey string, revisions []string, noCache, noRevisionCache, verifySignature bool, proj *v1alpha1.AppProject) ([]*unstructured.Unstructured, []*apiclient.ManifestResponse, error) { ts := stats.NewTimingStats() @@ -201,6 +180,8 @@ 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, @@ -221,7 +202,7 @@ func (m *appStateManager) getRepoObjs(app *v1alpha1.Application, sources []v1alp HelmOptions: helmOptions, HasMultipleSources: app.Spec.HasMultipleSources(), RefSources: refSources, - VersionConfig: getVersionConfig(), + VersionConfig: apiclient.GetVersionConfig(), }) if err != nil { return nil, nil, fmt.Errorf("failed to generate manifest for source %d of %d: %w", i+1, len(sources), err) diff --git a/pkg/apiclient/events/events.pb.go b/pkg/apiclient/events/events.pb.go index 50a30ead30347..b7398f48055ac 100644 --- a/pkg/apiclient/events/events.pb.go +++ b/pkg/apiclient/events/events.pb.go @@ -230,6 +230,55 @@ func (m *EventPayload) GetErrors() []*ObjectError { return nil } +// * +// Application versions +type AppVersions struct { + AppVersion string `protobuf:"bytes,1,opt,name=appVersion" json:"appVersion"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *AppVersions) Reset() { *m = AppVersions{} } +func (m *AppVersions) String() string { return proto.CompactTextString(m) } +func (*AppVersions) ProtoMessage() {} +func (*AppVersions) Descriptor() ([]byte, []int) { + return fileDescriptor_3ad9267ec62b112f, []int{3} +} +func (m *AppVersions) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AppVersions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AppVersions.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AppVersions) XXX_Merge(src proto.Message) { + xxx_messageInfo_AppVersions.Merge(m, src) +} +func (m *AppVersions) XXX_Size() int { + return m.Size() +} +func (m *AppVersions) XXX_DiscardUnknown() { + xxx_messageInfo_AppVersions.DiscardUnknown(m) +} + +var xxx_messageInfo_AppVersions proto.InternalMessageInfo + +func (m *AppVersions) GetAppVersion() string { + if m != nil { + return m.AppVersion + } + return "" +} + // * // Holds information about the object source type ObjectSource struct { @@ -256,6 +305,7 @@ type ObjectSource struct { AppNamespace string `protobuf:"bytes,21,opt,name=appNamespace" json:"appNamespace"` AppInstanceLabelKey string `protobuf:"bytes,22,opt,name=appInstanceLabelKey" json:"appInstanceLabelKey"` TrackingMethod string `protobuf:"bytes,23,opt,name=trackingMethod" json:"trackingMethod"` + AppVersions *AppVersions `protobuf:"bytes,24,opt,name=appVersions" json:"appVersions,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -265,7 +315,7 @@ func (m *ObjectSource) Reset() { *m = ObjectSource{} } func (m *ObjectSource) String() string { return proto.CompactTextString(m) } func (*ObjectSource) ProtoMessage() {} func (*ObjectSource) Descriptor() ([]byte, []int) { - return fileDescriptor_3ad9267ec62b112f, []int{3} + return fileDescriptor_3ad9267ec62b112f, []int{4} } func (m *ObjectSource) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -455,6 +505,13 @@ func (m *ObjectSource) GetTrackingMethod() string { return "" } +func (m *ObjectSource) GetAppVersions() *AppVersions { + if m != nil { + return m.AppVersions + } + return nil +} + // * // Holds error information type ObjectError struct { @@ -471,7 +528,7 @@ func (m *ObjectError) Reset() { *m = ObjectError{} } func (m *ObjectError) String() string { return proto.CompactTextString(m) } func (*ObjectError) ProtoMessage() {} func (*ObjectError) Descriptor() ([]byte, []int) { - return fileDescriptor_3ad9267ec62b112f, []int{4} + return fileDescriptor_3ad9267ec62b112f, []int{5} } func (m *ObjectError) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -532,6 +589,7 @@ func init() { proto.RegisterType((*EventSource)(nil), "generic.EventSource") proto.RegisterType((*Event)(nil), "generic.Event") proto.RegisterType((*EventPayload)(nil), "generic.EventPayload") + proto.RegisterType((*AppVersions)(nil), "generic.AppVersions") proto.RegisterType((*ObjectSource)(nil), "generic.ObjectSource") proto.RegisterMapType((map[string]string)(nil), "generic.ObjectSource.AppLabelsEntry") proto.RegisterType((*ObjectError)(nil), "generic.ObjectError") @@ -540,64 +598,67 @@ func init() { func init() { proto.RegisterFile("server/application/events.proto", fileDescriptor_3ad9267ec62b112f) } var fileDescriptor_3ad9267ec62b112f = []byte{ - // 909 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xdd, 0x6e, 0xdc, 0x44, - 0x14, 0xc6, 0x9b, 0xff, 0xb3, 0x9b, 0x34, 0x4c, 0x93, 0x76, 0xb4, 0x2a, 0xe9, 0x6a, 0x15, 0xa1, - 0x55, 0xd5, 0xda, 0x64, 0xf9, 0x51, 0xa9, 0xb8, 0x49, 0xd5, 0x20, 0x02, 0x09, 0x20, 0x87, 0x22, - 0xc1, 0xdd, 0xc4, 0x7b, 0x6a, 0x4f, 0xd7, 0x9e, 0x19, 0xcd, 0xcc, 0x5a, 0xda, 0x5b, 0xc4, 0x1b, - 0xf0, 0x10, 0x5c, 0xf3, 0x16, 0xbd, 0x44, 0xe2, 0x1e, 0xa1, 0x88, 0x07, 0x41, 0x63, 0x7b, 0x37, - 0xe3, 0x90, 0x0b, 0xca, 0x9d, 0xcf, 0x77, 0xbe, 0xf3, 0xd9, 0xc7, 0xe7, 0x9b, 0x33, 0xf0, 0xd0, - 0xa0, 0x2e, 0x51, 0x47, 0x4c, 0xa9, 0x9c, 0x27, 0xcc, 0x72, 0x29, 0x22, 0x2c, 0x51, 0x58, 0x13, - 0x2a, 0x2d, 0xad, 0x24, 0x1b, 0x29, 0x0a, 0xd4, 0x3c, 0xe9, 0x9f, 0xa5, 0xdc, 0x66, 0xb3, 0xcb, - 0x30, 0x91, 0x45, 0xc4, 0x74, 0x2a, 0x95, 0x96, 0xaf, 0xab, 0x87, 0x27, 0xc9, 0x24, 0x2a, 0xc7, - 0x91, 0x9a, 0xa6, 0x11, 0x53, 0xdc, 0xb4, 0xa4, 0xca, 0x23, 0x96, 0xab, 0x8c, 0x1d, 0x45, 0x95, - 0x0a, 0xb3, 0x38, 0xa9, 0x65, 0xfb, 0x1f, 0x4d, 0x9f, 0x9a, 0x90, 0x4b, 0x57, 0x51, 0xb0, 0x24, - 0xe3, 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0x1c, 0xe3, 0x07, 0x00, 0x00, + // 945 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x4f, 0x6f, 0x1c, 0x35, + 0x14, 0x67, 0x36, 0xff, 0xdf, 0x6e, 0xd2, 0xe0, 0x26, 0xad, 0x15, 0x95, 0x74, 0xb5, 0x8a, 0xd0, + 0xaa, 0x6a, 0x67, 0x48, 0x0a, 0x55, 0xa9, 0xb8, 0xa4, 0x6a, 0x10, 0x81, 0x04, 0xd0, 0x84, 0x56, + 0x82, 0x9b, 0x33, 0xfb, 0x3a, 0xeb, 0xee, 0x8c, 0x6d, 0xd9, 0xde, 0x95, 0xf6, 0xca, 0x57, 0xe0, + 0x43, 0x70, 0xe6, 0xce, 0x07, 0xe8, 0x11, 0x89, 0x3b, 0x42, 0x11, 0x1f, 0x04, 0xd9, 0x33, 0xbb, + 0xeb, 0x09, 0x39, 0xd0, 0xde, 0xfc, 0x7e, 0xef, 0xf7, 0xde, 0xcc, 0xb3, 0x7f, 0xfe, 0x19, 0xee, + 0x1b, 0xd4, 0x13, 0xd4, 0x09, 0x53, 0xaa, 0xe0, 0x19, 0xb3, 0x5c, 0x8a, 0x04, 0x27, 0x28, 0xac, + 0x89, 0x95, 0x96, 0x56, 0x92, 0xb5, 0x1c, 0x05, 0x6a, 0x9e, 0xed, 0x9d, 0xe5, 0xdc, 0x0e, 0xc7, + 0x97, 0x71, 0x26, 0xcb, 0x84, 0xe9, 0x5c, 0x2a, 0x2d, 0xdf, 0xf8, 0xc5, 0xa3, 0x6c, 0x90, 0x4c, + 0x8e, 0x12, 0x35, 0xca, 0x13, 0xa6, 0xb8, 0x69, 0xb4, 0x9a, 0x1c, 0xb2, 0x42, 0x0d, 0xd9, 0x61, + 0xe2, 0xbb, 0x30, 0x8b, 0x83, 0xaa, 0xed, 0xde, 0xa7, 0xa3, 0xa7, 0x26, 0xe6, 0xd2, 0x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 0xeb, 0xf7, 0xfe, 0x93, 0xe8, 0xf9, 0xf1, 0xdb, 0xab, 0xfd, 0xe8, + 0x8f, 0xab, 0xfd, 0xe8, 0xef, 0xab, 0xfd, 0xe8, 0xa7, 0xc7, 0xff, 0xef, 0xc1, 0xcf, 0x0a, 0x8e, + 0xc2, 0xd6, 0x4d, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x17, 0x7b, 0xf3, 0xa9, 0x50, 0x08, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -864,6 +925,38 @@ func (m *EventPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *AppVersions) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AppVersions) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AppVersions) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + i -= len(m.AppVersion) + copy(dAtA[i:], m.AppVersion) + i = encodeVarintEvents(dAtA, i, uint64(len(m.AppVersion))) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *ObjectSource) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -888,6 +981,20 @@ func (m *ObjectSource) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= len(m.XXX_unrecognized) copy(dAtA[i:], m.XXX_unrecognized) } + if m.AppVersions != nil { + { + size, err := m.AppVersions.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xc2 + } i -= len(m.TrackingMethod) copy(dAtA[i:], m.TrackingMethod) i = encodeVarintEvents(dAtA, i, uint64(len(m.TrackingMethod))) @@ -1188,6 +1295,20 @@ func (m *EventPayload) Size() (n int) { return n } +func (m *AppVersions) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AppVersion) + n += 1 + l + sovEvents(uint64(l)) + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + func (m *ObjectSource) Size() (n int) { if m == nil { return 0 @@ -1253,6 +1374,10 @@ func (m *ObjectSource) Size() (n int) { n += 2 + l + sovEvents(uint64(l)) l = len(m.TrackingMethod) n += 2 + l + sovEvents(uint64(l)) + if m.AppVersions != nil { + l = m.AppVersions.Size() + n += 2 + l + sovEvents(uint64(l)) + } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -1735,6 +1860,89 @@ func (m *EventPayload) Unmarshal(dAtA []byte) error { } return nil } +func (m *AppVersions) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AppVersions: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AppVersions: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AppVersion", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AppVersion = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *ObjectSource) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2593,6 +2801,42 @@ func (m *ObjectSource) Unmarshal(dAtA []byte) error { } m.TrackingMethod = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 24: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AppVersions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AppVersions == nil { + m.AppVersions = &AppVersions{} + } + if err := m.AppVersions.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) diff --git a/pkg/version_config_manager/version_config_manager.go b/pkg/version_config_manager/version_config_manager.go index 696f57e9aa51a..1609d4a527321 100644 --- a/pkg/version_config_manager/version_config_manager.go +++ b/pkg/version_config_manager/version_config_manager.go @@ -2,6 +2,7 @@ package version_config_manager import ( "errors" + log "github.com/sirupsen/logrus" ) type VersionConfig struct { @@ -62,3 +63,19 @@ func NewVersionConfigManager(providerType string, source string) (*VersionConfig func (v *VersionConfigManager) ObtainConfig() (*VersionConfig, error) { return v.provider.GetConfig() } + +func GetVersionConfig() *VersionConfig { + versionConfigManager, err := NewVersionConfigManager("ConfigMap", "some-product-cm") + if err != nil { + log.Printf("ERROR: Failed to create VersionConfigManager: %v", err) + return nil + } + + versionConfig, err := versionConfigManager.ObtainConfig() + if err != nil { + log.Printf("ERROR: Failed to obtain config: %v", err) + return nil + } + + return versionConfig +} diff --git a/reposerver/apiclient/util.go b/reposerver/apiclient/util.go index f060911b8cf43..7c1d57b0995df 100644 --- a/reposerver/apiclient/util.go +++ b/reposerver/apiclient/util.go @@ -1,5 +1,9 @@ package apiclient +import ( + "github.com/argoproj/argo-cd/v2/pkg/version_config_manager" +) + func (m *ManifestResponse) GetCompiledManifests() []string { manifests := make([]string, len(m.Manifests)) for i, m := range m.Manifests { @@ -7,3 +11,17 @@ func (m *ManifestResponse) GetCompiledManifests() []string { } return manifests } + +func GetVersionConfig() *VersionConfig { + versionConfig := version_config_manager.GetVersionConfig() + + if versionConfig == nil { + return nil + } + + return &VersionConfig{ + ProductLabel: versionConfig.ProductLabel, + ResourceName: versionConfig.ResourceName, + JsonPath: versionConfig.JsonPath, + } +} diff --git a/reposerver/repository/app_version.go b/reposerver/repository/app_version.go index 2d4988bdbb522..78aa41c716391 100644 --- a/reposerver/repository/app_version.go +++ b/reposerver/repository/app_version.go @@ -10,25 +10,22 @@ import ( ) func getValueFromYAMLByJSONPath(appPath, jsonPathExpression string) (*string, error) { - // Чтение файла YAML content, err := os.ReadFile(appPath) if err != nil { return nil, err } - // Разбор YAML-файла var obj interface{} if err := yaml.Unmarshal(content, &obj); err != nil { return nil, err } - // Преобразование YAML в Map[interface{}]interface{} для работы jsonpath + // Convert YAML to Map[interface{}]interface{} jsonObj, err := convertToJSONCompatible(obj) if err != nil { return nil, err } - // Использование jsonpath для получения значения jp := jsonpath.New("jsonpathParser") jp.AllowMissingKeys(true) if err := jp.Parse(jsonPathExpression); err != nil { @@ -58,15 +55,12 @@ func convertToJSONCompatible(i interface{}) (interface{}, error) { } func getAppVersion(appPath string, resourceName string, jsonPathExpression string) (*string, error) { - // appPath = "example.yaml" - // jsonPathExpression = "{.some.json.path}" - value, err := getValueFromYAMLByJSONPath(appPath+"/"+resourceName, jsonPathExpression) if err != nil { return nil, err } - fmt.Printf("Value: %v\n", *value) + fmt.Printf("appVersion value: %v\n", *value) return value, nil } diff --git a/server/application/application.go b/server/application/application.go index 8ae5231bec054..011b09b9e6035 100644 --- a/server/application/application.go +++ b/server/application/application.go @@ -61,7 +61,6 @@ import ( "github.com/argoproj/argo-cd/v2/util/settings" applicationType "github.com/argoproj/argo-cd/v2/pkg/apis/application" - "github.com/argoproj/argo-cd/v2/pkg/version_config_manager" ) type AppResourceTreeFn func(ctx context.Context, app *appv1.Application) (*appv1.ApplicationTree, error) @@ -439,26 +438,6 @@ func (s *Server) queryRepoServer(ctx context.Context, a *appv1.Application, acti return action(client, repo, permittedHelmRepos, permittedHelmCredentials, helmOptions, kustomizeOptions, enabledSourceTypes) } -func getVersionConfig() *apiclient.VersionConfig { - versionConfigManager, err := version_config_manager.NewVersionConfigManager("ConfigMap", "some-product-cm") - if err != nil { - log.Fatalf("Failed to create VersionConfigManager: %v", err) - return nil - } - - versionConfig, err := versionConfigManager.ObtainConfig() - if err != nil { - log.Fatalf("Failed to obtain config: %v", err) - return nil - } - - return &apiclient.VersionConfig{ - ProductLabel: versionConfig.ProductLabel, - ResourceName: versionConfig.ResourceName, - JsonPath: versionConfig.JsonPath, - } -} - // GetManifests returns application manifests func (s *Server) GetManifests(ctx context.Context, q *application.ApplicationManifestQuery) (*apiclient.ManifestResponse, error) { if q.Name == nil || *q.Name == "" { @@ -517,7 +496,7 @@ func (s *Server) GetManifests(ctx context.Context, q *application.ApplicationMan HelmOptions: helmOptions, TrackingMethod: string(argoutil.GetTrackingMethod(s.settingsMgr)), EnabledSourceTypes: enableGenerateManifests, - VersionConfig: getVersionConfig(), + VersionConfig: apiclient.GetVersionConfig(), }) if err != nil { return fmt.Errorf("error generating manifests: %w", err) diff --git a/server/application/application_event_reporter.go b/server/application/application_event_reporter.go index a047d6ce53cf1..55f0966077d20 100644 --- a/server/application/application_event_reporter.go +++ b/server/application/application_event_reporter.go @@ -4,10 +4,11 @@ import ( "context" "encoding/json" "fmt" - "github.com/argoproj/argo-cd/v2/util/argo" "reflect" "strings" + "github.com/argoproj/argo-cd/v2/util/argo" + "github.com/argoproj/gitops-engine/pkg/health" "github.com/argoproj/gitops-engine/pkg/utils/kube" "github.com/argoproj/gitops-engine/pkg/utils/text" @@ -165,6 +166,13 @@ func (s *applicationEventReporter) streamApplicationEvents( return err } } else { + appVersionJSON, err := json.Marshal(desiredManifests.ApplicationVersions) + if err == nil { + if a.Annotations == nil { + a.Annotations = make(map[string]string) + } + a.Annotations["codefresh.io/appVersion"] = string(appVersionJSON) + } // will get here only for root applications (not managed as a resource by another application) appEvent, err := s.getApplicationEventPayload(ctx, a, es, ts, appInstanceLabelKey, trackingMethod) if err != nil { @@ -294,6 +302,14 @@ func (s *applicationEventReporter) processResource( if originalApplication != nil { originalAppRevisionMetadata, _ = s.getApplicationRevisionDetails(ctx, originalApplication, getOperationRevision(originalApplication)) + + appVersionJSON, err := json.Marshal(desiredManifests.ApplicationVersions) + if err == nil { + if parentApplicationToReport.Annotations == nil { + parentApplicationToReport.Annotations = make(map[string]string) + } + parentApplicationToReport.Annotations["codefresh.io/appVersion"] = string(appVersionJSON) + } } ev, err := getResourceEventPayload(parentApplicationToReport, &rs, es, actualState, desiredState, appTree, manifestGenErr, ts, originalApplication, revisionMetadataToReport, originalAppRevisionMetadata, appInstanceLabelKey, trackingMethod) @@ -687,6 +703,7 @@ func (s *applicationEventReporter) getApplicationEventPayload( Cluster: a.Spec.Destination.Server, AppInstanceLabelKey: appInstanceLabelKey, TrackingMethod: string(trackingMethod), + AppVersions: nil, } payload := events.EventPayload{ diff --git a/server/application/events.proto b/server/application/events.proto index 7b967c07eea44..190628df7164c 100644 --- a/server/application/events.proto +++ b/server/application/events.proto @@ -51,6 +51,13 @@ message EventPayload { repeated ObjectError errors = 4; } +/** +* Application versions +*/ +message AppVersions { + optional string appVersion = 1 [(gogoproto.nullable) = false]; +} + /** * Holds information about the object source */ @@ -78,6 +85,7 @@ message ObjectSource { optional string appNamespace = 21 [(gogoproto.nullable) = false]; optional string appInstanceLabelKey = 22 [(gogoproto.nullable) = false]; optional string trackingMethod = 23 [(gogoproto.nullable) = false]; + optional AppVersions appVersions = 24; } /** diff --git a/util/argo/argo.go b/util/argo/argo.go index 6809c5b2d8e90..610a5934b90b7 100644 --- a/util/argo/argo.go +++ b/util/argo/argo.go @@ -769,6 +769,7 @@ func verifyGenerateManifests( NoRevisionCache: true, HasMultipleSources: hasMultipleSources, RefSources: refSources, + VersionConfig: apiclient.GetVersionConfig(), } req.Repo.CopyCredentialsFromRepo(repoRes) req.Repo.CopySettingsFrom(repoRes)