-
Notifications
You must be signed in to change notification settings - Fork 106
PO to GMP Migration Tool: Orchestrator & CLI Boilerplate #1961
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
036f215
feat: implement foundation orchestrator, CLI carriage, and structured…
karthunni 70d2b55
build: add copyright license headers to go files
karthunni 105cfdc
refactor: change logging and cli harness
karthunni 051ded3
refactor(main): use slog for CLI entrypoint logging
karthunni 69eb392
refactor: resolve logger data races and remove global hijacking
karthunni f6b49d0
feat: log errors for skipped unsupported prometheus operator resources
karthunni c0959e9
feat: implement nil pointer safety checks
karthunni eb2594a
refactor: restructure parsing checks
karthunni 7aaa3ad
fix: kubernetes resource validation
karthunni 37e8b5e
fix: make logger private and parser error pipeline
karthunni ffe27fd
fix: default streams and print errors
karthunni 4a78f0f
fix: made resource level map thread-safe (future proofing)
karthunni e5e93ac
fix: namespace default in get
karthunni a36ffaa
fix: more defensive initialization
karthunni e9b4758
fix: remove unnecessary test
karthunni c17f8eb
fix: remove defaulting comment and slog resolve
karthunni b380a49
fix: add skipped outcome in report/logs
karthunni a8ccb1f
fix: hidden directory edge case
karthunni fc9d074
feat: CLI support for multiple files and strict arguments
karthunni bdc0f31
fix: process List inputs
karthunni c5440d0
fix: implement consistent parse errors
karthunni 46489b6
fix: cache initialization and cli suggestion
karthunni a17481a
fix: print summary in main
karthunni a673119
fix: output writing in CLI
karthunni 9966902
fix: print manifests only if successful
karthunni eebdbbe
fix: remove custom log levels
karthunni 627d1d0
fix: lint errors
karthunni ad15fd3
feat: readme added
karthunni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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,55 @@ | ||
| # Copyright 2024 Google LLC | ||
| # | ||
| # 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. | ||
|
|
||
| FROM --platform=$BUILDPLATFORM google-go.pkg.dev/golang:1.26.4@sha256:3444149d0a7e3f7cfb9c2db65f0f75676fe6ad04de3ce72674efb120c08dd1c1 AS buildbase | ||
| ARG TARGETOS | ||
| ARG TARGETARCH | ||
| ARG BUILDARCH | ||
| WORKDIR /app | ||
| COPY charts/values.global.yaml charts/values.global.yaml | ||
| COPY go.mod go.mod | ||
| COPY go.sum go.sum | ||
| COPY tools tools | ||
| # Copy the Go vendor directory only if it exists. Vendor folder will automatically | ||
| # cause 'go build' to use -mod=vendor flag (otherwise -mod=mod is used). | ||
| COPY vendor* vendor | ||
| COPY cmd cmd | ||
| COPY pkg pkg | ||
|
|
||
| ENV GOEXPERIMENT=boringcrypto | ||
| ENV CGO_ENABLED=1 | ||
| ENV GOFIPS140=off | ||
| ENV GOTOOLCHAIN=local | ||
| ENV GOOS=${TARGETOS} | ||
| ENV GOARCH=${TARGETARCH} | ||
| RUN if [ "${TARGETARCH}" = "arm64" ] && [ "${BUILDARCH}" != "arm64" ]; then \ | ||
| apt-get update && apt-get install -y --no-install-recommends \ | ||
| gcc-aarch64-linux-gnu libc6-dev-arm64-cross; \ | ||
| export CC=aarch64-linux-gnu-gcc; \ | ||
| elif [ "${TARGETARCH}" = "amd64" ] && [ "${BUILDARCH}" != "amd64" ]; then \ | ||
| apt-get update && apt-get install -y --no-install-recommends \ | ||
| gcc-x86-64-linux-gnu libc6-dev-amd64-cross; \ | ||
| export CC=x86_64-linux-gnu-gcc; \ | ||
| fi && \ | ||
| GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ | ||
| go build \ | ||
| -ldflags="-X github.com/prometheus/common/version.Version=$(cat charts/values.global.yaml | go tool -modfile="tools/go.mod" yq '.version' ) \ | ||
| -X github.com/prometheus/common/version.BuildDate=$(date --iso-8601=seconds)" \ | ||
| -o gmp-migrate \ | ||
| cmd/gmp-migrate/*.go | ||
|
karthunni marked this conversation as resolved.
|
||
|
|
||
|
|
||
| FROM gke.gcr.io/gke-distroless/libc:gke_distroless_20260307.00_p0@sha256:d5c073079125b887158bb1dd0ee4da49b39a08203c3c96124ee310962dd5aae2 | ||
| COPY --from=buildbase /app/gmp-migrate /bin/gmp-migrate | ||
| ENTRYPOINT ["/bin/gmp-migrate"] | ||
This file contains hidden or 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,40 @@ | ||
| // Copyright 2026 Google LLC | ||
| // | ||
| // 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 main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
|
|
||
| "github.com/GoogleCloudPlatform/prometheus-engine/pkg/migrate" | ||
| "github.com/alecthomas/kingpin/v2" | ||
| ) | ||
|
|
||
| var ( | ||
| // Flags. | ||
| inputFile = kingpin.Flag("file", "Input source (YAML file, directory, or '-' for stdin)").Short('f').Required().String() | ||
| ) | ||
|
|
||
| func main() { | ||
| kingpin.CommandLine.Help = "Migrate Prometheus Operator configurations to Google Managed Prometheus (GMP)." | ||
| kingpin.Parse() | ||
|
|
||
| migrator := migrate.NewMigrator() | ||
| _, err := migrator.Run(*inputFile) | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "[ERROR] Migration failed: %v\n", err) | ||
| os.Exit(1) | ||
| } | ||
|
karthunni marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.