-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add CreateRepositoryTag endpoint (#8)
Because - Distribution registry doesn't hold digest or timestamp info for tags This commit - Implements the tag creation endpoint in `artifact-backend`, which will be used by `api-gateway` when it detects an image push has finished successfully.
- Loading branch information
Showing
14 changed files
with
581 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package handler | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/otel" | ||
"go.opentelemetry.io/otel/trace" | ||
|
||
"github.com/instill-ai/artifact-backend/pkg/logger" | ||
artifact "github.com/instill-ai/artifact-backend/pkg/service" | ||
pb "github.com/instill-ai/protogen-go/artifact/artifact/v1alpha" | ||
) | ||
|
||
var tracer = otel.Tracer("artifact-backend.private-handler.tracer") | ||
|
||
// PrivateHandler handles the private Artifact endpoints. | ||
type PrivateHandler struct { | ||
pb.UnimplementedArtifactPrivateServiceServer | ||
service *artifact.Service | ||
} | ||
|
||
// NewPrivateHandler returns an initialized private handler. | ||
func NewPrivateHandler(_ context.Context, s *artifact.Service) pb.ArtifactPrivateServiceServer { | ||
return &PrivateHandler{ | ||
service: s, | ||
} | ||
} | ||
|
||
// ListRepositoryTags returns the versions of a distribution registry | ||
// repository. | ||
func (h *PrivateHandler) ListRepositoryTags(ctx context.Context, req *pb.ListRepositoryTagsRequest) (*pb.ListRepositoryTagsResponse, error) { | ||
ctx, span := tracer.Start(ctx, "ListRepositoryTags", trace.WithSpanKind(trace.SpanKindServer)) | ||
defer span.End() | ||
|
||
logger, _ := logger.GetZapLogger(ctx) | ||
|
||
resp, err := h.service.ListRepositoryTags(ctx, req) | ||
if err != nil { | ||
span.SetStatus(1, err.Error()) | ||
return nil, err | ||
} | ||
|
||
logger.Info("ListRepositoryTags") | ||
return resp, nil | ||
} | ||
|
||
// CreateRepositoryTag registers the information of a repository tag after it | ||
// has been pushed to the registry. | ||
func (h *PrivateHandler) CreateRepositoryTag(ctx context.Context, req *pb.CreateRepositoryTagRequest) (*pb.CreateRepositoryTagResponse, error) { | ||
ctx, span := tracer.Start(ctx, "CreateRepositoryTag", trace.WithSpanKind(trace.SpanKindServer)) | ||
defer span.End() | ||
|
||
logger, _ := logger.GetZapLogger(ctx) | ||
|
||
resp, err := h.service.CreateRepositoryTag(ctx, req) | ||
if err != nil { | ||
span.SetStatus(1, err.Error()) | ||
return nil, err | ||
} | ||
|
||
logger.Info("CreateRepositoryTag") | ||
return resp, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package handler | ||
|
||
import ( | ||
"context" | ||
|
||
artifactpb "github.com/instill-ai/protogen-go/artifact/artifact/v1alpha" | ||
healthcheckPB "github.com/instill-ai/protogen-go/common/healthcheck/v1beta" | ||
) | ||
|
||
// PublicHandler handles public API | ||
type PublicHandler struct { | ||
artifactpb.UnimplementedArtifactPublicServiceServer | ||
} | ||
|
||
// NewPublicHandler initiates a handler instance | ||
func NewPublicHandler(_ context.Context) artifactpb.ArtifactPublicServiceServer { | ||
return &PublicHandler{} | ||
} | ||
|
||
// Liveness returns the health of the service. | ||
func (h *PublicHandler) Liveness(_ context.Context, _ *artifactpb.LivenessRequest) (*artifactpb.LivenessResponse, error) { | ||
return &artifactpb.LivenessResponse{ | ||
HealthCheckResponse: &healthcheckPB.HealthCheckResponse{ | ||
Status: healthcheckPB.HealthCheckResponse_SERVING_STATUS_SERVING, | ||
}, | ||
}, nil | ||
} | ||
|
||
// Readiness returns the state of the service. | ||
func (h *PublicHandler) Readiness(_ context.Context, _ *artifactpb.ReadinessRequest) (*artifactpb.ReadinessResponse, error) { | ||
return &artifactpb.ReadinessResponse{ | ||
HealthCheckResponse: &healthcheckPB.HealthCheckResponse{ | ||
Status: healthcheckPB.HealthCheckResponse_SERVING_STATUS_SERVING, | ||
}, | ||
}, nil | ||
} |
Oops, something went wrong.