Skip to content

Commit eaffb86

Browse files
crunchyheathJonathan S. Katz
authored andcommitted
Dynamic collection of license files
This allows for the dynamic inclusion of license files in the built container images.
1 parent dd02612 commit eaffb86

File tree

57 files changed

+48
-5043
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+48
-5043
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.DS_Store
22
/vendor/
33
tools
4+
licenses/*
5+
!licenses/LICENSE.txt

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ images = pgo-apiserver \
9595
postgres-operator
9696

9797
.PHONY: all installrbac setup setupnamespaces cleannamespaces bounce \
98-
deployoperator runmain runapiserver cli-docs clean push pull \
99-
release default
98+
deployoperator cli-docs clean push pull \
99+
release default license
100100

101101

102102
#======= Main functions =======
@@ -127,6 +127,8 @@ deployoperator:
127127

128128

129129
#======= Binary builds =======
130+
build: build-postgres-operator build-pgo-apiserver build-pgo-client build-pgo-rmdata build-pgo-scheduler license
131+
130132
build-pgo-apiserver:
131133
go install -gcflags='$(GCFLAGS)' apiserver.go
132134
cp $(GOBIN)/apiserver bin/
@@ -196,7 +198,7 @@ endif
196198

197199
pgo-base: pgo-base-$(IMGBUILDER)
198200

199-
pgo-base-build: $(PGOROOT)/build/pgo-base/Dockerfile
201+
pgo-base-build: build $(PGOROOT)/build/pgo-base/Dockerfile
200202
$(IMGCMDSTEM) \
201203
-f $(PGOROOT)/build/pgo-base/Dockerfile \
202204
-t $(PGO_IMAGE_PREFIX)/pgo-base:$(PGO_IMAGE_TAG) \
@@ -225,6 +227,9 @@ cli-docs:
225227
clean:
226228
rm -rf $(GOPATH)/pkg/* $(GOBIN)/postgres-operator $(GOBIN)/apiserver $(GOBIN)/*pgo
227229

230+
license:
231+
./bin/license_aggregator.sh
232+
228233
push: $(images:%=push-%) ;
229234

230235
push-%:

bin/license_aggregator.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
# Copyright 2021 Crunchy Data Solutions, Inc.
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Inputs / outputs
17+
SCAN_DIR=${GOPATH}/pkg/mod
18+
OUT_DIR=licenses
19+
20+
# Fail on error
21+
set -e
22+
23+
# Clean up before we start our work
24+
rm -rf $OUT_DIR/*/
25+
26+
# Get any file in the vendor directory with the word "license" in it. Note that we'll also keep its path
27+
myLicenses=$(find $SCAN_DIR -type f | grep -i license)
28+
for licensefile in $myLicenses
29+
do
30+
# make a new license directory matching the same vendor structure
31+
licensedir=$(dirname $licensefile)
32+
newlicensedir=$(echo $licensedir | sed "s:$SCAN_DIR:$OUT_DIR:" | sed 's:@[0-9a-zA-Z.\\-]*/:/:' | sed 's:@[0-9a-zA-Z.\\-]*::')
33+
mkdir -p $newlicensedir
34+
# And, copy over the license
35+
cp -f $licensefile $newlicensedir
36+
done
37+
38+
sudo chmod -R 755 licenses

build/pgo-base/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ LABEL vendor="Crunchy Data" \
2121
io.openshift.tags="postgresql,postgres,sql,nosql,crunchy" \
2222
io.k8s.description="Trusted open source PostgreSQL-as-a-Service"
2323

24-
COPY redhat/licenses /licenses
2524
COPY redhat/atomic/help.1 /help.1
2625
COPY redhat/atomic/help.md /help.md
2726
COPY licenses /licenses

licenses/github.com/PuerkitoBio/purell/LICENSE

Lines changed: 0 additions & 12 deletions
This file was deleted.

licenses/github.com/PuerkitoBio/urlesc/LICENSE

Lines changed: 0 additions & 27 deletions
This file was deleted.

licenses/github.com/cpuguy83/go-md2man/LICENSE.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

licenses/github.com/davecgh/go-spew/LICENSE

Lines changed: 0 additions & 15 deletions
This file was deleted.

licenses/github.com/docker/spdystream/LICENSE

Lines changed: 0 additions & 191 deletions
This file was deleted.

0 commit comments

Comments
 (0)