Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
  • Loading branch information
JAORMX committed May 8, 2024
1 parent bd8213d commit cca5ef1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 14 deletions.
2 changes: 0 additions & 2 deletions database/migrations/000054_oci_prov.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
-- limitations under the License.

ALTER TYPE provider_type ADD VALUE 'image-lister';
ALTER TYPE provider_type ADD VALUE 'ghcr';
ALTER TYPE provider_type ADD VALUE 'dockerhub';

-- Add `ghcr` and `dockerhub` provider classes
ALTER TYPE provider_class ADD VALUE 'ghcr';
Expand Down
2 changes: 0 additions & 2 deletions internal/db/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions internal/providers/dockerhub/dockerhub.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const DockerHub = "dockerhub"

// Implements is the list of provider types that the DockerHub provider implements
var Implements = []db.ProviderType{
db.ProviderTypeDockerhub,
db.ProviderTypeImageLister,
db.ProviderTypeOci,
}
Expand Down Expand Up @@ -118,6 +117,8 @@ func (d *dockerHubImageLister) ListImages(ctx context.Context) ([]string, error)
return nil, fmt.Errorf("error making request: %w", err)
}

defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
if resp.StatusCode == http.StatusUnauthorized {
return nil, fmt.Errorf("unauthorized: %s", resp.Status)
Expand All @@ -128,9 +129,6 @@ func (d *dockerHubImageLister) ListImages(ctx context.Context) ([]string, error)
return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
}

// read body
defer resp.Body.Close()

// parse body
toParse := struct {
Results []struct {
Expand Down
8 changes: 2 additions & 6 deletions internal/providers/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (pb *ProviderBuilder) GetGitHub() (provinfv1.GitHub, error) {
// GetGHCR returns a GHCR client for the provider.
func (pb *ProviderBuilder) GetGHCR() (provinfv1.ImageLister, error) {
if !pb.Implements(db.ProviderTypeImageLister) {
return nil, fmt.Errorf("provider does not implement ghcr")
return nil, fmt.Errorf("provider does not implement image-lister")
}

if pb.p.Version != provinfv1.V1 {
Expand All @@ -266,7 +266,7 @@ func (pb *ProviderBuilder) GetGHCR() (provinfv1.ImageLister, error) {
// GetDockerHub returns a DockerHub client for the provider.
func (pb *ProviderBuilder) GetDockerHub() (provinfv1.ImageLister, error) {
if !pb.Implements(db.ProviderTypeImageLister) {
return nil, fmt.Errorf("provider does not implement dockerhub")
return nil, fmt.Errorf("provider does not implement image-lister")
}

if pb.p.Version != provinfv1.V1 {
Expand Down Expand Up @@ -334,10 +334,6 @@ func DBToPBType(t db.ProviderType) (minderv1.ProviderType, bool) {
return minderv1.ProviderType_PROVIDER_TYPE_OCI, true
case db.ProviderTypeImageLister:
return minderv1.ProviderType_PROVIDER_TYPE_IMAGE_LISTER, true
case db.ProviderTypeGhcr:
return minderv1.ProviderType_PROVIDER_TYPE_GHCR, true
case db.ProviderTypeDockerhub:
return minderv1.ProviderType_PROVIDER_TYPE_DOCKERHUB, true
default:
return minderv1.ProviderType_PROVIDER_TYPE_UNSPECIFIED, false
}
Expand Down

0 comments on commit cca5ef1

Please sign in to comment.