diff --git a/pkg/apiclient/repocreds/repocreds.pb.go b/pkg/apiclient/repocreds/repocreds.pb.go index 74d47ea1699ae..c872097d52ed0 100644 --- a/pkg/apiclient/repocreds/repocreds.pb.go +++ b/pkg/apiclient/repocreds/repocreds.pb.go @@ -13,6 +13,7 @@ import ( v1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + types "github.com/gogo/protobuf/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -231,6 +232,7 @@ func (m *RepoCredsCreateRequest) GetUpsert() bool { // RepoCredsUpdateRequest is a request for updating existing repository credentials config type RepoCredsUpdateRequest struct { Creds *v1alpha1.RepoCreds `protobuf:"bytes,1,opt,name=creds,proto3" json:"creds,omitempty"` + UpdateMask *types.FieldMask `protobuf:"bytes,3001,opt,name=updateMask,proto3" json:"updateMask,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -276,6 +278,13 @@ func (m *RepoCredsUpdateRequest) GetCreds() *v1alpha1.RepoCreds { return nil } +func (m *RepoCredsUpdateRequest) GetUpdateMask() *types.FieldMask { + if m != nil { + return m.UpdateMask + } + return nil +} + func init() { proto.RegisterType((*RepoCredsQuery)(nil), "repocreds.RepoCredsQuery") proto.RegisterType((*RepoCredsDeleteRequest)(nil), "repocreds.RepoCredsDeleteRequest") @@ -287,39 +296,42 @@ func init() { func init() { proto.RegisterFile("server/repocreds/repocreds.proto", fileDescriptor_b0b5fce4710a8821) } var fileDescriptor_b0b5fce4710a8821 = []byte{ - // 503 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x94, 0xc1, 0x6a, 0x14, 0x31, - 0x18, 0xc7, 0x49, 0xa5, 0xc5, 0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- 0xd5, 0xad, 0x0d, 0xf1, 0x56, 0x1b, 0xe2, 0x42, 0xa1, 0xc3, 0x75, 0x5d, 0x24, 0xe9, 0x7b, 0xcc, - 0x90, 0x2c, 0x63, 0x3e, 0x9c, 0x15, 0xfd, 0x07, 0xc2, 0xdd, 0xaa, 0xa8, 0x2b, 0xd3, 0x2e, 0x74, - 0xc1, 0xfa, 0x68, 0xef, 0x78, 0xda, 0xdb, 0xe1, 0x8d, 0x25, 0x5a, 0xf6, 0x7e, 0x4a, 0x50, 0xe8, - 0xec, 0x43, 0x45, 0xfe, 0x11, 0x77, 0xab, 0x01, 0x5b, 0x19, 0x7c, 0x61, 0x22, 0xc3, 0xc3, 0x36, - 0x49, 0x3d, 0x88, 0x37, 0x3d, 0x4d, 0xe7, 0xf8, 0x7a, 0x0b, 0x8d, 0xe3, 0x78, 0x74, 0xfa, 0x73, - 0xd2, 0x43, 0xbf, 0x26, 0x3d, 0xf4, 0x67, 0xd2, 0x43, 0x2f, 0xee, 0xaf, 0xf6, 0xd4, 0xc4, 0x99, - 0x80, 0xdc, 0x36, 0x5e, 0xe7, 0x5b, 0xfe, 0x6d, 0xb9, 0xf7, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x83, - 0xa0, 0x52, 0xd7, 0x30, 0x05, 0x00, 0x00, + // 551 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x94, 0x41, 0x6b, 0x13, 0x41, + 0x14, 0xc7, 0x99, 0x4a, 0x8b, 0x1d, 0x41, 0xda, 0xad, 0xb4, 0xc9, 0xa6, 0xc6, 0xb8, 0x07, 0x29, + 0x45, 0x67, 0x48, 0x04, 0x11, 0xbd, 0xd9, 0xa2, 0x07, 0xeb, 0xc1, 0x15, 0x2f, 0x82, 0x94, 0xc9, + 0xee, 0xeb, 0x76, 0xcc, 0x76, 0x67, 0x9c, 0x99, 0x5d, 0x28, 0x22, 0x82, 0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 0xe3, 0x7d, 0x43, 0xb8, 0x55, 0x4d, + 0x7d, 0x1e, 0xe2, 0xcd, 0x79, 0x88, 0x53, 0x36, 0xf1, 0x97, 0x35, 0x85, 0xa0, 0xe3, 0x30, 0xfd, + 0x60, 0x16, 0xf3, 0x41, 0x39, 0xa0, 0x1f, 0x08, 0xb7, 0x2a, 0x47, 0x2c, 0x4c, 0x3b, 0x65, 0xa1, + 0xe5, 0xd1, 0xde, 0x76, 0xb4, 0xb7, 0xfc, 0xeb, 0x33, 0xb4, 0xf4, 0xdd, 0x88, 0x20, 0x57, 0xe9, + 0xfb, 0x8a, 0xfc, 0x03, 0x6e, 0x55, 0xeb, 0xb9, 0x30, 0xf8, 0xd4, 0x3e, 0xfb, 0xbb, 0xf3, 0x24, + 0xe3, 0x35, 0xbe, 0xe1, 0x68, 0x9a, 0xfb, 0x3b, 0x73, 0x68, 0x2c, 0xc7, 0xa3, 0xc3, 0x5f, 0xc3, + 0x36, 0xfa, 0x3d, 0x6c, 0xa3, 0xbf, 0xc3, 0x36, 0x7a, 0x75, 0x6f, 0xb1, 0x3f, 0xaa, 0x28, 0xe5, + 0x90, 0x99, 0x3a, 0x57, 0x7f, 0xcd, 0x2d, 0xc1, 0xdd, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x7b, + 0xf1, 0xda, 0x9a, 0x90, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -686,6 +698,22 @@ func (m *RepoCredsUpdateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) i -= len(m.XXX_unrecognized) copy(dAtA[i:], m.XXX_unrecognized) } + if m.UpdateMask != nil { + { + size, err := m.UpdateMask.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRepocreds(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xbb + i-- + dAtA[i] = 0xca + } if m.Creds != nil { { size, err := m.Creds.MarshalToSizedBuffer(dAtA[:i]) @@ -785,6 +813,10 @@ func (m *RepoCredsUpdateRequest) Size() (n int) { l = m.Creds.Size() n += 1 + l + sovRepocreds(uint64(l)) } + if m.UpdateMask != nil { + l = m.UpdateMask.Size() + n += 3 + l + sovRepocreds(uint64(l)) + } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -1186,6 +1218,42 @@ func (m *RepoCredsUpdateRequest) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3001: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateMask", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRepocreds + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRepocreds + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRepocreds + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.UpdateMask == nil { + m.UpdateMask = &types.FieldMask{} + } + if err := m.UpdateMask.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipRepocreds(dAtA[iNdEx:]) diff --git a/pkg/apiclient/repocreds/repocreds.pb.gw.go b/pkg/apiclient/repocreds/repocreds.pb.gw.go index cbf003fbfaa54..f5a4e50cc529a 100644 --- a/pkg/apiclient/repocreds/repocreds.pb.gw.go +++ b/pkg/apiclient/repocreds/repocreds.pb.gw.go @@ -121,6 +121,10 @@ func local_request_RepoCredsService_CreateRepositoryCredentials_0(ctx context.Co } +var ( + filter_RepoCredsService_UpdateRepositoryCredentials_0 = &utilities.DoubleArray{Encoding: map[string]int{"creds": 0, "url": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} +) + func request_RepoCredsService_UpdateRepositoryCredentials_0(ctx context.Context, marshaler runtime.Marshaler, client RepoCredsServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq RepoCredsUpdateRequest var metadata runtime.ServerMetadata @@ -151,6 +155,13 @@ func request_RepoCredsService_UpdateRepositoryCredentials_0(ctx context.Context, return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "creds.url", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RepoCredsService_UpdateRepositoryCredentials_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdateRepositoryCredentials(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -186,6 +197,13 @@ func local_request_RepoCredsService_UpdateRepositoryCredentials_0(ctx context.Co return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "creds.url", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RepoCredsService_UpdateRepositoryCredentials_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdateRepositoryCredentials(ctx, &protoReq) return msg, metadata, err diff --git a/server/repocreds/repocreds.go b/server/repocreds/repocreds.go index 4474ce91b1655..a84537764a95d 100644 --- a/server/repocreds/repocreds.go +++ b/server/repocreds/repocreds.go @@ -1,6 +1,9 @@ package repocreds import ( + "github.com/argoproj/argo-cd/v2/util/grpc" + protov1 "github.com/golang/protobuf/proto" + "github.com/mennanov/fmutils" "reflect" "github.com/argoproj/argo-cd/v2/util/argo" @@ -117,6 +120,17 @@ func (s *Server) UpdateRepositoryCredentials(ctx context.Context, q *repocredspk if err := s.enf.EnforceErr(ctx.Value("claims"), rbacpolicy.ResourceRepositories, rbacpolicy.ActionUpdate, q.Creds.URL); err != nil { return nil, err } + + if q.UpdateMask != nil && len(q.UpdateMask.Paths) != 0 { + existing, err := s.db.GetRepositoryCredentials(ctx, q.Creds.URL) + if err != nil { + return nil, err + } + + grpc.Mask(protov1.MessageV2(existing), protov1.MessageV2(q.Creds), fmutils.NestedMaskFromPaths(q.UpdateMask.Paths)) + q.Creds = existing + } + _, err := s.db.UpdateRepositoryCredentials(ctx, q.Creds) return q.Creds, err } diff --git a/server/repocreds/repocreds.proto b/server/repocreds/repocreds.proto index 8161e5eb8e1c5..800079aceb432 100644 --- a/server/repocreds/repocreds.proto +++ b/server/repocreds/repocreds.proto @@ -8,6 +8,7 @@ package repocreds; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; +import "google/protobuf/field_mask.proto"; import "k8s.io/api/core/v1/generated.proto"; import "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1/generated.proto"; @@ -35,6 +36,7 @@ message RepoCredsCreateRequest { // RepoCredsUpdateRequest is a request for updating existing repository credentials config message RepoCredsUpdateRequest { github.com.argoproj.argo_cd.v2.pkg.apis.application.v1alpha1.RepoCreds creds = 1; + google.protobuf.FieldMask updateMask = 3001; } // RepoCredsService implements CRUD actions for managing repository credentials config