Skip to content

Commit

Permalink
feat: new publishopts creation
Browse files Browse the repository at this point in the history
  • Loading branch information
brandtkeller committed Feb 12, 2025
1 parent f1605c5 commit fd5c117
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 12 deletions.
28 changes: 26 additions & 2 deletions src/internal/packager2/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,41 @@

package packager2

import "context"
import (
"context"
"fmt"
)

type PublishOpts struct {
Path string
Registry string
IsSkeleton bool
SigningKeyPath string
SigningKeyPassword string
SkipSignatureValidation bool
}

func NewPublishOpts(path string, registry string, skeleton bool, signingKeyPath string, signingKeyPassword string, skipSignaturevalidation bool) (PublishOpts, error) {

if registry == "" {
return PublishOpts{}, fmt.Errorf("registry must be specified")
}

opts := PublishOpts{
Path: path,
Registry: registry,
IsSkeleton: skeleton,
SigningKeyPath: signingKeyPath,
SigningKeyPassword: signingKeyPassword,
SkipSignatureValidation: skipSignaturevalidation,
}

return opts, nil
}

// Takes directory/tar file & OCI Registry

// TODO Dir points to a location on disk and registry is a URL.
func Publish(ctx context.Context, dir string, registry string, opts PublishOpts) error {
func Publish(ctx context.Context, path string, registry string, opts PublishOpts) error {
return nil
}
23 changes: 13 additions & 10 deletions src/internal/packager2/publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,29 @@ import (
func TestPublish(t *testing.T) {

tt := []struct {
name string
dir string
opts PublishOpts
name string
dir string
registry string
opts PublishOpts
}{
{
name: "simple",
dir: "testdata/simple",
opts: PublishOpts{},
name: "simple",
dir: "testdata/simple",
registry: "",
opts: PublishOpts{},
},
{
name: "simple",
dir: "testdata/simple",
opts: PublishOpts{},
name: "simple",
dir: "testdata/simple",
registry: "",
opts: PublishOpts{},
},
}

for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
err := Publish(context.Background(), tc.opts)
err := Publish(context.Background(), tc.dir, tc.registry, tc.opts)
require.NoError(t, err)
})
}
Expand Down

0 comments on commit fd5c117

Please sign in to comment.