Skip to content

Commit

Permalink
chore(registry): adopt org model deployment endpoint (#200)
Browse files Browse the repository at this point in the history
Because

- we are missing org deployment flow in registry plugin

This commit

- adopt org model deployment endpoint
  • Loading branch information
heiruwu authored Jun 17, 2024
1 parent bb3a943 commit 22e8bc7
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 14 deletions.
2 changes: 2 additions & 0 deletions plugins/grpc-proxy/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ github.com/go-chi/chi v4.0.1+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxm
github.com/golang/protobuf v1.0.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240614102540-80a2963307ba h1:EJd2eHk3H+nXcSxHjvjeWRaJ5EhMOP/8ZcfuM9wE2T4=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240614102540-80a2963307ba/go.mod h1:2blmpUwiTwxIDnrjIqT6FhR5ewshZZF554wzjXFvKpQ=
github.com/luraproject/lura v1.4.1 h1:zNzLYMzM13EaSrb9bfaPICD4bXtNqMCdyi42R1eBgro=
github.com/luraproject/lura v1.4.1/go.mod h1:KIo1/+nsRZVxIO04Hkbth0GXSSzypvkFpF5KaIoLvlo=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
Expand Down
2 changes: 1 addition & 1 deletion plugins/multi-auth/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22.2

require (
github.com/gofrs/uuid v4.3.1+incompatible
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240327112131-e593145f363a
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240614102540-80a2963307ba
github.com/luraproject/lura v1.4.1
google.golang.org/grpc v1.63.2
)
Expand Down
2 changes: 2 additions & 0 deletions plugins/multi-auth/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0Q
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240327112131-e593145f363a h1:k4tq5qQQABKiQ7uuEN2K54jnx3eVaW/PQpZXBU/SGdQ=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240327112131-e593145f363a/go.mod h1:jhEL0SauySMoPLVvx105DWyThju9sYTbsXIySVCArmM=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240614102540-80a2963307ba h1:EJd2eHk3H+nXcSxHjvjeWRaJ5EhMOP/8ZcfuM9wE2T4=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240614102540-80a2963307ba/go.mod h1:2blmpUwiTwxIDnrjIqT6FhR5ewshZZF554wzjXFvKpQ=
github.com/luraproject/lura v1.4.1 h1:zNzLYMzM13EaSrb9bfaPICD4bXtNqMCdyi42R1eBgro=
github.com/luraproject/lura v1.4.1/go.mod h1:KIo1/+nsRZVxIO04Hkbth0GXSSzypvkFpF5KaIoLvlo=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
Expand Down
2 changes: 1 addition & 1 deletion plugins/registry/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.2
require (
github.com/distribution/distribution v2.8.3+incompatible
github.com/frankban/quicktest v1.14.6
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240327112131-e593145f363a
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240614102540-80a2963307ba
github.com/luraproject/lura v1.4.1
google.golang.org/grpc v1.63.2
)
Expand Down
2 changes: 2 additions & 0 deletions plugins/registry/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0Q
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240327112131-e593145f363a h1:k4tq5qQQABKiQ7uuEN2K54jnx3eVaW/PQpZXBU/SGdQ=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240327112131-e593145f363a/go.mod h1:jhEL0SauySMoPLVvx105DWyThju9sYTbsXIySVCArmM=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240614102540-80a2963307ba h1:EJd2eHk3H+nXcSxHjvjeWRaJ5EhMOP/8ZcfuM9wE2T4=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20240614102540-80a2963307ba/go.mod h1:2blmpUwiTwxIDnrjIqT6FhR5ewshZZF554wzjXFvKpQ=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand Down
35 changes: 23 additions & 12 deletions plugins/registry/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,19 +300,30 @@ func (rh *registryHandler) relay(ctx context.Context, p registryHandlerParams) {
// is publishing the push operation success as an event and let the
// clients to consume and act upon it (artifact to register the tag
// creation time, model to deploy the image...).
prefix := "users"
if isOrganizationRepository {
prefix = "organizations"
}
deployReq := &modelpb.DeployModelAdminRequest{
Name: fmt.Sprintf("%s/%s/models/%s", prefix, namespace, contentID),
Version: resourceID,
Digest: digest,
}
if _, err := rh.modelPrivateClient.DeployModelAdmin(ctx, deployReq); err != nil {
logger.Error(req.URL.Path, "failed to deploy model", err)
rh.handleError(req, w, err)
return
prefix := "organizations"
deployReq := &modelpb.DeployOrganizationModelAdminRequest{
Name: fmt.Sprintf("%s/%s/models/%s", prefix, namespace, contentID),
Version: resourceID,
Digest: digest,
}
if _, err := rh.modelPrivateClient.DeployOrganizationModelAdmin(ctx, deployReq); err != nil {
logger.Error(req.URL.Path, "failed to deploy organization model", err)
rh.handleError(req, w, err)
return
}
} else {
prefix := "users"
deployReq := &modelpb.DeployUserModelAdminRequest{
Name: fmt.Sprintf("%s/%s/models/%s", prefix, namespace, contentID),
Version: resourceID,
Digest: digest,
}
if _, err := rh.modelPrivateClient.DeployUserModelAdmin(ctx, deployReq); err != nil {
logger.Error(req.URL.Path, "failed to deploy user model", err)
rh.handleError(req, w, err)
return
}
}
}

Expand Down

0 comments on commit 22e8bc7

Please sign in to comment.