Skip to content

Commit

Permalink
update refactoring done on API
Browse files Browse the repository at this point in the history
Signed-off-by: Kairo Araujo <[email protected]>
  • Loading branch information
kairoaraujo committed Jan 23, 2024
1 parent 16ce17a commit 804bed9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/archivistactl/cmd/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func storeAttestationByPath(ctx context.Context, baseUrl, path string) (string,
}

defer file.Close()
resp, err := api.StoreWithReader(ctx, baseUrl, file)
resp, err := api.UploadWithReader(ctx, baseUrl, file)
if err != nil {
return "", err
}
Expand Down
12 changes: 6 additions & 6 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,31 +101,31 @@ func (s *Server) Router() *mux.Router {
// @Success 200 {object} api.StoreResponse
// @Tags attestation
// @Router /v1/upload [post]
func (s *Server) Upload(ctx context.Context, r io.Reader) (api.StoreResponse, error) {
func (s *Server) Upload(ctx context.Context, r io.Reader) (api.UploadResponse, error) {
payload, err := io.ReadAll(r)
if err != nil {
return api.StoreResponse{}, err
return api.UploadResponse{}, err
}

gid, err := gitoid.New(bytes.NewReader(payload), gitoid.WithContentLength(int64(len(payload))), gitoid.WithSha256())
if err != nil {
logrus.Errorf("failed to generate gitoid: %v", err)
return api.StoreResponse{}, err
return api.UploadResponse{}, err
}

if s.objectStore != nil {
if err := s.objectStore.Store(ctx, gid.String(), payload); err != nil {
logrus.Errorf("received error from object store: %+v", err)
return api.StoreResponse{}, err
return api.UploadResponse{}, err
}
}

if err := s.metadataStore.Store(ctx, gid.String(), payload); err != nil {
logrus.Errorf("received error from metadata store: %+v", err)
return api.StoreResponse{}, err
return api.UploadResponse{}, err
}

return api.StoreResponse{Gitoid: gid.String()}, nil
return api.UploadResponse{Gitoid: gid.String()}, nil
}

// @Summary Store
Expand Down

0 comments on commit 804bed9

Please sign in to comment.