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

Add a new manifest command to support multi-architecture builds #1967

Closed
wants to merge 63 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
17ec0e6
WIP: added manifest_add command
WYGIN Nov 9, 2023
45f39bc
WIP added manifest_annotate command
WYGIN Nov 9, 2023
5b75d95
WIP added manifest_create command
WYGIN Nov 9, 2023
9799f01
WIP added manifest_exists command
WYGIN Nov 9, 2023
1968518
WIP added manifest_inspect command
WYGIN Nov 9, 2023
d8f6039
WIP added manifest_push command
WYGIN Nov 9, 2023
07b9150
WIP added manifest_remove command
WYGIN Nov 9, 2023
a6355e1
WIP added manifest_rm command
WYGIN Nov 9, 2023
f24b167
WIP added add_manifest client
WYGIN Nov 9, 2023
15ed584
WIP added annotate_manifest client
WYGIN Nov 9, 2023
8cf016e
WIP added IndexFactory to Client
WYGIN Nov 9, 2023
0ed954f
WIP added create_manifest client
WYGIN Nov 9, 2023
dfd4bc4
WIP added delete_manifest client
WYGIN Nov 9, 2023
94ba3e3
WIP added exists_manifest client
WYGIN Nov 9, 2023
4ec02e7
WIP added inspect_manifest client
WYGIN Nov 9, 2023
f2161a9
WIP added push_manifest client
WYGIN Nov 9, 2023
2080208
WIP added remove_manifest client
WYGIN Nov 9, 2023
5aa4b9f
WIP added errors
WYGIN Nov 9, 2023
d10a617
build(deps): bump github.com/buildpacks/lifecycle from 0.17.1 to 0.17.2
dependabot[bot] Oct 18, 2023
32e5d1d
Updating default lifecycle version to 0.17.2
jjbustamante Oct 26, 2023
d5d98bc
Group minor/patch version Go Dependabot updates into one PR
edmorley Oct 27, 2023
bf88725
Add buildpacksio/pack:<version>-base images to delivery
natalieparellano Oct 27, 2023
31654b8
Add floating :base tag
natalieparellano Oct 30, 2023
f70fdfe
Ensure the run image os/arch always matches:
natalieparellano Oct 12, 2023
0133424
When downloading buildpacks or extensions for `pack build` or `pack b…
natalieparellano Oct 12, 2023
0848fec
build(deps): bump the go-dependencies group with 6 updates
dependabot[bot] Oct 31, 2023
71821d8
Fix misleading log message when publishing a buildpack package
natalieparellano Sep 22, 2023
4624639
WIP added code to generate env files in buildConfigEnv dir
WYGIN Oct 4, 2023
9854231
WIP added required abstract test cases
WYGIN Oct 4, 2023
161d06a
WIP added tests that still nedd to be fixed
WYGIN Oct 5, 2023
7183dcf
WIP change from action to suffix and delim in builder.toml
WYGIN Oct 5, 2023
1480037
WIP added logic to add buildConfigEnvs to layer of image
WYGIN Oct 8, 2023
b8409a9
build-config-env layer oly added when it is not empty
WYGIN Oct 12, 2023
fc47fd8
added requested changes and fix bugs
WYGIN Oct 25, 2023
4feb437
fix: code format
WYGIN Oct 25, 2023
e41d99e
improved code coverage
WYGIN Oct 26, 2023
e3cc4d9
build(deps): bump buildpacks/github-actions from 5.4.0 to 5.5.0
dependabot[bot] Nov 1, 2023
8e69f1b
Add ServerVersion to docker client interface which is needed by imgutil
jericop Nov 1, 2023
a8335fb
Use imgutil fork to verify platform changes
jericop Nov 2, 2023
f9ec20e
Bump imgutil dependency for default platform change
jericop Nov 2, 2023
b714626
WIP: added manifest_add command
WYGIN Nov 9, 2023
8b109bf
WIP added manifest_annotate command
WYGIN Nov 9, 2023
a76513d
WIP added manifest_create command
WYGIN Nov 9, 2023
128f178
WIP added manifest_exists command
WYGIN Nov 9, 2023
d238c64
WIP added manifest_inspect command
WYGIN Nov 9, 2023
9006ad4
WIP added manifest_push command
WYGIN Nov 9, 2023
11d416d
WIP added manifest_remove command
WYGIN Nov 9, 2023
749b6fe
WIP added manifest_rm command
WYGIN Nov 9, 2023
8b25d63
WIP added add_manifest client
WYGIN Nov 9, 2023
6b8f798
WIP added annotate_manifest client
WYGIN Nov 9, 2023
4aa9362
WIP added IndexFactory to Client
WYGIN Nov 9, 2023
89763fd
WIP added create_manifest client
WYGIN Nov 9, 2023
a5b1faa
WIP added delete_manifest client
WYGIN Nov 9, 2023
6090d11
WIP added exists_manifest client
WYGIN Nov 9, 2023
b8f3186
WIP added inspect_manifest client
WYGIN Nov 9, 2023
b9dd8a4
WIP added push_manifest client
WYGIN Nov 9, 2023
54c3c6c
WIP added remove_manifest client
WYGIN Nov 9, 2023
553f927
WIP added errors
WYGIN Nov 9, 2023
c7180d8
Merge branch 'manifest' of https://github.com/WYGIN/buildpacks-pack i…
WYGIN Nov 9, 2023
4bbb483
WIP generate mock code with 'make generate'
WYGIN Nov 9, 2023
8f81b6c
WIP added tests for add_manifest
WYGIN Nov 9, 2023
f12c849
WIP improved add_manifest client tests
WYGIN Nov 10, 2023
4326812
WIP refactor manifest_add client
WYGIN Nov 10, 2023
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
Prev Previous commit
Next Next commit
WIP added add_manifest client
Signed-off-by: WYGIN <wygininc@gmail.com>
  • Loading branch information
WYGIN committed Nov 9, 2023
commit f24b167f0edc2c766e9181e3837e8d816348c5d2
67 changes: 67 additions & 0 deletions internal/commands/manifest_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package commands_test

import (
"bytes"
"testing"

"github.com/buildpacks/pack/internal/commands"
"github.com/buildpacks/pack/internal/commands/testmocks"
"github.com/buildpacks/pack/pkg/logging"
"github.com/golang/mock/gomock"
"github.com/heroku/color"
"github.com/sclevine/spec"
"github.com/sclevine/spec/report"
"github.com/spf13/cobra"
)

func TestManifestCommand(t *testing.T) {
color.Disable(true)
defer color.Disable(false)

spec.Run(t, "Commands", testManifestCommand, spec.Random(), spec.Report(report.Terminal{}))
}

func testManifestCommand(t *testing.T, when spec.G, it spec.S) {
var (
command *cobra.Command
logger *logging.LogWithWriters
outBuf bytes.Buffer
mockController *gomock.Controller
mockClient *testmocks.MockPackClient
)

it.Before(func() {
logger = logging.NewLogWithWriters(&outBuf, &outBuf)
mockController = gomock.NewController(t)
mockClient = testmocks.NewMockPackClient(mockController)

command = commands.NewManifestCommand(logger, mockClient)
})

when("#ManifestAdd", func() {
when("no flags specified", func() {

})
when("add is passed as flag", func() {

})
when("create is passed as flag", func() {

})
when("annotate is passed as flag", func() {

})
when("remove is passed as flag", func() {

})
when("inspect is passed as flag", func() {

})
when("rm is passed as flag", func() {

})
when("push is passed as flag", func() {

})
})
}
87 changes: 87 additions & 0 deletions pkg/client/add_manifest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package client

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

type ManifestAddOptions struct {
ManifestAnnotateOptions
All bool
}

// AddManifest implements commands.PackClient.
func (c *Client) AddManifest(ctx context.Context, index string, image string, opts ManifestAddOptions) (indexID string, err error) {
ref, err := c.runtime.ParseReference(image)
if err != nil {
return
}

imgIndex, err := c.runtime.LookupImageIndex(index)
if err != nil {
return
}

digest, err := imgIndex.Add(ctx, ref, opts.All)
if err != nil {
if ref, _, err = c.imageFactory.FindImage(image); err != nil {
return indexID, fmt.Errorf("Error while trying to find image on local storage: %v", err)
}
digest, err = imgIndex.Add(ctx, ref, opts.All)
if err != nil {
return indexID, fmt.Errorf("Error while trying to add on manifest list: %v", err)
}
}

if opts.OS != "" {
if _, err := imgIndex.Index.SetOS(digest, opts.OS); err != nil {
return indexID, err
}
}

if opts.OSArch != "" {
if _, err := imgIndex.Index.SetArchitecture(digest, opts.OSArch); err != nil {
return indexID, err
}
}

if opts.OSVariant != "" {
if _, err := imgIndex.Index.SetVariant(digest, opts.OSVariant); err != nil {
return indexID, err
}
}

if opts.OSVersion != "" {
if _, err := imgIndex.Index.SetOSVersion(digest, opts.OSVersion); err != nil {
return indexID, err
}
}

if len(opts.Features) != 0 {
if _, err := imgIndex.Index.SetFeatures(digest, opts.Features); err != nil {
return indexID, err
}
}

if len(opts.Annotations) != 0 {
annotations := make(map[string]string)
for _, annotationSpec := range opts.Annotations {
spec := strings.SplitN(annotationSpec, "=", 2)
if len(spec) != 2 {
return indexID, fmt.Errorf("no value given for annotation %q", spec[0])
}
annotations[spec[0]] = spec[1]
}
if err := imgIndex.Index.SetAnnotations(&digest, annotations); err != nil {
return err
}
}

indexID, err = imgIndex.Index.Save(index, nil, "")
if err == nil {
fmt.Printf("%s: %s\n", indexID, digest.String())
}

return indexID, err
}
103 changes: 103 additions & 0 deletions pkg/client/add_manifest_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package client_test

import (
"bytes"
"testing"

"github.com/buildpacks/pack/internal/commands"
"github.com/buildpacks/pack/internal/commands/testmocks"
"github.com/buildpacks/pack/pkg/logging"
"github.com/golang/mock/gomock"
"github.com/heroku/color"
"github.com/sclevine/spec"
"github.com/sclevine/spec/report"
"github.com/spf13/cobra"
)

func TestManifestAddCommand(t *testing.T) {
color.Disable(true)
defer color.Disable(false)

spec.Run(t, "Commands", testManifestAddCommand, spec.Random(), spec.Report(report.Terminal{}))
}

func testManifestAddCommand(t *testing.T, when spec.G, it spec.S) {
var (
command *cobra.Command
logger *logging.LogWithWriters
outBuf bytes.Buffer
mockController *gomock.Controller
mockClient *testmocks.MockPackClient
)

it.Before(func() {
logger = logging.NewLogWithWriters(&outBuf, &outBuf)
mockController = gomock.NewController(t)
mockClient = testmocks.NewMockPackClient(mockController)

command = commands.ManifestAdd(logger, mockClient)
})

when("#AddManifest", func() {
when("no flags specified", func() {

})
when("when --all flags passed", func() {

})
when("when --os flags passed", func() {

})
when("when --arch flags passed", func() {

})
when("when --variant flags passed", func() {

})
when("when --os-version flags passed", func() {

})
when("when --features flags passed", func() {

})
when("when --os-features flags passed", func() {

})
when("when --annotations flags passed", func() {

})
when("when multiple flags passed", func() {

})
when("when no args passed", func() {

})
when("when manifest list reference is incorrect", func() {

})
when("when manifest reference is incorrect", func() {

})
when("when manifest passed in-place of manifest list on first arg", func() {

})
when("when manifest list is passed on second arg", func() {

})
when("when manifest is passed on second arg with --all option", func() {

})
when("when manifest list in locally available", func() {

})
when("when manifest is not locally available", func() {

})
when("when manifest is locally available passed", func() {

})
when("when multiple manifests passed", func() {

})
})
}