Skip to content

Commit

Permalink
fixed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cjlapao committed May 15, 2024
1 parent 56132f1 commit beefa62
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/catalog/push_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ func (s *CatalogManifestService) PushMetadata(ctx basecontext.ApiContext, r *mod
break
}

helper.DeleteFile(filepath.Join("/tmp", s.getMetaFilename(manifest.Name)))
if err := helper.DeleteFile(filepath.Join("/tmp", s.getMetaFilename(manifest.Name))); err != nil {
ctx.LogErrorf("Error deleting metadata file %v: %v", s.getMetaFilename(manifest.Name), err)
manifest.AddError(err)
break
}

catalogManifest.RequiredClaims = r.RequiredClaims
catalogManifest.RequiredRoles = r.RequiredRoles
Expand Down
30 changes: 30 additions & 0 deletions src/controllers/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,11 @@ func AddClaimsToCatalogManifestHandler() restapi.ControllerHandler {
ReturnApiError(ctx, w, models.NewFromError(err))
return
}
} else {
ReturnApiError(ctx, w, models.ApiErrorResponse{
Message: "No claims provided",
Code: http.StatusBadRequest,
})
}

newManifest, err := dbService.GetCatalogManifestsByCatalogIdVersionAndArch(ctx, catalogId, version, architecture)
Expand Down Expand Up @@ -769,6 +774,11 @@ func RemoveClaimsToCatalogManifestHandler() restapi.ControllerHandler {
ReturnApiError(ctx, w, models.NewFromError(err))
return
}
} else {
ReturnApiError(ctx, w, models.ApiErrorResponse{
Message: "No claims provided",
Code: http.StatusBadRequest,
})
}

newManifest, err := dbService.GetCatalogManifestsByCatalogIdVersionAndArch(ctx, catalogId, version, architecture)
Expand Down Expand Up @@ -856,6 +866,11 @@ func AddRolesToCatalogManifestHandler() restapi.ControllerHandler {
ReturnApiError(ctx, w, models.NewFromError(err))
return
}
} else {
ReturnApiError(ctx, w, models.ApiErrorResponse{
Message: "No roles provided",
Code: http.StatusBadRequest,
})
}

newManifest, err := dbService.GetCatalogManifestsByCatalogIdVersionAndArch(ctx, catalogId, version, architecture)
Expand Down Expand Up @@ -943,6 +958,11 @@ func RemoveRolesToCatalogManifestHandler() restapi.ControllerHandler {
ReturnApiError(ctx, w, models.NewFromError(err))
return
}
} else {
ReturnApiError(ctx, w, models.ApiErrorResponse{
Message: "No roles provided",
Code: http.StatusBadRequest,
})
}

newManifest, err := dbService.GetCatalogManifestsByCatalogIdVersionAndArch(ctx, catalogId, version, architecture)
Expand Down Expand Up @@ -1030,6 +1050,11 @@ func AddTagsToCatalogManifestHandler() restapi.ControllerHandler {
ReturnApiError(ctx, w, models.NewFromError(err))
return
}
} else {
ReturnApiError(ctx, w, models.ApiErrorResponse{
Message: "No tags provided",
Code: http.StatusBadRequest,
})
}

newManifest, err := dbService.GetCatalogManifestsByCatalogIdVersionAndArch(ctx, catalogId, version, architecture)
Expand Down Expand Up @@ -1117,6 +1142,11 @@ func RemoveTagsToCatalogManifestHandler() restapi.ControllerHandler {
ReturnApiError(ctx, w, models.NewFromError(err))
return
}
} else {
ReturnApiError(ctx, w, models.ApiErrorResponse{
Message: "No tags provided",
Code: http.StatusBadRequest,
})
}

newManifest, err := dbService.GetCatalogManifestsByCatalogIdVersionAndArch(ctx, catalogId, version, architecture)
Expand Down

0 comments on commit beefa62

Please sign in to comment.