Skip to content

Commit a9879e1

Browse files
patrick.rissmann@l3montree.compatrick.rissmann@l3montree.com
authored andcommitted
Fixed some oversights in regards to the attestation interface and the create function
1 parent 508674a commit a9879e1

4 files changed

Lines changed: 14 additions & 8 deletions

File tree

cmd/devguard/api/api.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ type assetVersionRepository interface {
5353
ReadBySlug(assetID uuid.UUID, slug string) (models.AssetVersion, error)
5454
}
5555

56+
type attestationRepository interface {
57+
ReadBySlug(attestationName string, slug string) (models.Attestation, error)
58+
}
59+
5660
type orgRepository interface {
5761
ReadBySlug(slugOrId string) (models.Org, error)
5862
}

internal/core/attestation/attestation_controller.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (a *attestationController) Create(ctx core.Context) error {
4848
return echo.NewHTTPError(400, "unable to bind data to attestation model").WithInternal(err)
4949
}
5050

51-
err = json.Unmarshal(content, &jsonContent)
51+
err = json.Unmarshal(content, &jsonContent) //convert the byte array from io.ReadAll into a readable json
5252
if err != nil {
5353
return err
5454
}
@@ -57,6 +57,11 @@ func (a *attestationController) Create(ctx core.Context) error {
5757
if err != nil {
5858
return echo.NewHTTPError(400, err.Error())
5959
}
60-
return nil
6160

61+
err = a.attestationRepository.Create(nil, &attestation)
62+
if err != nil {
63+
return err
64+
}
65+
66+
return nil
6267
}

internal/core/common_interfaces.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ type AssetRepository interface {
5353
}
5454

5555
type AttestationRepository interface {
56+
common.Repository[string, models.Attestation, DB]
5657
GetByAssetID(assetID uuid.UUID) ([]models.Attestation, error)
5758
GetByAssetVersion(assetID uuid.UUID, assetVersion string) ([]models.Attestation, error)
5859
}

internal/database/repositories/attestation_repository.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
type attestationRepository struct {
1111
db core.DB
12-
common.Repository[uuid.UUID, models.Attestation, core.DB]
12+
common.Repository[string, models.Attestation, core.DB]
1313
}
1414

1515
func NewAttestationRepository(db core.DB) *attestationRepository {
@@ -19,7 +19,7 @@ func NewAttestationRepository(db core.DB) *attestationRepository {
1919
}
2020
return &attestationRepository{
2121
db: db,
22-
Repository: newGormRepository[uuid.UUID, models.Attestation](db),
22+
Repository: newGormRepository[string, models.Attestation](db),
2323
}
2424
}
2525

@@ -40,7 +40,3 @@ func (a *attestationRepository) GetByAssetVersion(assetID uuid.UUID, assetVersio
4040
}
4141
return attestationList, nil
4242
}
43-
44-
func (a *attestationRepository) Create() error {
45-
return nil
46-
}

0 commit comments

Comments
 (0)