Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.
Closed
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: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ listed in the changelog.

## [Unreleased]

### Fixed

- make create-kind-with-registry failed locally on mac ([#679](https://github.com/opendevstack/ods-pipeline/issues/679))

## [0.11.0] - 2023-03-14

### Changed
Expand Down
40 changes: 22 additions & 18 deletions scripts/kind-with-registry.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/bin/bash
#
# Adapted from:
# https://github.com/kubernetes-sigs/kind/commits/master/site/static/examples/kind-with-registry.sh
#
# Copyright 2020 The Kubernetes Project
#
# 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
#
# Adapted from:
# https://github.com/kubernetes-sigs/kind/commits/master/site/static/examples/kind-with-registry.sh
#
# Copyright 2020 The Kubernetes Project
#
# 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.

set -o errexit
Expand Down Expand Up @@ -76,7 +76,7 @@ if [ "${running}" != 'true' ]; then
if [ "${reg_network}" != "bridge" ]; then
docker network create "${reg_network}" || true
fi

docker run \
-d --restart=always -p "${REGISTRY_PORT}:5000" --name "${REGISTRY_NAME}" --net "${reg_network}" \
registry:2
Expand All @@ -103,7 +103,11 @@ nodes:
extraMounts:
- hostPath: ${ODS_PIPELINE_DIR}/test
containerPath: /files
containerdConfigPatches:
kubeadmConfigPatches:
- |
kind: KubeletConfiguration
cgroupDriver: systemd
containerdConfigPatches:
- |-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${REGISTRY_PORT}"]
endpoint = ["http://${reg_ip}:${REGISTRY_PORT}"]
Expand Down
14 changes: 6 additions & 8 deletions test/tasks/ods-package-image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,19 @@ func checkTagFiles(t *testing.T, ctxt *tasktesting.TaskRunContext, wsDir string,
func checkTags(t *testing.T, ctxt *tasktesting.TaskRunContext, wsDir string, expectedTags []string) {
// registry := "kind-registry.kind:5000"
registry := "localhost:5000"
tlsVerify := false
args := []string{
"inspect",
`--format={{.RepoTags}}`,
fmt.Sprintf("--tls-verify=%v", tlsVerify),
}
imageNsStreamSha := fmt.Sprintf("%s/%s:%s", ctxt.Namespace, ctxt.ODS.Component, ctxt.ODS.GitCommitSHA)
imageRef := fmt.Sprintf("docker://%s/%s", registry, imageNsStreamSha)
imageRef := fmt.Sprintf("%s/%s", registry, imageNsStreamSha)
args = append(args, imageRef)

stdout, _, err := command.RunBuffered("skopeo", args)
stdout, _, err := command.RunBuffered("docker", args)
if err != nil {
t.Fatalf("skopeo inspect %s: %s", fmt.Sprint(args), err)
t.Fatalf("docker %s: %s", fmt.Sprint(args), err)
}
tags, err := parseSkopeoInspectDigestTags(string(stdout))
tags, err := parseDockerInspectDigestTags(string(stdout))
if err != nil {
t.Fatalf("parse tags failed: %s", err)
}
Expand All @@ -155,10 +153,10 @@ func checkTags(t *testing.T, ctxt *tasktesting.TaskRunContext, wsDir string, exp
}
}

func parseSkopeoInspectDigestTags(out string) ([]string, error) {
func parseDockerInspectDigestTags(out string) ([]string, error) {
t := strings.TrimSpace(out)
if !(strings.HasPrefix(t, "[") && strings.HasSuffix(t, "]")) {
return nil, fmt.Errorf("skopeo inspect: unexpected tag response expecting tags to be in brackets %s", t)
return nil, fmt.Errorf("docker inspect: unexpected tag response expecting tags to be in brackets %s", t)
}
t = t[1 : len(t)-1]
// expecting t to have space separated tags.
Expand Down