Skip to content

Commit 5c0cbff

Browse files
authored
Merge pull request #102 from NVIDIA/custom-go-proxy
add support building k8s-driver-manager with custom GOPROXY
2 parents 7f3d9d4 + 26fa02f commit 5c0cbff

File tree

5 files changed

+47
-12
lines changed

5 files changed

+47
-12
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ jobs:
3535
run: echo "version=$(echo $GITHUB_SHA | cut -c1-8)" >> "$GITHUB_OUTPUT"
3636

3737
golang:
38+
needs: [variables]
39+
secrets: inherit
3840
uses: ./.github/workflows/golang.yaml
3941

4042
image:

.github/workflows/golang.yaml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ name: Golang
1616

1717
on:
1818
workflow_call: {}
19-
pull_request:
20-
types:
21-
- opened
22-
- synchronize
23-
branches:
24-
- main
25-
- release-*
2619

2720
jobs:
2821
check:
@@ -71,7 +64,7 @@ jobs:
7164
uses: actions/setup-go@v5
7265
with:
7366
go-version: ${{ env.GOLANG_VERSION }}
74-
67+
7568
- name: Run unit tests and generate coverage report
7669
run: make coverage
7770

@@ -83,7 +76,10 @@ jobs:
8376

8477
build:
8578
name: Build
86-
runs-on: ubuntu-latest
79+
runs-on: linux-amd64-cpu4
80+
permissions:
81+
contents: read
82+
id-token: write
8783
steps:
8884
- name: Checkout code
8985
uses: actions/checkout@v4
@@ -99,4 +95,19 @@ jobs:
9995
with:
10096
go-version: ${{ env.GOLANG_VERSION }}
10197

102-
- run: make build
98+
- name: Setup JFrog CLI
99+
id: jfrog
100+
uses: jfrog/setup-jfrog-cli@v4
101+
env:
102+
JF_URL: https://${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}/
103+
with:
104+
oidc-provider-name: nvgithub
105+
oidc-audience: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
106+
- env:
107+
OIDC_USER: ${{ steps.jfrog.outputs.oidc-user }}
108+
OIDC_TOKEN: ${{ steps.jfrog.outputs.oidc-token }}
109+
OIDC_ARTIFACTORY_ENDPOINT: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
110+
run: |
111+
OIDC_USER_ENCODED=$(python3 -c 'import urllib.parse, os; print(urllib.parse.quote_plus(os.environ["OIDC_USER"]))')
112+
export GOPROXY="https://${OIDC_USER_ENCODED}:${OIDC_TOKEN}@${OIDC_ARTIFACTORY_ENDPOINT}/artifactory/api/go/edge-go-remote-virtual"
113+
make build

.github/workflows/image.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ on:
2727

2828
jobs:
2929
build-image:
30-
runs-on: ubuntu-latest
30+
runs-on: linux-amd64-cpu4
31+
permissions:
32+
contents: read
33+
id-token: write
34+
packages: write
3135
strategy:
3236
matrix:
3337
dist: [ubi9]
@@ -49,13 +53,25 @@ jobs:
4953
registry: ghcr.io
5054
username: ${{ github.actor }}
5155
password: ${{ secrets.GITHUB_TOKEN }}
52-
56+
- name: Setup JFrog CLI
57+
id: jfrog
58+
uses: jfrog/setup-jfrog-cli@v4
59+
env:
60+
JF_URL: https://${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}/
61+
with:
62+
oidc-provider-name: nvgithub
63+
oidc-audience: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
5364
- name: Build image
5465
env:
5566
IMAGE_NAME: ghcr.io/nvidia/k8s-driver-manager
5667
VERSION: ${{ inputs.version }}
5768
PUSH_ON_BUILD: "true"
5869
BUILD_MULTI_ARCH_IMAGES: ${{ inputs.build_multi_arch_images }}
70+
OIDC_USER: ${{ steps.jfrog.outputs.oidc-user }}
71+
OIDC_TOKEN: ${{ steps.jfrog.outputs.oidc-token }}
72+
OIDC_ARTIFACTORY_ENDPOINT: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
5973
run: |
74+
OIDC_USER_ENCODED=$(python3 -c 'import urllib.parse, os; print(urllib.parse.quote_plus(os.environ["OIDC_USER"]))')
75+
export GOPROXY="https://${OIDC_USER_ENCODED}:${OIDC_TOKEN}@${OIDC_ARTIFACTORY_ENDPOINT}/artifactory/api/go/edge-go-remote-virtual"
6076
echo "${VERSION}"
6177
make -f deployments/container/Makefile build-${{ matrix.dist }}

deployments/container/Dockerfile.ubi9

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ FROM nvcr.io/nvidia/cuda:13.0.1-base-ubi9 AS build
1616

1717
WORKDIR /work
1818

19+
ARG GOPROXY=direct
20+
ENV GOPROXY=$GOPROXY
21+
1922
COPY go.mod go.mod
2023
COPY go.sum go.sum
2124
COPY vendor vendor

deployments/container/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ REGISTRY ?= nvidia
2727
IMAGE_NAME := $(REGISTRY)/k8s-driver-manager
2828
endif
2929

30+
GOPROXY ?= direct
31+
3032
IMAGE_VERSION := $(VERSION)
3133

3234
IMAGE = $(IMAGE_NAME):$(IMAGE_VERSION)
@@ -66,6 +68,7 @@ $(BUILD_TARGETS): build-%:
6668
--build-arg VERSION="$(VERSION)" \
6769
--build-arg GIT_COMMIT="$(GIT_COMMIT)" \
6870
--build-arg CVE_UPDATES="$(CVE_UPDATES)" \
71+
--build-arg GOPROXY="$(GOPROXY)" \
6972
--file $(DOCKERFILE) \
7073
$(CURDIR)
7174

0 commit comments

Comments
 (0)