Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: build failed when registry address with port #47

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/backend/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ func (b *backend) Build(ctx context.Context, modelfilePath, workDir, target stri
// build the image config.
configDesc, err := build.BuildConfig(ctx, b.store, repo)
if err != nil {
return fmt.Errorf("faile to build image config: %w", err)
return fmt.Errorf("failed to build image config: %w", err)
}

fmt.Printf("%-15s => %s (%s)\n", "Built config", configDesc.Digest, humanize.IBytes(uint64(configDesc.Size)))

// build the image manifest.
manifestDesc, err := build.BuildManifest(ctx, b.store, repo, tag, layers, configDesc, manifestAnnotation(modelfile))
if err != nil {
return fmt.Errorf("faile to build image manifest: %w", err)
return fmt.Errorf("failed to build image manifest: %w", err)
}

fmt.Printf("%-15s => %s (%s)\n", "Built manifest", manifestDesc.Digest, humanize.IBytes(uint64(manifestDesc.Size)))
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (b *backend) Extract(ctx context.Context, target string, output string) err
return exportModelArtifact(ctx, b.store, manifest, repo, output)
}

// exportModelArtifact exports the target model artifact to the output directory, which will open the artifact and extract to restore the orginal repo structure.
// exportModelArtifact exports the target model artifact to the output directory, which will open the artifact and extract to restore the original repo structure.
func exportModelArtifact(ctx context.Context, store storage.Storage, manifest ocispec.Manifest, repo, output string) error {
for _, layer := range manifest.Layers {
// pull the blob from the storage.
Expand Down
4 changes: 2 additions & 2 deletions pkg/backend/processor/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"os"

"github.com/CloudNativeAI/modctl/pkg/backend/build"
modelspec "github.com/CloudNativeAI/model-spec/specs-go/v1"
"github.com/CloudNativeAI/modctl/pkg/storage"
modelspec "github.com/CloudNativeAI/model-spec/specs-go/v1"

ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
Expand All @@ -46,7 +46,7 @@ func (p *licenseProcessor) Identify(_ context.Context, path string, info os.File
func (p *licenseProcessor) Process(ctx context.Context, store storage.Storage, repo, path, workDir string) (ocispec.Descriptor, error) {
desc, err := build.BuildLayer(ctx, store, repo, path, workDir)
if err != nil {
return ocispec.Descriptor{}, nil
return ocispec.Descriptor{}, err
}

// add license annotations.
Expand Down
4 changes: 2 additions & 2 deletions pkg/backend/processor/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"regexp"

"github.com/CloudNativeAI/modctl/pkg/backend/build"
modelspec "github.com/CloudNativeAI/model-spec/specs-go/v1"
"github.com/CloudNativeAI/modctl/pkg/storage"
modelspec "github.com/CloudNativeAI/model-spec/specs-go/v1"

ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
Expand Down Expand Up @@ -58,7 +58,7 @@ func (p *modelProcessor) Identify(_ context.Context, path string, info os.FileIn
func (p *modelProcessor) Process(ctx context.Context, store storage.Storage, repo, path, workDir string) (ocispec.Descriptor, error) {
desc, err := build.BuildLayer(ctx, store, repo, path, workDir)
if err != nil {
return ocispec.Descriptor{}, nil
return ocispec.Descriptor{}, err
}

// add model annotations.
Expand Down
4 changes: 2 additions & 2 deletions pkg/backend/processor/model_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"regexp"

"github.com/CloudNativeAI/modctl/pkg/backend/build"
modelspec "github.com/CloudNativeAI/model-spec/specs-go/v1"
"github.com/CloudNativeAI/modctl/pkg/storage"
modelspec "github.com/CloudNativeAI/model-spec/specs-go/v1"

ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
Expand Down Expand Up @@ -58,7 +58,7 @@ func (p *modelConfigProcessor) Identify(_ context.Context, path string, info os.
func (p *modelConfigProcessor) Process(ctx context.Context, store storage.Storage, repo, path, workDir string) (ocispec.Descriptor, error) {
desc, err := build.BuildLayer(ctx, store, repo, path, workDir)
if err != nil {
return ocispec.Descriptor{}, nil
return ocispec.Descriptor{}, err
}

// add config annotations.
Expand Down
4 changes: 2 additions & 2 deletions pkg/backend/processor/readme.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"os"

"github.com/CloudNativeAI/modctl/pkg/backend/build"
modelspec "github.com/CloudNativeAI/model-spec/specs-go/v1"
"github.com/CloudNativeAI/modctl/pkg/storage"
modelspec "github.com/CloudNativeAI/model-spec/specs-go/v1"

ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
Expand All @@ -46,7 +46,7 @@ func (p *readmeProcessor) Identify(_ context.Context, path string, info os.FileI
func (p *readmeProcessor) Process(ctx context.Context, store storage.Storage, repo, path, workDir string) (ocispec.Descriptor, error) {
desc, err := build.BuildLayer(ctx, store, repo, path, workDir)
if err != nil {
return ocispec.Descriptor{}, nil
return ocispec.Descriptor{}, err
}

// add readme annotations.
Expand Down
9 changes: 9 additions & 0 deletions pkg/storage/distribution/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"crypto/sha256"
"fmt"
"io"
"regexp"

distribution "github.com/distribution/distribution/v3"
registry "github.com/distribution/distribution/v3/registry/storage"
Expand All @@ -31,6 +32,14 @@ import (
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)

func init() {
// The PathRegexp in the distribution package is used to validate the repository name,
// which not cover the case of the repository name includes the :port, so mutate the regexp to support it.
// original regexp: ^(/[A-Za-z0-9._-]+)+$
// new regexp: ^(/[A-Za-z0-9._:-]+)+$
driver.PathRegexp = regexp.MustCompile(`^(/[A-Za-z0-9._:-]+)+$`)
}

const (
// StorageTypeDistribution is the storage type of distribution.
StorageTypeDistribution = "distribution"
Expand Down
Loading