Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
emosbaugh committed Jul 23, 2024
1 parent f5d01d0 commit 6cfad4f
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 32 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/image-deps-updater.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ jobs:

- name: Update ${{ matrix.addon }} images
env:
REGISTRY_SERVER: index.docker.io
REGISTRY_USER: ${{ secrets.DOCKERHUB_USER }}
REGISTRY_PASS: ${{ secrets.DOCKERHUB_PASSWORD }}
IMAGES_REGISTRY_SERVER: index.docker.io
IMAGES_REGISTRY_USER: ${{ secrets.DOCKERHUB_USER }}
IMAGES_REGISTRY_PASS: ${{ secrets.DOCKERHUB_PASSWORD }}
INPUT_K0S_VERSION: ${{ github.event.inputs.k0s_version }}
INPUT_OPENEBS_VERSION: ${{ github.event.inputs.openebs_version }}
INPUT_KUBECTL_VERSION: ${{ github.event.inputs.kubectl_version }}
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/update-addons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ jobs:
- name: Update ${{ matrix.addon }}
id: update
env:
REGISTRY_SERVER: registry.replicated.com
REGISTRY_USER: ${{ secrets.REGISTRY_USERNAME_PRODUCTION }}
REGISTRY_PASS: ${{ secrets.REGISTRY_PASSWORD_PRODUCTION }}
DESTINATION: registry.replicated.com/ec-charts
CHARTS_REGISTRY_SERVER: registry.replicated.com
CHARTS_REGISTRY_USER: ${{ secrets.REGISTRY_USERNAME_PRODUCTION }}
CHARTS_REGISTRY_PASS: ${{ secrets.REGISTRY_PASSWORD_PRODUCTION }}
IMAGES_REGISTRY_SERVER: index.docker.io
IMAGES_REGISTRY_USER: ${{ secrets.DOCKERHUB_USER }}
IMAGES_REGISTRY_PASS: ${{ secrets.DOCKERHUB_PASSWORD }}
CHARTS_DESTINATION: registry.replicated.com/ec-charts
run: |
chmod 755 ./output/artifacts/buildtools
./output/artifacts/buildtools update addon ${{ matrix.addon }}
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,31 +67,31 @@ default: embedded-cluster-linux-amd64
pkg/goods/bins/k0s: Makefile
mkdir -p pkg/goods/bins
if [ "$(K0S_BINARY_SOURCE_OVERRIDE)" != "" ]; then \
curl -L -o pkg/goods/bins/k0s "$(K0S_BINARY_SOURCE_OVERRIDE)" ; \
curl -fL -o pkg/goods/bins/k0s "$(K0S_BINARY_SOURCE_OVERRIDE)" ; \
else \
curl -L -o pkg/goods/bins/k0s "https://github.com/k0sproject/k0s/releases/download/$(K0S_VERSION)/k0s-$(K0S_VERSION)-amd64" ; \
curl -fL -o pkg/goods/bins/k0s "https://github.com/k0sproject/k0s/releases/download/$(K0S_VERSION)/k0s-$(K0S_VERSION)-amd64" ; \
fi
chmod +x pkg/goods/bins/k0s
touch pkg/goods/bins/k0s

pkg/goods/bins/kubectl: Makefile
mkdir -p pkg/goods/bins
curl -L -o pkg/goods/bins/kubectl "https://dl.k8s.io/release/$(KUBECTL_VERSION)/bin/linux/amd64/kubectl"
curl -fL -o pkg/goods/bins/kubectl "https://dl.k8s.io/release/$(KUBECTL_VERSION)/bin/linux/amd64/kubectl"
chmod +x pkg/goods/bins/kubectl
touch pkg/goods/bins/kubectl

pkg/goods/bins/kubectl-support_bundle: Makefile
mkdir -p pkg/goods/bins
mkdir -p output/tmp/support-bundle
curl -L -o output/tmp/support-bundle/support-bundle.tar.gz https://github.com/replicatedhq/troubleshoot/releases/download/$(TROUBLESHOOT_VERSION)/support-bundle_linux_amd64.tar.gz
curl -fL -o output/tmp/support-bundle/support-bundle.tar.gz https://github.com/replicatedhq/troubleshoot/releases/download/$(TROUBLESHOOT_VERSION)/support-bundle_linux_amd64.tar.gz
tar -xzf output/tmp/support-bundle/support-bundle.tar.gz -C output/tmp/support-bundle
mv output/tmp/support-bundle/support-bundle pkg/goods/bins/kubectl-support_bundle
touch pkg/goods/bins/kubectl-support_bundle

pkg/goods/bins/kubectl-preflight: Makefile
mkdir -p pkg/goods/bins
mkdir -p output/tmp/preflight
curl -L -o output/tmp/preflight/preflight.tar.gz https://github.com/replicatedhq/troubleshoot/releases/download/$(TROUBLESHOOT_VERSION)/preflight_linux_amd64.tar.gz
curl -fL -o output/tmp/preflight/preflight.tar.gz https://github.com/replicatedhq/troubleshoot/releases/download/$(TROUBLESHOOT_VERSION)/preflight_linux_amd64.tar.gz
tar -xzf output/tmp/preflight/preflight.tar.gz -C output/tmp/preflight
mv output/tmp/preflight/preflight pkg/goods/bins/kubectl-preflight
touch pkg/goods/bins/kubectl-preflight
Expand All @@ -107,9 +107,9 @@ pkg/goods/internal/bins/kubectl-kots: Makefile
mkdir -p pkg/goods/internal/bins
mkdir -p output/tmp/kots
if [ "$(KOTS_BINARY_URL_OVERRIDE)" != "" ]; then \
curl -L -o output/tmp/kots/kots.tar.gz "$(KOTS_BINARY_URL_OVERRIDE)" ; \
curl -fL -o output/tmp/kots/kots.tar.gz "$(KOTS_BINARY_URL_OVERRIDE)" ; \
else \
curl -L -o output/tmp/kots/kots.tar.gz https://github.com/replicatedhq/kots/releases/download/$(KOTS_VERSION)/kots_linux_amd64.tar.gz ; \
curl -fL -o output/tmp/kots/kots.tar.gz https://github.com/replicatedhq/kots/releases/download/$(KOTS_VERSION)/kots_linux_amd64.tar.gz ; \
fi
tar -xzf output/tmp/kots/kots.tar.gz -C output/tmp/kots
mv output/tmp/kots/kots pkg/goods/internal/bins/kubectl-kots
Expand Down
11 changes: 7 additions & 4 deletions cmd/buildtools/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ import (

const environmentUsageText = `
This script uses the following environment variables:
- REGISTRY_SERVER: the registry server to push the chart/image to (only used for authentication in the case of charts, e.g. index.docker.io)
- REGISTRY_USER: the username to authenticate with.
- REGISTRY_PASS: the password to authenticate with.
- DESTINATION: the destination repository to push the chart to (e.g. ttl.sh/embedded-cluster-charts)
- CHARTS_REGISTRY_SERVER: the registry server to push the chart to (e.g. index.docker.io)
- CHARTS_REGISTRY_USER: the username to authenticate with.
- CHARTS_REGISTRY_PASS: the password to authenticate with.
- IMAGES_REGISTRY_SERVER: the registry server to push the images to (e.g. index.docker.io)
- IMAGES_REGISTRY_USER: the username to authenticate with.
- IMAGES_REGISTRY_PASS: the password to authenticate with.
- CHARTS_DESTINATION: the destination repository to push the chart to (e.g. ttl.sh/embedded-cluster-charts)
`

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/buildtools/openebs.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var updateOpenEBSAddonCommand = &cli.Command{
}
}

upstream := fmt.Sprintf("%s/openebs", os.Getenv("DESTINATION"))
upstream := fmt.Sprintf("%s/openebs", os.Getenv("CHARTS_DESTINATION"))
withproto := fmt.Sprintf("oci://proxy.replicated.com/anonymous/%s", upstream)

logrus.Infof("updating openebs images")
Expand Down
2 changes: 1 addition & 1 deletion cmd/buildtools/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var updateRegistryAddonCommand = &cli.Command{
return fmt.Errorf("unable to mirror chart: %w", err)
}

upstream := fmt.Sprintf("%s/docker-registry", os.Getenv("DESTINATION"))
upstream := fmt.Sprintf("%s/docker-registry", os.Getenv("CHARTS_DESTINATION"))
newmeta := release.AddonMetadata{
Version: latest,
Location: fmt.Sprintf("oci://proxy.replicated.com/anonymous/%s", upstream),
Expand Down
2 changes: 1 addition & 1 deletion cmd/buildtools/seaweedfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var updateSeaweedFSAddonCommand = &cli.Command{
return fmt.Errorf("unable to mirror seaweedfs chart: %w", err)
}

upstream := fmt.Sprintf("%s/seaweedfs", os.Getenv("DESTINATION"))
upstream := fmt.Sprintf("%s/seaweedfs", os.Getenv("CHARTS_DESTINATION"))
newmeta := release.AddonMetadata{
Version: latest,
Location: fmt.Sprintf("oci://proxy.replicated.com/anonymous/%s", upstream),
Expand Down
20 changes: 10 additions & 10 deletions cmd/buildtools/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ func ApkoLogin() error {
cmd := exec.Command(
"make",
"apko-login",
fmt.Sprintf("REGISTRY=%s", os.Getenv("REGISTRY_SERVER")),
fmt.Sprintf("USERNAME=%s", os.Getenv("REGISTRY_USER")),
fmt.Sprintf("PASSWORD=%s", os.Getenv("REGISTRY_PASS")),
fmt.Sprintf("REGISTRY=%s", os.Getenv("IMAGES_REGISTRY_SERVER")),
fmt.Sprintf("USERNAME=%s", os.Getenv("IMAGES_REGISTRY_USER")),
fmt.Sprintf("PASSWORD=%s", os.Getenv("IMAGES_REGISTRY_PASS")),
)
if err := RunCommand(cmd); err != nil {
return err
Expand All @@ -191,7 +191,7 @@ func ApkoLogin() error {
func ApkoBuildAndPublish(componentName string, packageName string, packageVersion string) error {
args := []string{
"apko-build-and-publish",
fmt.Sprintf("IMAGE=%s/replicated/ec-%s:%s", os.Getenv("REGISTRY_SERVER"), componentName, packageVersion),
fmt.Sprintf("IMAGE=%s/replicated/ec-%s:%s", os.Getenv("IMAGES_REGISTRY_SERVER"), componentName, packageVersion),
fmt.Sprintf("APKO_CONFIG=%s", filepath.Join("deploy", "images", componentName, "apko.tmpl.yaml")),
fmt.Sprintf("PACKAGE_NAME=%s", packageName),
fmt.Sprintf("PACKAGE_VERSION=%s", packageVersion),
Expand Down Expand Up @@ -541,18 +541,18 @@ func MirrorChart(repo, name, ver string) error {
logrus.Infof("downloaded %s chart: %s", name, chpath)
defer os.Remove(chpath)

if val := os.Getenv("REGISTRY_SERVER"); val != "" {
logrus.Infof("authenticating with %q", os.Getenv("REGISTRY_SERVER"))
if val := os.Getenv("CHARTS_REGISTRY_SERVER"); val != "" {
logrus.Infof("authenticating with %q", os.Getenv("CHARTS_REGISTRY_SERVER"))
if err := hcli.RegistryAuth(
os.Getenv("REGISTRY_SERVER"),
os.Getenv("REGISTRY_USER"),
os.Getenv("REGISTRY_PASS"),
os.Getenv("CHARTS_REGISTRY_SERVER"),
os.Getenv("CHARTS_REGISTRY_USER"),
os.Getenv("CHARTS_REGISTRY_PASS"),
); err != nil {
return fmt.Errorf("unable to authenticate: %w", err)
}
}

dst := fmt.Sprintf("oci://%s", os.Getenv("DESTINATION"))
dst := fmt.Sprintf("oci://%s", os.Getenv("CHARTS_DESTINATION"))
logrus.Infof("verifying if destination tag already exists")
tmpf, err := hcli.Pull(dst, name, ver)
if err != nil && !strings.HasSuffix(err.Error(), "not found") {
Expand Down
2 changes: 1 addition & 1 deletion cmd/buildtools/velero.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var updateVeleroAddonCommand = &cli.Command{
return fmt.Errorf("unable to mirror velero chart: %w", err)
}

upstream := fmt.Sprintf("%s/velero", os.Getenv("DESTINATION"))
upstream := fmt.Sprintf("%s/velero", os.Getenv("CHARTS_DESTINATION"))
newmeta := release.AddonMetadata{
Version: latest,
Location: fmt.Sprintf("oci://proxy.replicated.com/anonymous/%s", upstream),
Expand Down

0 comments on commit 6cfad4f

Please sign in to comment.