-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes value for storage.oci.repository
Previously while providing repo url value for storage oci repository, chains controller was giving an error as `a digest must contain exactly one '@' separator (e.g. registry/repository@digest)` because, it was not able to add digest Hence this patch fixes it, by formatting the value provided by the user and thus storing the attestations/signatures in the provided location Signed-off-by: PuneetPunamiya <[email protected]>
- Loading branch information
1 parent
1c918c9
commit 1c754db
Showing
2 changed files
with
94 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
Copyright 2023 The Tekton Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package oci | ||
|
||
import ( | ||
"github.com/google/go-containerregistry/pkg/name" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/tektoncd/chains/pkg/config" | ||
) | ||
|
||
func TestNewRepo(t *testing.T) { | ||
t.Run("Use any registry in storage oci repository", func(t *testing.T) { | ||
cfg := config.Config{} | ||
cfg.Storage.OCI.Repository = "example.com/foo" | ||
tests := []struct { | ||
testImageName string | ||
expectedImageName string | ||
expectedRepo *name.Repository | ||
}{ | ||
{ | ||
testImageName: "gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init@sha256:bc4f7468f87486e3835b09098c74cd7f54db2cf697cbb9b824271b95a2d0871e", | ||
expectedImageName: "example.com/foo", | ||
expectedRepo: &name.Repository{}, | ||
}, | ||
{ | ||
testImageName: "foo.io/bar/kaniko-chains@sha256:bc4f7468f87486e3835b09098c74cd7f54db2cf697cbb9b824271b95a2d0871e", | ||
expectedImageName: "example.com/foo", | ||
}, | ||
{ | ||
testImageName: "registry.com/spam/spam/spam/spam/spam/spam@sha256:bc4f7468f87486e3835b09098c74cd7f54db2cf697cbb9b824271b95a2d0871e", | ||
expectedImageName: "example.com/foo", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
repo, err := newRepo(cfg) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
assert.Equal(t, repo.Name(), test.expectedImageName) | ||
} | ||
}) | ||
} |