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

cmd: add a utility to copy catalog content #3036

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ COPY --from=builder /build/bin/olm /bin/olm
COPY --from=builder /build/bin/catalog /bin/catalog
COPY --from=builder /build/bin/package-server /bin/package-server
COPY --from=builder /build/bin/cpb /bin/cpb
COPY --from=builder /build/bin/copy-content /bin/copy-content
USER 1001
EXPOSE 8080
EXPOSE 5443
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,14 @@ bin/wait: FORCE
build-util-linux: arch_flags=GOOS=linux GOARCH=$(ARCH)
build-util-linux: build-util

build-util: bin/cpb
build-util: bin/cpb bin/copy-content

bin/cpb: FORCE
CGO_ENABLED=0 $(arch_flags) go build -buildvcs=false $(MOD_FLAGS) -ldflags '-extldflags "-static"' -o $@ ./util/cpb

bin/copy-content: FORCE
CGO_ENABLED=0 $(arch_flags) go build -buildvcs=false $(MOD_FLAGS) -ldflags '-extldflags "-static"' -o $@ ./cmd/copy-content

$(CMDS): version_flags=-ldflags "-X $(PKG)/pkg/version.GitCommit=$(GIT_COMMIT) -X $(PKG)/pkg/version.OLMVersion=`cat OLM_VERSION`"
$(CMDS):
$(arch_flags) go $(build_cmd) $(MOD_FLAGS) $(version_flags) -tags $(BUILD_TAGS) -o bin/$(shell basename $@) $@
Expand Down
38 changes: 38 additions & 0 deletions cmd/copy-content/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package main

import (
"flag"
"fmt"
"os"

"github.com/otiai10/copy"
)

func main() {
catalogSource := flag.String("catalog.from", "", "Path to catalog contents to copy.")
catalogDestination := flag.String("catalog.to", "", "Path to where catalog contents should be copied.")
cacheSource := flag.String("cache.from", "", "Path to cache contents to copy.")
cacheDestination := flag.String("cache.to", "", "Path to where cache contents should be copied.")

for flagName, value := range map[string]*string{
"catalog.from": catalogSource,
"catalog.to": catalogDestination,
"cache.from": cacheSource,
"cache.to": cacheDestination,
} {
if value == nil || *value == "" {
fmt.Printf("--%s is required", flagName)
os.Exit(1)
}
}

for from, to := range map[string]string{
*catalogSource: *catalogDestination,
*cacheSource: *cacheDestination,
} {
if err := copy.Copy(from, to); err != nil {
fmt.Printf("failed to copy %s to %s: %s\n", from, to, err)
os.Exit(1)
}
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ require (
github.com/openshift/client-go v0.0.0-20220525160904-9e1acff93e4a
github.com/operator-framework/api v0.17.8-0.20230908201838-28c6773d2b74
github.com/operator-framework/operator-registry v1.29.0
github.com/otiai10/copy v1.2.0
github.com/otiai10/copy v1.12.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.15.1
github.com/prometheus/client_model v0.4.0
Expand Down
10 changes: 3 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -608,13 +608,9 @@ github.com/operator-framework/api v0.17.8-0.20230908201838-28c6773d2b74 h1:BNzxQ
github.com/operator-framework/api v0.17.8-0.20230908201838-28c6773d2b74/go.mod h1:Wbg136l1Po6zqG2QcTN1QZ8dbT4BQvNlQDM9tmQYvz0=
github.com/operator-framework/operator-registry v1.29.0 h1:HMmVTiuOAGoHLzYqR9Lr2QSOqbVzA50++ojNl2mu9f4=
github.com/operator-framework/operator-registry v1.29.0/go.mod h1:4rVQu/cOuCtVt3JzKsAmwyq2lsiu9uPaH9nYNfnqj9o=
github.com/otiai10/copy v1.2.0 h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k=
github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw=
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
github.com/otiai10/mint v1.3.1 h1:BCmzIS3n71sGfHB5NMNDB3lHYPz8fWSkCAErHed//qc=
github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
github.com/otiai10/copy v1.12.0 h1:cLMgSQnXBs1eehF0Wy/FAGsgDTDmAqFR7rQylBb1nDY=
github.com/otiai10/copy v1.12.0/go.mod h1:rSaLseMUsZFFbsFGc7wCJnnkTAvdc5L6VWxPE4308Ww=
github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pbnjay/strptime v0.0.0-20140226051138-5c05b0d668c9 h1:4lfz0keanz7/gAlvJ7lAe9zmE08HXxifBZJC0AdeGKo=
github.com/pbnjay/strptime v0.0.0-20140226051138-5c05b0d668c9/go.mod h1:6Hr+C/olSdkdL3z68MlyXWzwhvwmwN7KuUFXGb3PoOk=
Expand Down
8 changes: 7 additions & 1 deletion vendor/github.com/otiai10/copy/.gitignore

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

102 changes: 98 additions & 4 deletions vendor/github.com/otiai10/copy/README.md

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

Loading