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

chore: fix up codegen privileges #6309

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions internal/cli/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion internal/engine/buildcontrol/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions internal/engine/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,240 changes: 644 additions & 596 deletions pkg/apis/core/v1alpha1/generated.pb.go

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions pkg/apis/core/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions pkg/webview/view.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 24 additions & 4 deletions scripts/update-codegen-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ if [ "${BASH_VERSINFO:-0}" -lt 5 ]; then
exit 2
fi

if [[ -n "${CODEGEN_USER-}" ]]; then
useradd "$CODEGEN_USER"
fi

GOPATH=$(go env GOPATH)
export GOPATH

Expand Down Expand Up @@ -79,3 +75,27 @@ if [[ "$VIOLATIONS" != "ok" ]]; then
exit 1
fi

FIXUPS=(
./pkg/openapi
./pkg/openapi/zz_generated.openapi.go
./pkg/apis/core/v1alpha1/zz_generated.conversion.go
./pkg/apis/core/v1alpha1/generated.proto
./pkg/apis/core/v1alpha1/zz_generated.defaults.go
./pkg/apis/core/v1alpha1/generated.pb.go
./pkg/apis/core/v1alpha1/zz_generated.deepcopy.go
./pkg/apis/core/zz_generated.deepcopy.go
)

if [[ "$CODEGEN_UID" != "$(id -u)" ]]; then
groupadd --gid "$CODEGEN_GID" codegen-user
useradd --uid "$CODEGEN_UID" -g codegen-user codegen-user

for f in "${FIXUPS[@]}"; do
if [ -d "$f" ]; then
chmod 775 "$f"
else
chmod 664 "$f"
fi
chown codegen-user:codegen-user "$f"
done
fi
5 changes: 4 additions & 1 deletion scripts/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ cd "$DIR/.."
if [[ $CI == true ]]; then
# TODO - get this working in CI
# scripts/update-protobuf-helper.sh

export CODEGEN_UID=$(id -u)
export CODEGEN_GID=$(id -g)
scripts/update-codegen-helper.sh
exit 0
fi
Expand All @@ -19,7 +22,7 @@ docker run --rm -v "$(pwd)":/go/src/github.com/tilt-dev/tilt \
--entrypoint /go/src/github.com/tilt-dev/tilt/scripts/update-protobuf-helper.sh \
tilt-protobuf-helper

docker run --rm -e "CODEGEN_USER=$USER" -v "$(pwd)":/go/src/github.com/tilt-dev/tilt \
docker run --rm -e "CODEGEN_UID=$(id -u)" -e "CODEGEN_GID=$(id -g)" -v "$(pwd)":/go/src/github.com/tilt-dev/tilt \
--workdir /go/src/github.com/tilt-dev/tilt \
--entrypoint ./scripts/update-codegen-helper.sh \
golang:1.21