PutFile implements RuntimeService.
(ctx context.Context, req *runtimev1.PutFileRequest)
| 123 | |
| 124 | // PutFile implements RuntimeService. |
| 125 | func (s *Server) PutFile(ctx context.Context, req *runtimev1.PutFileRequest) (*runtimev1.PutFileResponse, error) { |
| 126 | observability.AddRequestAttributes(ctx, |
| 127 | attribute.String("args.instance_id", req.InstanceId), |
| 128 | attribute.String("args.path", req.Path), |
| 129 | attribute.Bool("args.create", req.Create), |
| 130 | attribute.Bool("args.create_only", req.CreateOnly), |
| 131 | ) |
| 132 | |
| 133 | s.addInstanceRequestAttributes(ctx, req.InstanceId) |
| 134 | |
| 135 | if !auth.GetClaims(ctx, req.InstanceId).Can(runtime.EditRepo) { |
| 136 | return nil, ErrForbidden |
| 137 | } |
| 138 | |
| 139 | err := s.runtime.PutFile(ctx, req.InstanceId, req.Path, strings.NewReader(req.Blob), req.Create, req.CreateOnly) |
| 140 | if err != nil { |
| 141 | return nil, mapGRPCErrorWithFallback(err, codes.InvalidArgument) |
| 142 | } |
| 143 | |
| 144 | return &runtimev1.PutFileResponse{}, nil |
| 145 | } |
| 146 | |
| 147 | // CreateDirectory implements RuntimeService. |
| 148 | func (s *Server) CreateDirectory(ctx context.Context, req *runtimev1.CreateDirectoryRequest) (*runtimev1.CreateDirectoryResponse, error) { |
nothing calls this directly
no test coverage detected