diff --git a/api/external/infra_proxy/migrations/migrations.pb.client_mock.go b/api/external/infra_proxy/migrations/migrations.pb.client_mock.go index 19e7aa8dbf6..e9e2d3c3fa4 100644 --- a/api/external/infra_proxy/migrations/migrations.pb.client_mock.go +++ b/api/external/infra_proxy/migrations/migrations.pb.client_mock.go @@ -96,6 +96,26 @@ func (mr *MockInfraProxyMigrationClientMockRecorder) GetStagedData(ctx, in inter return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStagedData", reflect.TypeOf((*MockInfraProxyMigrationClient)(nil).GetStagedData), varargs...) } +// ConfirmPreview mocks base method +func (m *MockInfraProxyMigrationClient) ConfirmPreview(ctx context.Context, in *request.ConfirmPreview, opts ...grpc.CallOption) (*response.ConfirmPreview, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, in} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ConfirmPreview", varargs...) + ret0, _ := ret[0].(*response.ConfirmPreview) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ConfirmPreview indicates an expected call of ConfirmPreview +func (mr *MockInfraProxyMigrationClientMockRecorder) ConfirmPreview(ctx, in interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, in}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConfirmPreview", reflect.TypeOf((*MockInfraProxyMigrationClient)(nil).ConfirmPreview), varargs...) +} + // MockInfraProxyMigrationServer is a mock of InfraProxyMigrationServer interface type MockInfraProxyMigrationServer struct { ctrl *gomock.Controller @@ -163,3 +183,18 @@ func (mr *MockInfraProxyMigrationServerMockRecorder) GetStagedData(arg0, arg1 in mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStagedData", reflect.TypeOf((*MockInfraProxyMigrationServer)(nil).GetStagedData), arg0, arg1) } + +// ConfirmPreview mocks base method +func (m *MockInfraProxyMigrationServer) ConfirmPreview(arg0 context.Context, arg1 *request.ConfirmPreview) (*response.ConfirmPreview, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ConfirmPreview", arg0, arg1) + ret0, _ := ret[0].(*response.ConfirmPreview) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ConfirmPreview indicates an expected call of ConfirmPreview +func (mr *MockInfraProxyMigrationServerMockRecorder) ConfirmPreview(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConfirmPreview", reflect.TypeOf((*MockInfraProxyMigrationServer)(nil).ConfirmPreview), arg0, arg1) +} diff --git a/api/external/infra_proxy/migrations/migrations.pb.go b/api/external/infra_proxy/migrations/migrations.pb.go index dff8cb10cff..09fd2d45025 100644 --- a/api/external/infra_proxy/migrations/migrations.pb.go +++ b/api/external/infra_proxy/migrations/migrations.pb.go @@ -52,7 +52,7 @@ var file_external_infra_proxy_migrations_migrations_proto_rawDesc = []byte{ 0x1a, 0x39, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xcf, 0x07, 0x0a, 0x13, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x97, 0x0a, 0x0a, 0x13, 0x49, 0x6e, 0x66, 0x72, 0x61, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0xa4, 0x02, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x4d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4b, 0x2e, 0x63, 0x68, 0x65, @@ -113,31 +113,55 @@ var file_external_infra_proxy_migrations_migrations_proto_rawDesc = []byte{ 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x3a, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x7b, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x7d, 0x8a, 0xb5, 0x18, 0x18, 0x12, 0x16, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x3a, 0x69, 0x6e, 0x66, - 0x72, 0x61, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x3a, 0x67, 0x65, 0x74, 0x42, 0x3e, 0x5a, - 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x65, 0x66, - 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x65, 0x78, - 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x5f, 0x70, 0x72, 0x6f, - 0x78, 0x79, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x61, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x3a, 0x67, 0x65, 0x74, 0x12, 0xc5, 0x02, + 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, + 0x12, 0x40, 0x2e, 0x63, 0x68, 0x65, 0x66, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x65, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, + 0x2e, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x50, 0x72, 0x65, 0x76, 0x69, + 0x65, 0x77, 0x1a, 0x41, 0x2e, 0x63, 0x68, 0x65, 0x66, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, + 0x74, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x5f, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x2e, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x72, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x50, 0x72, + 0x65, 0x76, 0x69, 0x65, 0x77, 0x22, 0xad, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x4d, 0x12, 0x4b, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x30, 0x2f, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x2f, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, + 0x7d, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x72, 0x6d, 0x5f, 0x70, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x2f, 0x7b, 0x6d, 0x69, + 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x7d, 0x8a, 0xb5, 0x18, 0x3a, 0x0a, + 0x38, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x3a, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x73, 0x3a, 0x7b, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x7d, 0x3a, + 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x7b, 0x6d, 0x69, 0x67, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x7d, 0x8a, 0xb5, 0x18, 0x18, 0x12, 0x16, 0x69, + 0x6e, 0x66, 0x72, 0x61, 0x3a, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x73, 0x3a, 0x67, 0x65, 0x74, 0x42, 0x3e, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x65, 0x66, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, + 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x69, + 0x6e, 0x66, 0x72, 0x61, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var file_external_infra_proxy_migrations_migrations_proto_goTypes = []interface{}{ (*request.GetMigrationStatusRequest)(nil), // 0: chef.automate.api.infra_proxy.migrations.request.GetMigrationStatusRequest (*request.CancelMigrationRequest)(nil), // 1: chef.automate.api.infra_proxy.migrations.request.CancelMigrationRequest (*request.GetStagedDataRequest)(nil), // 2: chef.automate.api.infra_proxy.migrations.request.GetStagedDataRequest - (*response.GetMigrationStatusResponse)(nil), // 3: chef.automate.api.infra_proxy.migrations.response.GetMigrationStatusResponse - (*response.CancelMigrationResponse)(nil), // 4: chef.automate.api.infra_proxy.migrations.response.CancelMigrationResponse - (*response.GetStagedDataResponse)(nil), // 5: chef.automate.api.infra_proxy.migrations.response.GetStagedDataResponse + (*request.ConfirmPreview)(nil), // 3: chef.automate.api.infra_proxy.migrations.request.ConfirmPreview + (*response.GetMigrationStatusResponse)(nil), // 4: chef.automate.api.infra_proxy.migrations.response.GetMigrationStatusResponse + (*response.CancelMigrationResponse)(nil), // 5: chef.automate.api.infra_proxy.migrations.response.CancelMigrationResponse + (*response.GetStagedDataResponse)(nil), // 6: chef.automate.api.infra_proxy.migrations.response.GetStagedDataResponse + (*response.ConfirmPreview)(nil), // 7: chef.automate.api.infra_proxy.migrations.response.ConfirmPreview } var file_external_infra_proxy_migrations_migrations_proto_depIdxs = []int32{ 0, // 0: chef.automate.api.infra_proxy.migrations.InfraProxyMigration.GetMigrationStatus:input_type -> chef.automate.api.infra_proxy.migrations.request.GetMigrationStatusRequest 1, // 1: chef.automate.api.infra_proxy.migrations.InfraProxyMigration.CancelMigration:input_type -> chef.automate.api.infra_proxy.migrations.request.CancelMigrationRequest 2, // 2: chef.automate.api.infra_proxy.migrations.InfraProxyMigration.GetStagedData:input_type -> chef.automate.api.infra_proxy.migrations.request.GetStagedDataRequest - 3, // 3: chef.automate.api.infra_proxy.migrations.InfraProxyMigration.GetMigrationStatus:output_type -> chef.automate.api.infra_proxy.migrations.response.GetMigrationStatusResponse - 4, // 4: chef.automate.api.infra_proxy.migrations.InfraProxyMigration.CancelMigration:output_type -> chef.automate.api.infra_proxy.migrations.response.CancelMigrationResponse - 5, // 5: chef.automate.api.infra_proxy.migrations.InfraProxyMigration.GetStagedData:output_type -> chef.automate.api.infra_proxy.migrations.response.GetStagedDataResponse - 3, // [3:6] is the sub-list for method output_type - 0, // [0:3] is the sub-list for method input_type + 3, // 3: chef.automate.api.infra_proxy.migrations.InfraProxyMigration.ConfirmPreview:input_type -> chef.automate.api.infra_proxy.migrations.request.ConfirmPreview + 4, // 4: chef.automate.api.infra_proxy.migrations.InfraProxyMigration.GetMigrationStatus:output_type -> chef.automate.api.infra_proxy.migrations.response.GetMigrationStatusResponse + 5, // 5: chef.automate.api.infra_proxy.migrations.InfraProxyMigration.CancelMigration:output_type -> chef.automate.api.infra_proxy.migrations.response.CancelMigrationResponse + 6, // 6: chef.automate.api.infra_proxy.migrations.InfraProxyMigration.GetStagedData:output_type -> chef.automate.api.infra_proxy.migrations.response.GetStagedDataResponse + 7, // 7: chef.automate.api.infra_proxy.migrations.InfraProxyMigration.ConfirmPreview:output_type -> chef.automate.api.infra_proxy.migrations.response.ConfirmPreview + 4, // [4:8] is the sub-list for method output_type + 0, // [0:4] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name @@ -182,6 +206,7 @@ type InfraProxyMigrationClient interface { GetMigrationStatus(ctx context.Context, in *request.GetMigrationStatusRequest, opts ...grpc.CallOption) (*response.GetMigrationStatusResponse, error) CancelMigration(ctx context.Context, in *request.CancelMigrationRequest, opts ...grpc.CallOption) (*response.CancelMigrationResponse, error) GetStagedData(ctx context.Context, in *request.GetStagedDataRequest, opts ...grpc.CallOption) (*response.GetStagedDataResponse, error) + ConfirmPreview(ctx context.Context, in *request.ConfirmPreview, opts ...grpc.CallOption) (*response.ConfirmPreview, error) } type infraProxyMigrationClient struct { @@ -219,11 +244,21 @@ func (c *infraProxyMigrationClient) GetStagedData(ctx context.Context, in *reque return out, nil } +func (c *infraProxyMigrationClient) ConfirmPreview(ctx context.Context, in *request.ConfirmPreview, opts ...grpc.CallOption) (*response.ConfirmPreview, error) { + out := new(response.ConfirmPreview) + err := c.cc.Invoke(ctx, "/chef.automate.api.infra_proxy.migrations.InfraProxyMigration/ConfirmPreview", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // InfraProxyMigrationServer is the server API for InfraProxyMigration service. type InfraProxyMigrationServer interface { GetMigrationStatus(context.Context, *request.GetMigrationStatusRequest) (*response.GetMigrationStatusResponse, error) CancelMigration(context.Context, *request.CancelMigrationRequest) (*response.CancelMigrationResponse, error) GetStagedData(context.Context, *request.GetStagedDataRequest) (*response.GetStagedDataResponse, error) + ConfirmPreview(context.Context, *request.ConfirmPreview) (*response.ConfirmPreview, error) } // UnimplementedInfraProxyMigrationServer can be embedded to have forward compatible implementations. @@ -239,6 +274,9 @@ func (*UnimplementedInfraProxyMigrationServer) CancelMigration(context.Context, func (*UnimplementedInfraProxyMigrationServer) GetStagedData(context.Context, *request.GetStagedDataRequest) (*response.GetStagedDataResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetStagedData not implemented") } +func (*UnimplementedInfraProxyMigrationServer) ConfirmPreview(context.Context, *request.ConfirmPreview) (*response.ConfirmPreview, error) { + return nil, status.Errorf(codes.Unimplemented, "method ConfirmPreview not implemented") +} func RegisterInfraProxyMigrationServer(s *grpc.Server, srv InfraProxyMigrationServer) { s.RegisterService(&_InfraProxyMigration_serviceDesc, srv) @@ -298,6 +336,24 @@ func _InfraProxyMigration_GetStagedData_Handler(srv interface{}, ctx context.Con return interceptor(ctx, in, info, handler) } +func _InfraProxyMigration_ConfirmPreview_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(request.ConfirmPreview) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(InfraProxyMigrationServer).ConfirmPreview(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/chef.automate.api.infra_proxy.migrations.InfraProxyMigration/ConfirmPreview", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(InfraProxyMigrationServer).ConfirmPreview(ctx, req.(*request.ConfirmPreview)) + } + return interceptor(ctx, in, info, handler) +} + var _InfraProxyMigration_serviceDesc = grpc.ServiceDesc{ ServiceName: "chef.automate.api.infra_proxy.migrations.InfraProxyMigration", HandlerType: (*InfraProxyMigrationServer)(nil), @@ -314,6 +370,10 @@ var _InfraProxyMigration_serviceDesc = grpc.ServiceDesc{ MethodName: "GetStagedData", Handler: _InfraProxyMigration_GetStagedData_Handler, }, + { + MethodName: "ConfirmPreview", + Handler: _InfraProxyMigration_ConfirmPreview_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "external/infra_proxy/migrations/migrations.proto", diff --git a/api/external/infra_proxy/migrations/migrations.pb.gw.go b/api/external/infra_proxy/migrations/migrations.pb.gw.go index c7db809ce89..0c27481b5aa 100644 --- a/api/external/infra_proxy/migrations/migrations.pb.gw.go +++ b/api/external/infra_proxy/migrations/migrations.pb.gw.go @@ -216,6 +216,82 @@ func local_request_InfraProxyMigration_GetStagedData_0(ctx context.Context, mars } +func request_InfraProxyMigration_ConfirmPreview_0(ctx context.Context, marshaler runtime.Marshaler, client InfraProxyMigrationClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq request.ConfirmPreview + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["server_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "server_id") + } + + protoReq.ServerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "server_id", err) + } + + val, ok = pathParams["migration_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "migration_id") + } + + protoReq.MigrationId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "migration_id", err) + } + + msg, err := client.ConfirmPreview(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_InfraProxyMigration_ConfirmPreview_0(ctx context.Context, marshaler runtime.Marshaler, server InfraProxyMigrationServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq request.ConfirmPreview + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["server_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "server_id") + } + + protoReq.ServerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "server_id", err) + } + + val, ok = pathParams["migration_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "migration_id") + } + + protoReq.MigrationId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "migration_id", err) + } + + msg, err := server.ConfirmPreview(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterInfraProxyMigrationHandlerServer registers the http handlers for service InfraProxyMigration to "mux". // UnaryRPC :call InfraProxyMigrationServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -281,6 +357,26 @@ func RegisterInfraProxyMigrationHandlerServer(ctx context.Context, mux *runtime. }) + mux.Handle("GET", pattern_InfraProxyMigration_ConfirmPreview_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_InfraProxyMigration_ConfirmPreview_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_InfraProxyMigration_ConfirmPreview_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -382,6 +478,26 @@ func RegisterInfraProxyMigrationHandlerClient(ctx context.Context, mux *runtime. }) + mux.Handle("GET", pattern_InfraProxyMigration_ConfirmPreview_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_InfraProxyMigration_ConfirmPreview_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_InfraProxyMigration_ConfirmPreview_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -391,6 +507,8 @@ var ( pattern_InfraProxyMigration_CancelMigration_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"api", "v0", "infra", "servers", "server_id", "migrations", "cancel_migration", "migration_id"}, "", runtime.AssumeColonVerbOpt(true))) pattern_InfraProxyMigration_GetStagedData_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"api", "v0", "infra", "servers", "migrations", "staged_data", "migration_id"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_InfraProxyMigration_ConfirmPreview_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"api", "v0", "infra", "servers", "server_id", "migrations", "confirm_preview", "migration_id"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -399,4 +517,6 @@ var ( forward_InfraProxyMigration_CancelMigration_0 = runtime.ForwardResponseMessage forward_InfraProxyMigration_GetStagedData_0 = runtime.ForwardResponseMessage + + forward_InfraProxyMigration_ConfirmPreview_0 = runtime.ForwardResponseMessage ) diff --git a/api/external/infra_proxy/migrations/migrations.pb.policy.go b/api/external/infra_proxy/migrations/migrations.pb.policy.go index 5ee8ed29d8a..620a57304da 100644 --- a/api/external/infra_proxy/migrations/migrations.pb.policy.go +++ b/api/external/infra_proxy/migrations/migrations.pb.policy.go @@ -50,4 +50,19 @@ func init() { } return "" }) + policy.MapMethodTo("/chef.automate.api.infra_proxy.migrations.InfraProxyMigration/ConfirmPreview", "infra:infraServers:{server_id}:migrations:{migration_id}", "infra:infraServers:get", "GET", "/api/v0/infra/servers/{server_id}/migrations/confirm_preview/{migration_id}", func(unexpandedResource string, input interface{}) string { + if m, ok := input.(*request.ConfirmPreview); ok { + return policy.ExpandParameterizedResource(unexpandedResource, func(want string) string { + switch want { + case "server_id": + return m.ServerId + case "migration_id": + return m.MigrationId + default: + return "" + } + }) + } + return "" + }) } diff --git a/api/external/infra_proxy/migrations/migrations.proto b/api/external/infra_proxy/migrations/migrations.proto index 36c7e24f6e3..b7148b7ee51 100644 --- a/api/external/infra_proxy/migrations/migrations.proto +++ b/api/external/infra_proxy/migrations/migrations.proto @@ -27,4 +27,10 @@ service InfraProxyMigration { option (chef.automate.api.iam.policy).resource = "infra:infraServers:migrations:{migration_id}"; option (chef.automate.api.iam.policy).action = "infra:infraServers:get"; }; + + rpc ConfirmPreview (infra_proxy.migrations.request.ConfirmPreview) returns (infra_proxy.migrations.response.ConfirmPreview) { + option (google.api.http).get = "/api/v0/infra/servers/{server_id}/migrations/confirm_preview/{migration_id}"; + option (chef.automate.api.iam.policy).resource = "infra:infraServers:{server_id}:migrations:{migration_id}"; + option (chef.automate.api.iam.policy).action = "infra:infraServers:get"; + }; } diff --git a/api/external/infra_proxy/migrations/migrations.swagger.json b/api/external/infra_proxy/migrations/migrations.swagger.json index 30890cebd6f..aedabc3fa43 100644 --- a/api/external/infra_proxy/migrations/migrations.swagger.json +++ b/api/external/infra_proxy/migrations/migrations.swagger.json @@ -110,6 +110,44 @@ "InfraProxyMigration" ] } + }, + "/api/v0/infra/servers/{server_id}/migrations/confirm_preview/{migration_id}": { + "get": { + "operationId": "InfraProxyMigration_ConfirmPreview", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/chef.automate.api.infra_proxy.migrations.response.ConfirmPreview" + } + }, + "default": { + "description": "An unexpected error response", + "schema": { + "$ref": "#/definitions/grpc.gateway.runtime.Error" + } + } + }, + "parameters": [ + { + "name": "server_id", + "description": "Chef Server ID", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "migration_id", + "description": "Migration ID", + "in": "path", + "required": true, + "type": "string" + } + ], + "tags": [ + "InfraProxyMigration" + ] + } } }, "definitions": { @@ -130,6 +168,15 @@ } } }, + "chef.automate.api.infra_proxy.migrations.response.ConfirmPreview": { + "type": "object", + "properties": { + "migration_id": { + "type": "string", + "title": "Migration ID" + } + } + }, "chef.automate.api.infra_proxy.migrations.response.GetMigrationStatusResponse": { "type": "object", "properties": { diff --git a/api/external/infra_proxy/migrations/request/migrations.pb.go b/api/external/infra_proxy/migrations/request/migrations.pb.go index f7152aa14f4..e17af51c70c 100644 --- a/api/external/infra_proxy/migrations/request/migrations.pb.go +++ b/api/external/infra_proxy/migrations/request/migrations.pb.go @@ -359,6 +359,63 @@ func (x *GetStagedDataRequest) GetMigrationId() string { return "" } +type ConfirmPreview struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Chef Server ID + ServerId string `protobuf:"bytes,1,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"` + // Migration ID + MigrationId string `protobuf:"bytes,2,opt,name=migration_id,json=migrationId,proto3" json:"migration_id,omitempty"` +} + +func (x *ConfirmPreview) Reset() { + *x = ConfirmPreview{} + if protoimpl.UnsafeEnabled { + mi := &file_external_infra_proxy_migrations_request_migrations_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConfirmPreview) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfirmPreview) ProtoMessage() {} + +func (x *ConfirmPreview) ProtoReflect() protoreflect.Message { + mi := &file_external_infra_proxy_migrations_request_migrations_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfirmPreview.ProtoReflect.Descriptor instead. +func (*ConfirmPreview) Descriptor() ([]byte, []int) { + return file_external_infra_proxy_migrations_request_migrations_proto_rawDescGZIP(), []int{6} +} + +func (x *ConfirmPreview) GetServerId() string { + if x != nil { + return x.ServerId + } + return "" +} + +func (x *ConfirmPreview) GetMigrationId() string { + if x != nil { + return x.MigrationId + } + return "" +} + var File_external_infra_proxy_migrations_request_migrations_proto protoreflect.FileDescriptor var file_external_infra_proxy_migrations_request_migrations_proto_rawDesc = []byte{ @@ -403,11 +460,17 @@ var file_external_infra_proxy_migrations_request_migrations_proto_rawDesc = []by 0x65, 0x64, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, - 0x42, 0x46, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, - 0x68, 0x65, 0x66, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x65, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x5f, - 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x2f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x22, 0x50, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x50, 0x72, 0x65, 0x76, 0x69, + 0x65, 0x77, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, + 0x21, 0x0a, 0x0c, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x49, 0x64, 0x42, 0x46, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x63, 0x68, 0x65, 0x66, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x65, 0x2f, 0x61, + 0x70, 0x69, 0x2f, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x69, 0x6e, 0x66, 0x72, + 0x61, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x2f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -422,7 +485,7 @@ func file_external_infra_proxy_migrations_request_migrations_proto_rawDescGZIP() return file_external_infra_proxy_migrations_request_migrations_proto_rawDescData } -var file_external_infra_proxy_migrations_request_migrations_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_external_infra_proxy_migrations_request_migrations_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_external_infra_proxy_migrations_request_migrations_proto_goTypes = []interface{}{ (*UploadZipFileRequest)(nil), // 0: chef.automate.api.infra_proxy.migrations.request.UploadZipFileRequest (*Metadata)(nil), // 1: chef.automate.api.infra_proxy.migrations.request.Metadata @@ -430,6 +493,7 @@ var file_external_infra_proxy_migrations_request_migrations_proto_goTypes = []in (*GetMigrationStatusRequest)(nil), // 3: chef.automate.api.infra_proxy.migrations.request.GetMigrationStatusRequest (*CancelMigrationRequest)(nil), // 4: chef.automate.api.infra_proxy.migrations.request.CancelMigrationRequest (*GetStagedDataRequest)(nil), // 5: chef.automate.api.infra_proxy.migrations.request.GetStagedDataRequest + (*ConfirmPreview)(nil), // 6: chef.automate.api.infra_proxy.migrations.request.ConfirmPreview } var file_external_infra_proxy_migrations_request_migrations_proto_depIdxs = []int32{ 2, // 0: chef.automate.api.infra_proxy.migrations.request.UploadZipFileRequest.chunk:type_name -> chef.automate.api.infra_proxy.migrations.request.Chunk @@ -519,6 +583,18 @@ func file_external_infra_proxy_migrations_request_migrations_proto_init() { return nil } } + file_external_infra_proxy_migrations_request_migrations_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConfirmPreview); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -526,7 +602,7 @@ func file_external_infra_proxy_migrations_request_migrations_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_external_infra_proxy_migrations_request_migrations_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 7, NumExtensions: 0, NumServices: 0, }, diff --git a/api/external/infra_proxy/migrations/request/migrations.proto b/api/external/infra_proxy/migrations/request/migrations.proto index 685157bec6f..485fadd3cd4 100644 --- a/api/external/infra_proxy/migrations/request/migrations.proto +++ b/api/external/infra_proxy/migrations/request/migrations.proto @@ -40,5 +40,12 @@ message CancelMigrationRequest { message GetStagedDataRequest { // Migration ID - string migration_id = 1; + string migration_id = 1; +} + +message ConfirmPreview { + // Chef Server ID + string server_id = 1; + // Migration ID + string migration_id = 2; } diff --git a/api/external/infra_proxy/migrations/response/migrations.pb.go b/api/external/infra_proxy/migrations/response/migrations.pb.go index b508963cfdf..95e2555053c 100644 --- a/api/external/infra_proxy/migrations/response/migrations.pb.go +++ b/api/external/infra_proxy/migrations/response/migrations.pb.go @@ -484,6 +484,54 @@ func (x *User) GetIsAdmin() bool { return false } +type ConfirmPreview struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Migration ID + MigrationId string `protobuf:"bytes,1,opt,name=migration_id,json=migrationId,proto3" json:"migration_id,omitempty"` +} + +func (x *ConfirmPreview) Reset() { + *x = ConfirmPreview{} + if protoimpl.UnsafeEnabled { + mi := &file_external_infra_proxy_migrations_response_migrations_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConfirmPreview) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfirmPreview) ProtoMessage() {} + +func (x *ConfirmPreview) ProtoReflect() protoreflect.Message { + mi := &file_external_infra_proxy_migrations_response_migrations_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfirmPreview.ProtoReflect.Descriptor instead. +func (*ConfirmPreview) Descriptor() ([]byte, []int) { + return file_external_infra_proxy_migrations_response_migrations_proto_rawDescGZIP(), []int{6} +} + +func (x *ConfirmPreview) GetMigrationId() string { + if x != nil { + return x.MigrationId + } + return "" +} + var File_external_infra_proxy_migrations_response_migrations_proto protoreflect.FileDescriptor var file_external_infra_proxy_migrations_response_migrations_proto_rawDesc = []byte{ @@ -560,12 +608,15 @@ var file_external_infra_proxy_migrations_response_migrations_proto_rawDesc = []b 0x63, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x69, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x6c, 0x69, 0x63, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, - 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x42, 0x47, 0x5a, 0x45, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x65, 0x66, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, - 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x69, - 0x6e, 0x66, 0x72, 0x61, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x22, 0x33, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, + 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x12, 0x21, 0x0a, 0x0c, 0x6d, 0x69, 0x67, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6d, + 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x47, 0x5a, 0x45, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x65, 0x66, 0x2f, 0x61, 0x75, + 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x65, 0x78, 0x74, 0x65, 0x72, + 0x6e, 0x61, 0x6c, 0x2f, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, + 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x72, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -580,7 +631,7 @@ func file_external_infra_proxy_migrations_response_migrations_proto_rawDescGZIP( return file_external_infra_proxy_migrations_response_migrations_proto_rawDescData } -var file_external_infra_proxy_migrations_response_migrations_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_external_infra_proxy_migrations_response_migrations_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_external_infra_proxy_migrations_response_migrations_proto_goTypes = []interface{}{ (*UploadZipFileResponse)(nil), // 0: chef.automate.api.infra_proxy.migrations.response.UploadZipFileResponse (*GetMigrationStatusResponse)(nil), // 1: chef.automate.api.infra_proxy.migrations.response.GetMigrationStatusResponse @@ -588,6 +639,7 @@ var file_external_infra_proxy_migrations_response_migrations_proto_goTypes = []i (*GetStagedDataResponse)(nil), // 3: chef.automate.api.infra_proxy.migrations.response.GetStagedDataResponse (*StagedData)(nil), // 4: chef.automate.api.infra_proxy.migrations.response.StagedData (*User)(nil), // 5: chef.automate.api.infra_proxy.migrations.response.user + (*ConfirmPreview)(nil), // 6: chef.automate.api.infra_proxy.migrations.response.ConfirmPreview } var file_external_infra_proxy_migrations_response_migrations_proto_depIdxs = []int32{ 4, // 0: chef.automate.api.infra_proxy.migrations.response.GetStagedDataResponse.staged_data:type_name -> chef.automate.api.infra_proxy.migrations.response.StagedData @@ -677,6 +729,18 @@ func file_external_infra_proxy_migrations_response_migrations_proto_init() { return nil } } + file_external_infra_proxy_migrations_response_migrations_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConfirmPreview); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -684,7 +748,7 @@ func file_external_infra_proxy_migrations_response_migrations_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_external_infra_proxy_migrations_response_migrations_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 7, NumExtensions: 0, NumServices: 0, }, diff --git a/api/external/infra_proxy/migrations/response/migrations.proto b/api/external/infra_proxy/migrations/response/migrations.proto index 42a6fb769c1..9408653496a 100644 --- a/api/external/infra_proxy/migrations/response/migrations.proto +++ b/api/external/infra_proxy/migrations/response/migrations.proto @@ -71,3 +71,8 @@ message user { // user is admin or not bool is_admin=10; } + +message ConfirmPreview { + // Migration ID + string migration_id = 1; +} diff --git a/api/interservice/infra_proxy/migrations/request/migrations.pb.go b/api/interservice/infra_proxy/migrations/request/migrations.pb.go index f46900395b0..37a89c12182 100644 --- a/api/interservice/infra_proxy/migrations/request/migrations.pb.go +++ b/api/interservice/infra_proxy/migrations/request/migrations.pb.go @@ -359,6 +359,63 @@ func (x *GetStagedDataRequest) GetMigrationId() string { return "" } +type ConfirmPreview struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Chef Server ID + ServerId string `protobuf:"bytes,1,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty" toml:"server_id,omitempty" mapstructure:"server_id,omitempty"` + // Migration ID + MigrationId string `protobuf:"bytes,2,opt,name=migration_id,json=migrationId,proto3" json:"migration_id,omitempty" toml:"migration_id,omitempty" mapstructure:"migration_id,omitempty"` +} + +func (x *ConfirmPreview) Reset() { + *x = ConfirmPreview{} + if protoimpl.UnsafeEnabled { + mi := &file_interservice_infra_proxy_migrations_request_migrations_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConfirmPreview) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfirmPreview) ProtoMessage() {} + +func (x *ConfirmPreview) ProtoReflect() protoreflect.Message { + mi := &file_interservice_infra_proxy_migrations_request_migrations_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfirmPreview.ProtoReflect.Descriptor instead. +func (*ConfirmPreview) Descriptor() ([]byte, []int) { + return file_interservice_infra_proxy_migrations_request_migrations_proto_rawDescGZIP(), []int{6} +} + +func (x *ConfirmPreview) GetServerId() string { + if x != nil { + return x.ServerId + } + return "" +} + +func (x *ConfirmPreview) GetMigrationId() string { + if x != nil { + return x.MigrationId + } + return "" +} + var File_interservice_infra_proxy_migrations_request_migrations_proto protoreflect.FileDescriptor var file_interservice_infra_proxy_migrations_request_migrations_proto_rawDesc = []byte{ @@ -403,13 +460,18 @@ var file_interservice_infra_proxy_migrations_request_migrations_proto_rawDesc = 0x49, 0x64, 0x22, 0x39, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x67, 0x65, 0x64, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0b, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x4a, 0x5a, - 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x65, 0x66, - 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x69, 0x6e, 0x66, 0x72, 0x61, - 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x2f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x52, 0x0b, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x50, 0x0a, + 0x0e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x12, + 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, + 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0b, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, + 0x4a, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, + 0x65, 0x66, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x69, 0x6e, 0x66, + 0x72, 0x61, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x2f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -424,7 +486,7 @@ func file_interservice_infra_proxy_migrations_request_migrations_proto_rawDescGZ return file_interservice_infra_proxy_migrations_request_migrations_proto_rawDescData } -var file_interservice_infra_proxy_migrations_request_migrations_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_interservice_infra_proxy_migrations_request_migrations_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_interservice_infra_proxy_migrations_request_migrations_proto_goTypes = []interface{}{ (*UploadZipFileRequest)(nil), // 0: chef.automate.domain.infra_proxy.migrations.request.UploadZipFileRequest (*Metadata)(nil), // 1: chef.automate.domain.infra_proxy.migrations.request.Metadata @@ -432,6 +494,7 @@ var file_interservice_infra_proxy_migrations_request_migrations_proto_goTypes = (*GetMigrationStatusRequest)(nil), // 3: chef.automate.domain.infra_proxy.migrations.request.GetMigrationStatusRequest (*CancelMigrationRequest)(nil), // 4: chef.automate.domain.infra_proxy.migrations.request.CancelMigrationRequest (*GetStagedDataRequest)(nil), // 5: chef.automate.domain.infra_proxy.migrations.request.GetStagedDataRequest + (*ConfirmPreview)(nil), // 6: chef.automate.domain.infra_proxy.migrations.request.ConfirmPreview } var file_interservice_infra_proxy_migrations_request_migrations_proto_depIdxs = []int32{ 2, // 0: chef.automate.domain.infra_proxy.migrations.request.UploadZipFileRequest.chunk:type_name -> chef.automate.domain.infra_proxy.migrations.request.Chunk @@ -521,6 +584,18 @@ func file_interservice_infra_proxy_migrations_request_migrations_proto_init() { return nil } } + file_interservice_infra_proxy_migrations_request_migrations_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConfirmPreview); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -528,7 +603,7 @@ func file_interservice_infra_proxy_migrations_request_migrations_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_interservice_infra_proxy_migrations_request_migrations_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 7, NumExtensions: 0, NumServices: 0, }, diff --git a/api/interservice/infra_proxy/migrations/request/migrations.proto b/api/interservice/infra_proxy/migrations/request/migrations.proto index 5095f7a025b..b014ea9a92d 100644 --- a/api/interservice/infra_proxy/migrations/request/migrations.proto +++ b/api/interservice/infra_proxy/migrations/request/migrations.proto @@ -42,5 +42,12 @@ message CancelMigrationRequest { message GetStagedDataRequest { // Migration ID - string migration_id = 1; + string migration_id = 1; +} + +message ConfirmPreview { + // Chef Server ID + string server_id = 1; + // Migration ID + string migration_id = 2; } diff --git a/api/interservice/infra_proxy/migrations/response/migrations.pb.go b/api/interservice/infra_proxy/migrations/response/migrations.pb.go index 21fe84961b0..626eae25e84 100644 --- a/api/interservice/infra_proxy/migrations/response/migrations.pb.go +++ b/api/interservice/infra_proxy/migrations/response/migrations.pb.go @@ -484,6 +484,54 @@ func (x *User) GetIsAdmin() bool { return false } +type ConfirmPreview struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Migration ID + MigrationId string `protobuf:"bytes,1,opt,name=migration_id,json=migrationId,proto3" json:"migration_id,omitempty" toml:"migration_id,omitempty" mapstructure:"migration_id,omitempty"` +} + +func (x *ConfirmPreview) Reset() { + *x = ConfirmPreview{} + if protoimpl.UnsafeEnabled { + mi := &file_interservice_infra_proxy_migrations_response_migrations_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConfirmPreview) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfirmPreview) ProtoMessage() {} + +func (x *ConfirmPreview) ProtoReflect() protoreflect.Message { + mi := &file_interservice_infra_proxy_migrations_response_migrations_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfirmPreview.ProtoReflect.Descriptor instead. +func (*ConfirmPreview) Descriptor() ([]byte, []int) { + return file_interservice_infra_proxy_migrations_response_migrations_proto_rawDescGZIP(), []int{6} +} + +func (x *ConfirmPreview) GetMigrationId() string { + if x != nil { + return x.MigrationId + } + return "" +} + var File_interservice_infra_proxy_migrations_response_migrations_proto protoreflect.FileDescriptor var file_interservice_infra_proxy_migrations_response_migrations_proto_rawDesc = []byte{ @@ -561,12 +609,15 @@ var file_interservice_infra_proxy_migrations_response_migrations_proto_rawDesc = 0x6e, 0x67, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x69, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x6c, 0x69, 0x63, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x41, 0x64, 0x6d, - 0x69, 0x6e, 0x42, 0x4b, 0x5a, 0x49, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x68, 0x65, 0x66, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x65, 0x2f, 0x61, - 0x70, 0x69, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, - 0x69, 0x6e, 0x66, 0x72, 0x61, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x6d, 0x69, 0x67, 0x72, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x69, 0x6e, 0x22, 0x33, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x50, 0x72, 0x65, + 0x76, 0x69, 0x65, 0x77, 0x12, 0x21, 0x0a, 0x0c, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6d, 0x69, 0x67, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x4b, 0x5a, 0x49, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x65, 0x66, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x6d, + 0x61, 0x74, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x2f, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, + 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -581,7 +632,7 @@ func file_interservice_infra_proxy_migrations_response_migrations_proto_rawDescG return file_interservice_infra_proxy_migrations_response_migrations_proto_rawDescData } -var file_interservice_infra_proxy_migrations_response_migrations_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_interservice_infra_proxy_migrations_response_migrations_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_interservice_infra_proxy_migrations_response_migrations_proto_goTypes = []interface{}{ (*UploadZipFileResponse)(nil), // 0: chef.automate.domain.infra_proxy.migrations.response.UploadZipFileResponse (*GetMigrationStatusResponse)(nil), // 1: chef.automate.domain.infra_proxy.migrations.response.GetMigrationStatusResponse @@ -589,6 +640,7 @@ var file_interservice_infra_proxy_migrations_response_migrations_proto_goTypes = (*GetStagedDataResponse)(nil), // 3: chef.automate.domain.infra_proxy.migrations.response.GetStagedDataResponse (*StagedData)(nil), // 4: chef.automate.domain.infra_proxy.migrations.response.StagedData (*User)(nil), // 5: chef.automate.domain.infra_proxy.migrations.response.user + (*ConfirmPreview)(nil), // 6: chef.automate.domain.infra_proxy.migrations.response.ConfirmPreview } var file_interservice_infra_proxy_migrations_response_migrations_proto_depIdxs = []int32{ 4, // 0: chef.automate.domain.infra_proxy.migrations.response.GetStagedDataResponse.staged_data:type_name -> chef.automate.domain.infra_proxy.migrations.response.StagedData @@ -678,6 +730,18 @@ func file_interservice_infra_proxy_migrations_response_migrations_proto_init() { return nil } } + file_interservice_infra_proxy_migrations_response_migrations_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConfirmPreview); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -685,7 +749,7 @@ func file_interservice_infra_proxy_migrations_response_migrations_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_interservice_infra_proxy_migrations_response_migrations_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 7, NumExtensions: 0, NumServices: 0, }, diff --git a/api/interservice/infra_proxy/migrations/response/migrations.proto b/api/interservice/infra_proxy/migrations/response/migrations.proto index 92305b86ef4..c6809d6b2a4 100644 --- a/api/interservice/infra_proxy/migrations/response/migrations.proto +++ b/api/interservice/infra_proxy/migrations/response/migrations.proto @@ -70,3 +70,8 @@ message user { // user is admin or not bool is_admin=10; } + +message ConfirmPreview { + // Migration ID + string migration_id = 1; +} diff --git a/api/interservice/infra_proxy/migrations/service/migrations.pb.go b/api/interservice/infra_proxy/migrations/service/migrations.pb.go index cf41cd8f429..07357504e41 100644 --- a/api/interservice/infra_proxy/migrations/service/migrations.pb.go +++ b/api/interservice/infra_proxy/migrations/service/migrations.pb.go @@ -50,8 +50,8 @@ var file_interservice_infra_proxy_migrations_service_migrations_proto_rawDesc = 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2f, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, - 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xda, - 0x05, 0x0a, 0x14, 0x4d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x61, 0x74, 0x61, + 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xfa, + 0x06, 0x0a, 0x14, 0x4d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x61, 0x74, 0x61, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xa8, 0x01, 0x0a, 0x0a, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x49, 0x2e, 0x63, 0x68, 0x65, 0x66, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x65, 0x2e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x69, 0x6e, @@ -96,7 +96,17 @@ var file_interservice_infra_proxy_migrations_service_migrations_proto_rawDesc = 0x61, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x67, 0x65, 0x64, 0x44, 0x61, 0x74, - 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x4a, 0x5a, 0x48, 0x67, + 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x9d, 0x01, 0x0a, 0x0e, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x12, 0x43, + 0x2e, 0x63, 0x68, 0x65, 0x66, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x65, 0x2e, 0x64, + 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x5f, 0x70, 0x72, 0x6f, 0x78, + 0x79, 0x2e, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x50, 0x72, 0x65, 0x76, + 0x69, 0x65, 0x77, 0x1a, 0x44, 0x2e, 0x63, 0x68, 0x65, 0x66, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6d, + 0x61, 0x74, 0x65, 0x2e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x66, 0x72, 0x61, + 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x2e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x72, 0x6d, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x22, 0x00, 0x42, 0x4a, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x65, 0x66, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x5f, 0x70, @@ -109,22 +119,26 @@ var file_interservice_infra_proxy_migrations_service_migrations_proto_goTypes = (*request.GetMigrationStatusRequest)(nil), // 1: chef.automate.domain.infra_proxy.migrations.request.GetMigrationStatusRequest (*request.CancelMigrationRequest)(nil), // 2: chef.automate.domain.infra_proxy.migrations.request.CancelMigrationRequest (*request.GetStagedDataRequest)(nil), // 3: chef.automate.domain.infra_proxy.migrations.request.GetStagedDataRequest - (*response.UploadZipFileResponse)(nil), // 4: chef.automate.domain.infra_proxy.migrations.response.UploadZipFileResponse - (*response.GetMigrationStatusResponse)(nil), // 5: chef.automate.domain.infra_proxy.migrations.response.GetMigrationStatusResponse - (*response.CancelMigrationResponse)(nil), // 6: chef.automate.domain.infra_proxy.migrations.response.CancelMigrationResponse - (*response.GetStagedDataResponse)(nil), // 7: chef.automate.domain.infra_proxy.migrations.response.GetStagedDataResponse + (*request.ConfirmPreview)(nil), // 4: chef.automate.domain.infra_proxy.migrations.request.ConfirmPreview + (*response.UploadZipFileResponse)(nil), // 5: chef.automate.domain.infra_proxy.migrations.response.UploadZipFileResponse + (*response.GetMigrationStatusResponse)(nil), // 6: chef.automate.domain.infra_proxy.migrations.response.GetMigrationStatusResponse + (*response.CancelMigrationResponse)(nil), // 7: chef.automate.domain.infra_proxy.migrations.response.CancelMigrationResponse + (*response.GetStagedDataResponse)(nil), // 8: chef.automate.domain.infra_proxy.migrations.response.GetStagedDataResponse + (*response.ConfirmPreview)(nil), // 9: chef.automate.domain.infra_proxy.migrations.response.ConfirmPreview } var file_interservice_infra_proxy_migrations_service_migrations_proto_depIdxs = []int32{ 0, // 0: chef.automate.domain.infra_proxy.migrations.service.MigrationDataService.UploadFile:input_type -> chef.automate.domain.infra_proxy.migrations.request.UploadZipFileRequest 1, // 1: chef.automate.domain.infra_proxy.migrations.service.MigrationDataService.GetMigrationStatus:input_type -> chef.automate.domain.infra_proxy.migrations.request.GetMigrationStatusRequest 2, // 2: chef.automate.domain.infra_proxy.migrations.service.MigrationDataService.CancelMigration:input_type -> chef.automate.domain.infra_proxy.migrations.request.CancelMigrationRequest 3, // 3: chef.automate.domain.infra_proxy.migrations.service.MigrationDataService.GetStagedData:input_type -> chef.automate.domain.infra_proxy.migrations.request.GetStagedDataRequest - 4, // 4: chef.automate.domain.infra_proxy.migrations.service.MigrationDataService.UploadFile:output_type -> chef.automate.domain.infra_proxy.migrations.response.UploadZipFileResponse - 5, // 5: chef.automate.domain.infra_proxy.migrations.service.MigrationDataService.GetMigrationStatus:output_type -> chef.automate.domain.infra_proxy.migrations.response.GetMigrationStatusResponse - 6, // 6: chef.automate.domain.infra_proxy.migrations.service.MigrationDataService.CancelMigration:output_type -> chef.automate.domain.infra_proxy.migrations.response.CancelMigrationResponse - 7, // 7: chef.automate.domain.infra_proxy.migrations.service.MigrationDataService.GetStagedData:output_type -> chef.automate.domain.infra_proxy.migrations.response.GetStagedDataResponse - 4, // [4:8] is the sub-list for method output_type - 0, // [0:4] is the sub-list for method input_type + 4, // 4: chef.automate.domain.infra_proxy.migrations.service.MigrationDataService.ConfirmPreview:input_type -> chef.automate.domain.infra_proxy.migrations.request.ConfirmPreview + 5, // 5: chef.automate.domain.infra_proxy.migrations.service.MigrationDataService.UploadFile:output_type -> chef.automate.domain.infra_proxy.migrations.response.UploadZipFileResponse + 6, // 6: chef.automate.domain.infra_proxy.migrations.service.MigrationDataService.GetMigrationStatus:output_type -> chef.automate.domain.infra_proxy.migrations.response.GetMigrationStatusResponse + 7, // 7: chef.automate.domain.infra_proxy.migrations.service.MigrationDataService.CancelMigration:output_type -> chef.automate.domain.infra_proxy.migrations.response.CancelMigrationResponse + 8, // 8: chef.automate.domain.infra_proxy.migrations.service.MigrationDataService.GetStagedData:output_type -> chef.automate.domain.infra_proxy.migrations.response.GetStagedDataResponse + 9, // 9: chef.automate.domain.infra_proxy.migrations.service.MigrationDataService.ConfirmPreview:output_type -> chef.automate.domain.infra_proxy.migrations.response.ConfirmPreview + 5, // [5:10] is the sub-list for method output_type + 0, // [0:5] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name @@ -170,6 +184,7 @@ type MigrationDataServiceClient interface { GetMigrationStatus(ctx context.Context, in *request.GetMigrationStatusRequest, opts ...grpc.CallOption) (*response.GetMigrationStatusResponse, error) CancelMigration(ctx context.Context, in *request.CancelMigrationRequest, opts ...grpc.CallOption) (*response.CancelMigrationResponse, error) GetStagedData(ctx context.Context, in *request.GetStagedDataRequest, opts ...grpc.CallOption) (*response.GetStagedDataResponse, error) + ConfirmPreview(ctx context.Context, in *request.ConfirmPreview, opts ...grpc.CallOption) (*response.ConfirmPreview, error) } type migrationDataServiceClient struct { @@ -241,12 +256,22 @@ func (c *migrationDataServiceClient) GetStagedData(ctx context.Context, in *requ return out, nil } +func (c *migrationDataServiceClient) ConfirmPreview(ctx context.Context, in *request.ConfirmPreview, opts ...grpc.CallOption) (*response.ConfirmPreview, error) { + out := new(response.ConfirmPreview) + err := c.cc.Invoke(ctx, "/chef.automate.domain.infra_proxy.migrations.service.MigrationDataService/ConfirmPreview", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MigrationDataServiceServer is the server API for MigrationDataService service. type MigrationDataServiceServer interface { UploadFile(MigrationDataService_UploadFileServer) error GetMigrationStatus(context.Context, *request.GetMigrationStatusRequest) (*response.GetMigrationStatusResponse, error) CancelMigration(context.Context, *request.CancelMigrationRequest) (*response.CancelMigrationResponse, error) GetStagedData(context.Context, *request.GetStagedDataRequest) (*response.GetStagedDataResponse, error) + ConfirmPreview(context.Context, *request.ConfirmPreview) (*response.ConfirmPreview, error) } // UnimplementedMigrationDataServiceServer can be embedded to have forward compatible implementations. @@ -265,6 +290,9 @@ func (*UnimplementedMigrationDataServiceServer) CancelMigration(context.Context, func (*UnimplementedMigrationDataServiceServer) GetStagedData(context.Context, *request.GetStagedDataRequest) (*response.GetStagedDataResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetStagedData not implemented") } +func (*UnimplementedMigrationDataServiceServer) ConfirmPreview(context.Context, *request.ConfirmPreview) (*response.ConfirmPreview, error) { + return nil, status.Errorf(codes.Unimplemented, "method ConfirmPreview not implemented") +} func RegisterMigrationDataServiceServer(s *grpc.Server, srv MigrationDataServiceServer) { s.RegisterService(&_MigrationDataService_serviceDesc, srv) @@ -350,6 +378,24 @@ func _MigrationDataService_GetStagedData_Handler(srv interface{}, ctx context.Co return interceptor(ctx, in, info, handler) } +func _MigrationDataService_ConfirmPreview_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(request.ConfirmPreview) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MigrationDataServiceServer).ConfirmPreview(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/chef.automate.domain.infra_proxy.migrations.service.MigrationDataService/ConfirmPreview", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MigrationDataServiceServer).ConfirmPreview(ctx, req.(*request.ConfirmPreview)) + } + return interceptor(ctx, in, info, handler) +} + var _MigrationDataService_serviceDesc = grpc.ServiceDesc{ ServiceName: "chef.automate.domain.infra_proxy.migrations.service.MigrationDataService", HandlerType: (*MigrationDataServiceServer)(nil), @@ -366,6 +412,10 @@ var _MigrationDataService_serviceDesc = grpc.ServiceDesc{ MethodName: "GetStagedData", Handler: _MigrationDataService_GetStagedData_Handler, }, + { + MethodName: "ConfirmPreview", + Handler: _MigrationDataService_ConfirmPreview_Handler, + }, }, Streams: []grpc.StreamDesc{ { diff --git a/api/interservice/infra_proxy/migrations/service/migrations.proto b/api/interservice/infra_proxy/migrations/service/migrations.proto index 5af38fbe07b..6e809629b1b 100644 --- a/api/interservice/infra_proxy/migrations/service/migrations.proto +++ b/api/interservice/infra_proxy/migrations/service/migrations.proto @@ -13,4 +13,5 @@ service MigrationDataService{ rpc GetMigrationStatus (chef.automate.domain.infra_proxy.migrations.request.GetMigrationStatusRequest) returns (chef.automate.domain.infra_proxy.migrations.response.GetMigrationStatusResponse) {}; rpc CancelMigration (chef.automate.domain.infra_proxy.migrations.request.CancelMigrationRequest) returns (chef.automate.domain.infra_proxy.migrations.response.CancelMigrationResponse) {}; rpc GetStagedData (chef.automate.domain.infra_proxy.migrations.request.GetStagedDataRequest) returns (chef.automate.domain.infra_proxy.migrations.response.GetStagedDataResponse) {}; + rpc ConfirmPreview (chef.automate.domain.infra_proxy.migrations.request.ConfirmPreview) returns (chef.automate.domain.infra_proxy.migrations.response.ConfirmPreview) {}; } diff --git a/components/automate-gateway/api/migrations.pb.swagger.go b/components/automate-gateway/api/migrations.pb.swagger.go index 98cbf681f8e..b914b07afe2 100644 --- a/components/automate-gateway/api/migrations.pb.swagger.go +++ b/components/automate-gateway/api/migrations.pb.swagger.go @@ -113,6 +113,44 @@ func init() { "InfraProxyMigration" ] } + }, + "/api/v0/infra/servers/{server_id}/migrations/confirm_preview/{migration_id}": { + "get": { + "operationId": "InfraProxyMigration_ConfirmPreview", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/chef.automate.api.infra_proxy.migrations.response.ConfirmPreview" + } + }, + "default": { + "description": "An unexpected error response", + "schema": { + "$ref": "#/definitions/grpc.gateway.runtime.Error" + } + } + }, + "parameters": [ + { + "name": "server_id", + "description": "Chef Server ID", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "migration_id", + "description": "Migration ID", + "in": "path", + "required": true, + "type": "string" + } + ], + "tags": [ + "InfraProxyMigration" + ] + } } }, "definitions": { @@ -133,6 +171,15 @@ func init() { } } }, + "chef.automate.api.infra_proxy.migrations.response.ConfirmPreview": { + "type": "object", + "properties": { + "migration_id": { + "type": "string", + "title": "Migration ID" + } + } + }, "chef.automate.api.infra_proxy.migrations.response.GetMigrationStatusResponse": { "type": "object", "properties": { diff --git a/components/automate-gateway/handler/infra_proxy/migrations/migrations.go b/components/automate-gateway/handler/infra_proxy/migrations/migrations.go index cfcfbdc51a6..f8e392f330f 100644 --- a/components/automate-gateway/handler/infra_proxy/migrations/migrations.go +++ b/components/automate-gateway/handler/infra_proxy/migrations/migrations.go @@ -89,3 +89,18 @@ func getStagedUser(user *infra_res.User) *gwres.User { stagedUser.IsAdmin = user.IsAdmin return stagedUser } + +// ConfirmPreview trigger the pipline function +func (a *InfraProxyMigrationServer) ConfirmPreview(ctx context.Context, r *gwreq.ConfirmPreview) (*gwres.ConfirmPreview, error) { + req := &infra_req.ConfirmPreview{ + MigrationId: r.MigrationId, + } + res, err := a.migrationClient.ConfirmPreview(ctx, req) + if err != nil { + return nil, err + } + + return &gwres.ConfirmPreview{ + MigrationId: res.MigrationId, + }, nil +} diff --git a/components/infra-proxy-service/migrations/migrations.go b/components/infra-proxy-service/migrations/migrations.go index 1ff3b45873a..cd7a29ac475 100644 --- a/components/infra-proxy-service/migrations/migrations.go +++ b/components/infra-proxy-service/migrations/migrations.go @@ -8,8 +8,6 @@ import ( "os" "path" - "github.com/chef/automate/components/infra-proxy-service/pipeline" - "github.com/chef/automate/api/interservice/infra_proxy/migrations/request" "github.com/chef/automate/api/interservice/infra_proxy/migrations/response" "github.com/chef/automate/api/interservice/infra_proxy/migrations/service" @@ -32,13 +30,24 @@ func (s *MigrationServer) UploadFile(stream service.MigrationDataService_UploadF if err != nil { log.WithError(err).Error("Unable to create migration id") res := handleErrorForUploadFileAndMigration(err, migrationId, serverId, s, ctx) - stream.SendAndClose(res) + errStream := stream.SendAndClose(res) + if errStream != nil { + log.Errorf("Failed to send and close strean file for migration id %s : %s", migrationId, err.Error()) + } return err } log.Info("Starting with migration phase with the upload file for migration id: ", migrationId) _, err = s.service.Migration.StartMigration(ctx, migrationId, serverId) + if err != nil { + log.Errorf("Unable to insert the migration status Start Migration for migration id : %s", migrationId) + return err + } fileData := bytes.Buffer{} - s.service.Migration.StartFileUpload(ctx, migrationId, serverId) + _, err = s.service.Migration.StartFileUpload(ctx, migrationId, serverId) + if err != nil { + log.Errorf("Unable to insert the migration status Start File upload for migration id : %s", migrationId) + return err + } for { req, err := stream.Recv() @@ -49,7 +58,10 @@ func (s *MigrationServer) UploadFile(stream service.MigrationDataService_UploadF if err != nil { log.Errorf("Failed to upload file for migration id %s : %s", migrationId, err.Error()) res := handleErrorForUploadFileAndMigration(err, migrationId, serverId, s, ctx) - stream.SendAndClose(res) + errStream := stream.SendAndClose(res) + if errStream != nil { + log.Errorf("Failed to send and close strean file for migration id %s : %s", migrationId, err.Error()) + } return err } @@ -58,7 +70,10 @@ func (s *MigrationServer) UploadFile(stream service.MigrationDataService_UploadF if err != nil { log.Errorf("Failed to upload file for migration id %s : %s", migrationId, err.Error()) res := handleErrorForUploadFileAndMigration(err, migrationId, serverId, s, ctx) - stream.SendAndClose(res) + errStream := stream.SendAndClose(res) + if errStream != nil { + log.Errorf("Failed to send and close strean file for migration id %s : %s", migrationId, err.Error()) + } return err } } @@ -67,7 +82,10 @@ func (s *MigrationServer) UploadFile(stream service.MigrationDataService_UploadF if err != nil { log.Errorf("Failed to save uploaded file for migration id %s : %s", migrationId, err.Error()) res := handleErrorForUploadFileAndMigration(err, migrationId, serverId, s, ctx) - stream.SendAndClose(res) + errStream := stream.SendAndClose(res) + if errStream != nil { + log.Errorf("Failed to send and close strean file for migration id %s : %s", migrationId, err.Error()) + } return err } log.Info("File successfully saved in the directory for the requested file for migration id: ", migrationId) @@ -76,7 +94,7 @@ func (s *MigrationServer) UploadFile(stream service.MigrationDataService_UploadF MigrationId: migrationId, Success: true, } - s.service.Migration.CompleteFileUpload(ctx, migrationId, serverId, 0, 0, 0) + _, _ = s.service.Migration.CompleteFileUpload(ctx, migrationId, serverId, 0, 0, 0) log.Info("File successfully uploaded in the directory for the requested file for migration id: ", migrationId) err = stream.SendAndClose(res) if err != nil { @@ -85,8 +103,8 @@ func (s *MigrationServer) UploadFile(stream service.MigrationDataService_UploadF return err } - pipelineResult := pipeline.Result{Meta: pipeline.Meta{ZipFile: fileName}} - s.phaseOnePipeline.Run(pipelineResult) + pipelineResult := pipeline_model.Result{Meta: pipeline_model.Meta{ZipFile: fileName}} + go s.phaseOnePipeline.Run(pipelineResult) return nil } @@ -152,9 +170,9 @@ func createMigrationId() (string, error) { //handleErrorForUploadFileAndMigration handles the error for the file upload func handleErrorForUploadFileAndMigration(err error, migrationId string, serviceId string, s *MigrationServer, ctx context.Context) *response.UploadZipFileResponse { response := createResponseWithErrors(err, migrationId) - s.service.Migration.FailedFileUpload(ctx, migrationId, serviceId, err.Error(), 0, 0, 0) + _, _ = s.service.Migration.FailedFileUpload(ctx, migrationId, serviceId, err.Error(), 0, 0, 0) //ToDo to add the Failed migration status as well - s.service.Migration.FailedMigration(ctx, migrationId, serviceId, err.Error(), 0, 0, 0) + _, _ = s.service.Migration.FailedMigration(ctx, migrationId, serviceId, err.Error(), 0, 0, 0) return response } @@ -192,21 +210,21 @@ func (s *MigrationServer) CancelMigration(ctx context.Context, req *request.Canc folderPath := path.Join("/hab/svc/infra-proxy-service/data", req.MigrationId) err = os.RemoveAll(folderPath) if err != nil { - s.service.Migration.FailedCancelMigration(ctx, req.MigrationId, req.ServerId, err.Error(), 0, 0, 0) + _, _ = s.service.Migration.FailedCancelMigration(ctx, req.MigrationId, req.ServerId, err.Error(), 0, 0, 0) return nil, err } // Clear up the stage table _, err = s.service.Migration.DeleteMigrationStage(ctx, req.MigrationId) if err != nil { - s.service.Migration.FailedCancelMigration(ctx, req.MigrationId, req.ServerId, err.Error(), 0, 0, 0) + _, _ = s.service.Migration.FailedCancelMigration(ctx, req.MigrationId, req.ServerId, err.Error(), 0, 0, 0) return nil, err } // Update the migration status _, err = s.service.Migration.CancelMigration(ctx, req.MigrationId, req.ServerId, 0, 0, 0) if err != nil { - s.service.Migration.FailedCancelMigration(ctx, req.MigrationId, req.ServerId, err.Error(), 0, 0, 0) + _, _ = s.service.Migration.FailedCancelMigration(ctx, req.MigrationId, req.ServerId, err.Error(), 0, 0, 0) return nil, err } @@ -294,3 +312,29 @@ func (s *MigrationServer) StoreStagedData(ctx context.Context, migrationId strin return nil } + +// ConfirmPreview trigger the preview pipline +func (s *MigrationServer) ConfirmPreview(ctx context.Context, req *request.ConfirmPreview) (*response.ConfirmPreview, error) { + // Validate all request fields are required + err := validation.New(validation.Options{ + Target: "server", + Request: *req, + RequiredDefault: true, + }).Validate() + + if err != nil { + return nil, err + } + + migrationStage, err := s.service.Migration.GetMigrationStage(ctx, req.MigrationId) + if err != nil { + return nil, err + } + + // call pipeline function to trigger the phase 2 pipeline + go s.phaseTwoPipeline.Run(migrationStage.StagedData) + + return &response.ConfirmPreview{ + MigrationId: req.MigrationId, + }, nil +} diff --git a/components/infra-proxy-service/migrations/pipeline/phaseonemigration.go b/components/infra-proxy-service/migrations/pipeline/phaseonemigration.go index eeb5ca405ea..8f1e1854bcd 100644 --- a/components/infra-proxy-service/migrations/pipeline/phaseonemigration.go +++ b/components/infra-proxy-service/migrations/pipeline/phaseonemigration.go @@ -2,7 +2,6 @@ package pipeline import ( "context" - "fmt" log "github.com/sirupsen/logrus" @@ -35,7 +34,7 @@ func UnzipSrc() PhaseOnePipelineProcessor { } func unzip(result <-chan PipelineData) <-chan PipelineData { - fmt.Println("Starting unzip pipeline") + log.Info("Starting unzip pipeline") out := make(chan PipelineData, 100) go func() { @@ -47,7 +46,7 @@ func unzip(result <-chan PipelineData) <-chan PipelineData { res.Done <- nil } } - fmt.Println("Closing unzip") + log.Info("Closing unzip") close(out) }() return out @@ -61,21 +60,21 @@ func ParseOrg() PhaseOnePipelineProcessor { } func parseOrg(result <-chan PipelineData) <-chan PipelineData { - fmt.Println("Starting to parse_orgs pipeline") + log.Info("Starting to parse_orgs pipeline") out := make(chan PipelineData, 100) go func() { - fmt.Println("Processing to parse orgs...") + log.Info("Processing to parse orgs...") for res := range result { select { case out <- res: case <-res.Ctx.Done(): res.Done <- nil } - fmt.Println("after write") + log.Info("after write") } - fmt.Println("CLosing parse_orgs pipeline") + log.Info("CLosing parse_orgs pipeline") close(out) }() return out @@ -89,12 +88,12 @@ func ParseUser() PhaseOnePipelineProcessor { } func parseUser(result <-chan PipelineData) <-chan PipelineData { - fmt.Println("Starting to parse_user pipeline") + log.Info("Starting to parse_user pipeline") out := make(chan PipelineData, 100) go func() { - fmt.Println("Processing to parse_user...") + log.Info("Processing to parse_user...") for res := range result { select { case out <- res: @@ -102,7 +101,7 @@ func parseUser(result <-chan PipelineData) <-chan PipelineData { res.Done <- nil } } - fmt.Println("Closing parse_user") + log.Info("Closing parse_user") close(out) }() @@ -117,12 +116,12 @@ func ConflictingUsers() PhaseOnePipelineProcessor { } func conflictingUsers(result <-chan PipelineData) <-chan PipelineData { - fmt.Println("Starting to conflicting_user check pipeline") + log.Info("Starting to conflicting_user check pipeline") out := make(chan PipelineData, 100) go func() { - fmt.Println("Processing to conflicting_user users...") + log.Info("Processing to conflicting_user users...") for res := range result { select { @@ -131,7 +130,7 @@ func conflictingUsers(result <-chan PipelineData) <-chan PipelineData { res.Done <- nil } } - fmt.Println("Closing conflicting_user") + log.Info("Closing conflicting_user") close(out) }() @@ -147,12 +146,12 @@ func OrgMembers() PhaseOnePipelineProcessor { } func orgMembers(result <-chan PipelineData) <-chan PipelineData { - fmt.Println("Starting to org_user check pipeline") + log.Info("Starting to org_user check pipeline") out := make(chan PipelineData, 100) go func() { - fmt.Println("Processing to check org_user association...") + log.Info("Processing to check org_user association...") for res := range result { select { case out <- res: @@ -160,7 +159,7 @@ func orgMembers(result <-chan PipelineData) <-chan PipelineData { res.Done <- nil } } - fmt.Println("Closing org_user association check") + log.Info("Closing org_user association check") close(out) }() @@ -176,12 +175,12 @@ func AdminUsers() PhaseOnePipelineProcessor { } func adminUsers(result <-chan PipelineData) <-chan PipelineData { - fmt.Println("Starting org admin_users check ") + log.Info("Starting org admin_users check ") out := make(chan PipelineData, 100) go func() { - fmt.Println("Processing to to check admin_users...") + log.Info("Processing to to check admin_users...") for res := range result { select { case out <- res: @@ -189,7 +188,7 @@ func adminUsers(result <-chan PipelineData) <-chan PipelineData { res.Done <- nil } } - fmt.Println("Closing admin_users") + log.Info("Closing admin_users") close(out) }() @@ -198,7 +197,7 @@ func adminUsers(result <-chan PipelineData) <-chan PipelineData { } func migrationPipeline(source <-chan PipelineData, pipes ...PhaseOnePipelineProcessor) { - fmt.Println("Pipeline started...") + log.Info("Pipeline started...") status := make(chan string) go func() { for _, pipe := range pipes { @@ -227,23 +226,18 @@ func SetupPhaseOnePipeline() PhaseOnePipleine { } func (p *PhaseOnePipleine) Run(result pipeline.Result) { - status := make(chan string) - go func() { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - done := make(chan error) - select { - case p.in <- PipelineData{Result: result, Done: done, Ctx: ctx}: - } - err := <-done - if err != nil { - MigrationError(err, Mig, ctx, result.Meta.MigrationID, result.Meta.ServerID) - log.Errorf("Phase one pipeline received error for migration %s: %s", result.Meta.MigrationID, err) - } - log.Println("received done") - status <- "Done" - }() - <-status + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + done := make(chan error) + select { + case p.in <- PipelineData{Result: result, Done: done, Ctx: ctx}: + } + err := <-done + if err != nil { + MigrationError(err, Mig, ctx, result.Meta.MigrationID, result.Meta.ServerID) + log.Errorf("Phase one pipeline received error for migration %s: %s", result.Meta.MigrationID, err) + } + log.Info("received done") } func MigrationError(err error, st storage.MigrationStorage, ctx context.Context, migrationId, serviceId string) { diff --git a/components/infra-proxy-service/migrations/pipeline/phasetwomigration.go b/components/infra-proxy-service/migrations/pipeline/phasetwomigration.go index 2b1512d8e67..3ae1ad42aa9 100644 --- a/components/infra-proxy-service/migrations/pipeline/phasetwomigration.go +++ b/components/infra-proxy-service/migrations/pipeline/phasetwomigration.go @@ -2,7 +2,6 @@ package pipeline import ( "context" - "fmt" log "github.com/sirupsen/logrus" @@ -23,19 +22,19 @@ func PopulateOrgs() PhaseTwoPipelineProcessor { } func populateOrgs(result <-chan PipelineData) <-chan PipelineData { - fmt.Println("Starting populateOrgs routine") + log.Info("Starting populateOrgs routine") out := make(chan PipelineData, 100) go func() { for res := range result { - fmt.Println("Processing to populateOrgs...") + log.Info("Processing to populateOrgs...") select { case out <- res: case <-res.Ctx.Done(): res.Done <- nil } } - fmt.Println("Closing populateOrgs routine") + log.Info("Closing populateOrgs routine") close(out) }() return out @@ -49,19 +48,19 @@ func CreateProject() PhaseTwoPipelineProcessor { } func createProject(result <-chan PipelineData) <-chan PipelineData { - fmt.Println("Starting CreateProject routine") + log.Info("Starting CreateProject routine") out := make(chan PipelineData, 100) go func() { for res := range result { - fmt.Println("Processing to createProject...") + log.Info("Processing to createProject...") select { case out <- res: case <-res.Ctx.Done(): res.Done <- nil } } - fmt.Println("Closing CreateProject routine") + log.Info("Closing CreateProject routine") close(out) }() return out @@ -75,19 +74,19 @@ func PopulateUsers() PhaseTwoPipelineProcessor { } func populateUsers(result <-chan PipelineData) <-chan PipelineData { - fmt.Println("Starting PopulateUsers routine") + log.Info("Starting PopulateUsers routine") out := make(chan PipelineData, 100) go func() { for res := range result { - fmt.Println("Processing to populateUsers...") + log.Info("Processing to populateUsers...") select { case out <- res: case <-res.Ctx.Done(): res.Done <- nil } } - fmt.Println("Closing PopulateUsers routine") + log.Info("Closing PopulateUsers routine") close(out) }() return out @@ -101,19 +100,19 @@ func PopulateORGUser() PhaseTwoPipelineProcessor { } func populateORGUser(result <-chan PipelineData) <-chan PipelineData { - fmt.Println("Starting PopulateORGUser routine") + log.Info("Starting PopulateORGUser routine") out := make(chan PipelineData, 100) go func() { for res := range result { - fmt.Println("Processing to populateORGUser...") + log.Info("Processing to populateORGUser...") select { case out <- res: case <-res.Ctx.Done(): res.Done <- nil } } - fmt.Println("Closing PopulateORGUser routine") + log.Info("Closing PopulateORGUser routine") close(out) }() return out @@ -127,26 +126,26 @@ func PopulateMembersPolicy() PhaseTwoPipelineProcessor { } func populateMembersPolicy(result <-chan PipelineData) <-chan PipelineData { - fmt.Println("Starting PopulateMembersPolicy routine") + log.Info("Starting PopulateMembersPolicy routine") out := make(chan PipelineData, 100) go func() { for res := range result { - fmt.Println("Processing to populateMembersPolicy...") + log.Info("Processing to populateMembersPolicy...") select { case out <- res: case <-res.Ctx.Done(): res.Done <- nil } } - fmt.Println("Closing PopulateMembersPolicy routine") + log.Info("Closing PopulateMembersPolicy routine") close(out) }() return out } func migrationTwoPipeline(source <-chan PipelineData, pipes ...PhaseTwoPipelineProcessor) { - fmt.Println("Pipeline started...") + log.Info("Pipeline started...") status := make(chan string) go func() { for _, pipe := range pipes { @@ -174,22 +173,18 @@ func SetupPhaseTwoPipeline() PhaseTwoPipleine { } func (p *PhaseTwoPipleine) Run(result pipeline.Result) { - status := make(chan string) - go func() { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - done := make(chan error) - select { - case p.in <- PipelineData{Result: result, Done: done, Ctx: ctx}: - } - err := <-done - if err != nil { - MigrationError(err, Mig, ctx, result.Meta.MigrationID, result.Meta.ServerID) - log.Errorf("Phase two pipeline received error for migration %s: %s", result.Meta.MigrationID, err) - } - MigrationSuccess(Mig, ctx, result.Meta.MigrationID, result.Meta.ServerID) - log.Println("received done") - status <- "Done" - }() - <-status + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + done := make(chan error) + select { + case p.in <- PipelineData{Result: result, Done: done, Ctx: ctx}: + } + err := <-done + if err != nil { + MigrationError(err, Mig, ctx, result.Meta.MigrationID, result.Meta.ServerID) + log.Errorf("Phase two pipeline received error for migration %s: %s", result.Meta.MigrationID, err) + } + MigrationSuccess(Mig, ctx, result.Meta.MigrationID, result.Meta.ServerID) + log.Info("received done") + } diff --git a/components/infra-proxy-service/migrations/pipeline/utility.go b/components/infra-proxy-service/migrations/pipeline/utility.go index 1cd942534c0..e55699ba5d9 100644 --- a/components/infra-proxy-service/migrations/pipeline/utility.go +++ b/components/infra-proxy-service/migrations/pipeline/utility.go @@ -67,6 +67,9 @@ func StoreOrg(ctx context.Context, st storage.Storage, org pipeline.Org, serverI return err, actionTaken } _, err = st.StoreOrg(ctx, org.Name, org.FullName, "", "", serverID, projects) + if err != nil { + log.Errorf("Unable to insert org for server id: %s", serverID) + } actionTaken = pipeline.Insert case pipeline.Delete: _, err = st.DeleteOrg(ctx, org.Name, serverID) @@ -108,21 +111,21 @@ func ParseOrgs(ctx context.Context, st storage.Storage, mst storage.MigrationSto folder, err := os.Open(orgPath) if err != nil { log.Errorf("Failed to open the folder for the file path %s : %s", orgPath, err.Error()) - mst.FailedOrgParsing(ctx, result.Meta.MigrationID, result.Meta.ServerID, err.Error(), 0, 0, 0) + _, _ = mst.FailedOrgParsing(ctx, result.Meta.MigrationID, result.Meta.ServerID, err.Error(), 0, 0, 0) return result, err } - defer folder.Close() orgNames, err := folder.Readdir(0) if err != nil { log.Errorf("Failed to read the files for the file path %s : %s", orgPath, err.Error()) - mst.FailedOrgParsing(ctx, result.Meta.MigrationID, result.Meta.ServerID, err.Error(), 0, 0, 0) + _, _ = mst.FailedOrgParsing(ctx, result.Meta.MigrationID, result.Meta.ServerID, err.Error(), 0, 0, 0) return result, err } + _ = folder.Close() orgsPresentInDB, err := st.GetOrgs(ctx, result.Meta.ServerID) if err != nil { log.Errorf("Failed to read orgs from database for %s:%s", result.Meta.ServerID, err.Error()) - mst.FailedOrgParsing(ctx, result.Meta.MigrationID, result.Meta.ServerID, err.Error(), 0, 0, 0) + _, _ = mst.FailedOrgParsing(ctx, result.Meta.MigrationID, result.Meta.ServerID, err.Error(), 0, 0, 0) return result, err } @@ -130,7 +133,7 @@ func ParseOrgs(ctx context.Context, st storage.Storage, mst storage.MigrationSto result.ParsedResult.Orgs = append(result.ParsedResult.Orgs, deleteOrgsIfNotPresentInCurrentFile(orgNames, orgsPresentInDB)...) - mst.CompleteOrgParsing(ctx, result.Meta.MigrationID, result.Meta.ServerID, 0, 0, 0) + _, err = mst.CompleteOrgParsing(ctx, result.Meta.MigrationID, result.Meta.ServerID, 0, 0, 0) if err != nil { log.Errorf("Failed to update the complete status while parsing for migration id %s : %s", result.Meta.MigrationID, err.Error()) return result, err @@ -215,10 +218,9 @@ func openOrgFolder(org os.FileInfo, fileLocation string) pipeline.OrgJson { } log.Info("Successfully opened the file at location", jsonPath) // defer the closing of our jsonFile so that we can parse it later on - defer jsonFile.Close() byteValue, _ := ioutil.ReadAll(jsonFile) - json.Unmarshal(byteValue, &orgJson) - + _ = json.Unmarshal(byteValue, &orgJson) + _ = jsonFile.Close() return orgJson } diff --git a/components/infra-proxy-service/migrations/server.go b/components/infra-proxy-service/migrations/server.go index adcfbde4e34..0f00ba828b7 100644 --- a/components/infra-proxy-service/migrations/server.go +++ b/components/infra-proxy-service/migrations/server.go @@ -8,13 +8,17 @@ import ( type MigrationServer struct { service *service.Service phaseOnePipeline pipeline.PhaseOnePipleine + phaseTwoPipeline pipeline.PhaseTwoPipleine } // NewMigrationServer returns an infra-proxy migration server func NewMigrationServer(service *service.Service) *MigrationServer { - c := pipeline.SetupPhaseOnePipeline() + phaseOnePipeline := pipeline.SetupPhaseOnePipeline() + phaseTwoPipeline := pipeline.SetupPhaseTwoPipeline() + return &MigrationServer{ service: service, - phaseOnePipeline: c, + phaseOnePipeline: phaseOnePipeline, + phaseTwoPipeline: phaseTwoPipeline, } } diff --git a/components/infra-proxy-service/pipeline/models.go b/components/infra-proxy-service/pipeline/models.go index b730e76df52..3f16370d98b 100644 --- a/components/infra-proxy-service/pipeline/models.go +++ b/components/infra-proxy-service/pipeline/models.go @@ -113,7 +113,7 @@ type User struct { // Connector ldap user Connector string `json:"connector"` - // IsConflicting for user's existance in db + // IsConflicting for user's existence in db IsConflicting bool `json:"is_conflicting"` // IsAdmin (user is admin or not) diff --git a/components/infra-proxy-service/server/servers.go b/components/infra-proxy-service/server/servers.go index c709d927f6e..b6f23895695 100644 --- a/components/infra-proxy-service/server/servers.go +++ b/components/infra-proxy-service/server/servers.go @@ -3,6 +3,7 @@ package server import ( "context" "encoding/json" + "github.com/prometheus/common/log" "io/ioutil" "github.com/chef/automate/api/external/common/query" @@ -178,6 +179,9 @@ func (s *Server) GetServer(ctx context.Context, req *request.GetServer) (*respon return nil, service.ParseStorageError(err, *req, "server") } migration, err := s.service.Migration.GetActiveMigration(ctx, req.Id) + if err != nil { + log.Errorf("Unable to fetch migration status for server id:%s", req.Id) + } resp := &response.GetServer{ Server: fromStorageServerWithMigrationDetails(server, migration), } diff --git a/components/infra-proxy-service/storage/testDB/testDB.go b/components/infra-proxy-service/storage/testDB/testDB.go index 864e2c114cf..2b460ef5977 100644 --- a/components/infra-proxy-service/storage/testDB/testDB.go +++ b/components/infra-proxy-service/storage/testDB/testDB.go @@ -25,10 +25,10 @@ func (t *TestDB) GetServer(_ context.Context, id string) (storage.Server, error) } func (t *TestDB) GetServers(ctx context.Context) ([]storage.Server, error) { + x := make([]storage.Server, 10) if t.NeedError { - return []storage.Server{}, errors.New("failed to fetch Server") + return x, errors.New("failed to fetch Server") } - var x []storage.Server for _, v := range t.Servers { x = append(x, v) }