Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit f801dc4

Browse files
authored
Switch over to github.com/sijms/go-ora/v2 (#312)
* switch over to github.com/sijms/go-ora/v2 * rip stuff out of the build process (travis, rpm downloads, etc) * modify docker files to not rely on oci.pc * windows validation completed; push up multi-arch build * bump version to 0.5.0
1 parent d0fbef9 commit f801dc4

File tree

11 files changed

+51
-194
lines changed

11 files changed

+51
-194
lines changed

.github/workflows/pull-request.yml

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,6 @@ jobs:
9696
echo "oracle-version=$oracle_version" >> $GITHUB_OUTPUT
9797
echo "version=$version" >> $GITHUB_OUTPUT
9898
99-
- name: Setup instantclient cache
100-
uses: actions/cache@v3
101-
env:
102-
cache-name: cache-instantclient-rpm
103-
cache-version: ${{ steps.version.outputs.oracle-version }}
104-
with:
105-
path: |
106-
./oracle-instantclient-*.rpm
107-
./oci8.pc
108-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-${{ hashFiles('**/Makefile') }}
109-
restore-keys: |
110-
${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-
111-
112-
- name: Install dependencies
113-
run: |
114-
make oci.pc prereq
115-
11699
- name: Setup Golang cache
117100
uses: actions/cache@v3
118101
with:
@@ -211,23 +194,6 @@ jobs:
211194
with:
212195
ref: ${{ env.PULL_REQUEST_HEAD }}
213196

214-
- name: Setup instantclient cache
215-
uses: actions/cache@v3
216-
env:
217-
cache-name: cache-instantclient-rpm
218-
cache-version: ${{ needs.build.outputs.oracle-version }}
219-
with:
220-
path: |
221-
./oracle-instantclient-*.rpm
222-
./oci8.pc
223-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-${{ hashFiles('**/Makefile') }}
224-
restore-keys: |
225-
${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-
226-
227-
- name: Install dependencies
228-
run: |
229-
make oci.pc download-rpms
230-
231197
- name: Build image
232198
id: docker-meta
233199
env:

.github/workflows/release.yml

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,6 @@ jobs:
8383
echo "oracle-version=$oracle_version" >> $GITHUB_OUTPUT
8484
echo "version=$version" >> $GITHUB_OUTPUT
8585
86-
- name: Setup instantclient cache
87-
uses: actions/cache@v3
88-
env:
89-
cache-name: cache-instantclient-rpm
90-
cache-version: ${{ steps.version.outputs.oracle-version }}
91-
with:
92-
path: |
93-
./oracle-instantclient-*.rpm
94-
./oci8.pc
95-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-${{ hashFiles('**/Makefile') }}
96-
restore-keys: |
97-
${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-
98-
99-
- name: Install dependencies
100-
run: |
101-
make oci.pc prereq
102-
10386
- name: Setup Golang cache
10487
uses: actions/cache@v3
10588
with:
@@ -193,23 +176,6 @@ jobs:
193176
- name: Checkout
194177
uses: actions/checkout@v3
195178

196-
- name: Setup instantclient cache
197-
uses: actions/cache@v3
198-
env:
199-
cache-name: cache-instantclient-rpm
200-
cache-version: ${{ needs.build.outputs.oracle-version }}
201-
with:
202-
path: |
203-
./oracle-instantclient-*.rpm
204-
./oci8.pc
205-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-${{ hashFiles('**/Makefile') }}
206-
restore-keys: |
207-
${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-
208-
209-
- name: Install dependencies
210-
run: |
211-
make oci.pc download-rpms
212-
213179
- name: Build image
214180
id: docker-meta
215181
env:

Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ COPY --from=oracle-image /usr/lib/oracle /usr/lib/oracle
1717
COPY --from=oracle-image /usr/share/oracle /usr/share/oracle
1818
COPY --from=oracle-image /usr/include/oracle /usr/include/oracle
1919

20-
COPY oci8.pc.template /usr/share/pkgconfig/oci8.pc
21-
RUN sed -i "s/@ORACLE_VERSION@/$ORACLE_VERSION/g" /usr/share/pkgconfig/oci8.pc && \
22-
sed -i "s/@MAJOR_VERSION@/$MAJOR_VERSION/g" /usr/share/pkgconfig/oci8.pc && \
23-
find /usr -name oci.pc
2420
RUN echo $LD_LIBRARY_PATH >> /etc/ld.so.conf.d/oracle.conf && ldconfig
2521

2622
WORKDIR /go/src/oracledb_exporter

Makefile

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ OS_TYPE ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
33
ARCH_TYPE ?= $(subst x86_64,amd64,$(patsubst i%86,386,$(ARCH)))
44
GOOS ?= $(shell go env GOOS)
55
GOARCH ?= $(shell go env GOARCH)
6-
VERSION ?= 0.4.4
6+
VERSION ?= 0.5.0
77
MAJOR_VERSION ?= 21
88
MINOR_VERSION ?= 8
99
ORACLE_VERSION ?= $(MAJOR_VERSION).$(MINOR_VERSION)
@@ -12,20 +12,22 @@ PKG_VERSION ?= $(ORACLE_VERSION).0.0.0-1.el8.$(ARCH)
1212
GLIBC_VERSION ?= 2.35-r0
1313
LDFLAGS := -X main.Version=$(VERSION)
1414
GOFLAGS := -ldflags "$(LDFLAGS) -s -w"
15-
RPM_VERSION ?= $(ORACLE_VERSION).0.0.0-1
16-
ORA_RPM = oracle-instantclient-basic-$(PKG_VERSION).rpm oracle-instantclient-devel-$(PKG_VERSION).rpm
17-
LD_LIBRARY_PATH = /usr/lib/oracle/$(ORACLE_VERSION)/client64/lib
1815
BUILD_ARGS = --build-arg VERSION=$(VERSION) --build-arg ORACLE_VERSION=$(ORACLE_VERSION) \
1916
--build-arg MAJOR_VERSION=$(MAJOR_VERSION) --build-arg ORACLE_IMAGE=$(ORACLE_IMAGE)
2017
LEGACY_TABLESPACE = --build-arg LEGACY_TABLESPACE=.legacy-tablespace
21-
DIST_DIR = oracledb_exporter-$(VERSION)-ora$(ORACLE_VERSION).$(OS_TYPE)-$(ARCH_TYPE)
22-
ARCHIVE = oracledb_exporter-$(VERSION)-ora$(ORACLE_VERSION).$(OS_TYPE)-$(ARCH_TYPE).tar.gz
18+
OUTDIR = ./dist
2319

2420
IMAGE_NAME ?= iamseth/oracledb_exporter
2521
IMAGE_ID ?= $(IMAGE_NAME):$(VERSION)
2622
IMAGE_ID_LATEST?= $(IMAGE_NAME):latest
2723
RELEASE ?= true
2824

25+
ifeq ($(GOOS), windows)
26+
EXT?=.exe
27+
else
28+
EXT?=
29+
endif
30+
2931
export LD_LIBRARY_PATH ORACLE_VERSION
3032

3133
version:
@@ -34,30 +36,37 @@ version:
3436
oracle-version:
3537
@echo "$(ORACLE_VERSION)"
3638

37-
%.rpm:
38-
wget -q "https://download.oracle.com/otn_software/linux/instantclient/$(MAJOR_VERSION)$(MINOR_VERSION)000/$@"
39+
.PHONY: go-build
40+
go-build:
41+
@echo "Build $(OS_TYPE)"
42+
mkdir -p $(OUTDIR)/oracledb_exporter-$(VERSION)-ora$(ORACLE_VERSION).$(GOOS)-$(GOARCH)/
43+
go build $(GOFLAGS) -o $(OUTDIR)/oracledb_exporter-$(VERSION)-ora$(ORACLE_VERSION).$(GOOS)-$(GOARCH)/oracledb_exporter$(EXT)
44+
cp default-metrics.toml $(OUTDIR)/$(DIST_DIR)
45+
(cd dist ; tar cfz oracledb_exporter-$(VERSION)-ora$(ORACLE_VERSION).$(GOOS)-$(GOARCH).tar.gz oracledb_exporter-$(VERSION)-ora$(ORACLE_VERSION).$(GOOS)-$(GOARCH))
3946

40-
download-rpms: $(ORA_RPM)
41-
@true
47+
.PHONY: go-build-linux-amd64
48+
go-build-linux-amd64:
49+
GOOS=linux GOARCH=amd64 $(MAKE) go-build -j2
4250

43-
prereq: download-rpms
44-
@echo deps
45-
sudo apt-get update
46-
sudo apt-get install --no-install-recommends -qq libaio1 rpm alien
47-
sudo alien -i oracle*.rpm || sudo rpm -Uvh --nodeps --force oracle*.rpm
48-
echo $(LD_LIBRARY_PATH) | sudo tee /etc/ld.so.conf.d/oracle.conf
49-
sudo ldconfig
51+
.PHONY: go-build-linux-arm64
52+
go-build-linux-arm64:
53+
GOOS=linux GOARCH=arm64 $(MAKE) go-build -j2
5054

51-
oci.pc:
52-
sed "s/@ORACLE_VERSION@/$(ORACLE_VERSION)/g" oci8.pc.template | \
53-
sed "s/@MAJOR_VERSION@/$(MAJOR_VERSION)/g" > oci8.pc
55+
.PHONY: go-build-darwin-amd64
56+
go-build-darwin-amd64:
57+
GOOS=darwin GOARCH=amd64 $(MAKE) go-build -j2
5458

55-
go-build: oci.pc
56-
@echo "Build $(OS_TYPE)"
57-
mkdir -p ./dist/$(DIST_DIR)
58-
PKG_CONFIG_PATH=${PWD} GOOS=$(OS_TYPE) GOARCH=$(ARCH_TYPE) go build $(GOFLAGS) -o ./dist/$(DIST_DIR)/oracledb_exporter
59-
cp default-metrics.toml ./dist/$(DIST_DIR)
60-
(cd dist ; tar cfz $(ARCHIVE) $(DIST_DIR))
59+
.PHONY: go-build-darwin-arm64
60+
go-build-darwin-arm64:
61+
GOOS=darwin GOARCH=arm64 $(MAKE) go-build -j2
62+
63+
.PHONY: go-build-windows-amd64
64+
go-build-windows-amd64:
65+
GOOS=windows GOARCH=amd64 $(MAKE) go-build -j2
66+
67+
.PHONY: go-build-windows-x86
68+
go-build-windows-x86:
69+
GOOS=windows GOARCH=386 $(MAKE) go-build -j2
6170

6271
go-lint:
6372
@echo "Linting codebase"
@@ -70,14 +79,14 @@ build: docker
7079
@true
7180

7281
deps:
73-
@PKG_CONFIG_PATH=${PWD} go get
82+
go get
7483

7584
go-test:
7685
@echo "Run tests"
77-
@PKG_CONFIG_PATH=${PWD} GOOS=$(OS_TYPE) GOARCH=$(ARCH_TYPE) go test -coverprofile="test-coverage.out" $$(go list ./... | grep -v /vendor/)
86+
GOOS=$(OS_TYPE) GOARCH=$(ARCH_TYPE) go test -coverprofile="test-coverage.out" $$(go list ./... | grep -v /vendor/)
7887

7988
clean:
80-
rm -rf ./dist sgerrand.rsa.pub glibc-*.apk oracle-*.rpm oci8.pc
89+
rm -rf ./dist sgerrand.rsa.pub glibc-*.apk oracle-*.rpm
8190

8291
docker: ubuntu-image alpine-image oraclelinux-image
8392

@@ -113,7 +122,7 @@ else
113122
@echo "Can't find cosign.key file"
114123
endif
115124

116-
ubuntu-image: $(ORA_RPM)
125+
ubuntu-image:
117126
if DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect "$(IMAGE_ID)" > /dev/null; then \
118127
echo "Image \"$(IMAGE_ID)\" already exists on ghcr.io"; \
119128
else \
@@ -137,7 +146,7 @@ else
137146
@echo "Can't find cosign.key file"
138147
endif
139148

140-
alpine-image: $(ORA_RPM)
149+
alpine-image:
141150
if DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect "$(IMAGE_ID)-alpine" > /dev/null; then \
142151
echo "Image \"$(IMAGE_ID)-alpine\" already exists on ghcr.io"; \
143152
else \
@@ -159,7 +168,4 @@ else
159168
@echo "Can't find cosign.key file"
160169
endif
161170

162-
travis: oci.pc prereq deps go-test go-build docker
163-
@true
164-
165-
.PHONY: version build deps go-test clean docker travis glibc.apk oci.pc
171+
.PHONY: version build deps go-test clean docker glibc.apk

README.md

Lines changed: 6 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -405,72 +405,15 @@ Or Alpine:
405405

406406
make alpine-image
407407

408-
## Linux binaries
408+
## Building Binaries
409409

410-
Retrieve Oracle RPMs (version x.y):
410+
Run build:
411411

412-
make download-rpms
413-
414-
Then run build:
415-
416-
make linux
417-
418-
## Windows binaries
419-
420-
_Stollen from https://github.com/iamseth/oracledb_exporter/issues/40_
421-
422-
First, download Oracle Instant Client 64-Bit version basic and sdk versions.
423-
424-
Extract client (for example: **C:\oracle\instantclient_18_5**) and extract SDK to the same folder (**C:\oracle\instantclient_18_5\sdk**)
425-
426-
Set the environment variables:
427-
428-
setx CGO_CFLAGS "C:\oracle\instantclient_18_5\sdk\include"
429-
setx CGO_LDFLAGS "-LC:\oracle\instantclient_18_5 -loci"
430-
431-
Then install GCC (like MSYS2 64 bit in **c:\msys64**)
432-
433-
Run the MSYS2 MINGW64 terminal and set dependencies packages:
434-
435-
- Update pacman:
436-
437-
pacman -Su
438-
439-
- Close terminal and open a new terminal
440-
- Update all other packages:
441-
442-
pacman -Su
443-
444-
- Install pkg-config and gcc:
445-
446-
pacman -S mingw64/mingw-w64-x86_64-pkg-config mingw64/mingw-w64-x86_64-gcc
447-
448-
Go to the pkg-config dir **c:/msys64/mingw64/lib/pkgconfig/** and create **oci8.pc** with the following content:
449-
450-
prefix=C:\oracle\instantclient_18_5/sdk/
451-
version=18.5
452-
build=client64
453-
libdir=C:\oracle\instantclient_18_5/sdk/lib/msvc
454-
includedir=C:\oracle\instantclient_18_5/sdk/include
455-
glib_genmarshal=glib-genmarshal
456-
gobject_query=gobject-query
457-
glib_mkenums=glib-mkenums
458-
Name: oci8
459-
Description: Oracle database engine
460-
Version: ${version}
461-
Libs: -L${libdir} -loci
462-
Libs.private:
463-
Cflags: -I${includedir}
464-
465-
Set **%PKG_CONFIG_PATH%** as the environment variable:
466-
467-
setx PKG_CONFIG_PATH "C:\msys64\mingw64\lib\pkgconfig"
468-
469-
Ensure, that **%PATH%** includes path to the msys64 binares, if not set it: setx path "%path%;C:\msys64\mingw64\bin"
470-
471-
Everything must compile, including mattn driver for oracle.
412+
```sh
413+
make go-build
414+
```
472415

473-
Next build ./... in oracledb-exporter dir, or install it.
416+
will output binaries and archive inside the `dist` folder for the building operating system.
474417

475418
## Import into your Golang Application
476419

alpine/Dockerfile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ COPY --from=oracle-image /usr/lib/oracle /usr/lib/oracle
1717
COPY --from=oracle-image /usr/share/oracle /usr/share/oracle
1818
COPY --from=oracle-image /usr/include/oracle /usr/include/oracle
1919

20-
COPY oci8.pc.template /usr/share/pkgconfig/oci8.pc
21-
RUN sed -i "s/@ORACLE_VERSION@/$ORACLE_VERSION/g" /usr/share/pkgconfig/oci8.pc && \
22-
sed -i "s/@MAJOR_VERSION@/$MAJOR_VERSION/g" /usr/share/pkgconfig/oci8.pc && \
23-
find /usr -name oci.pc
24-
RUN echo $LD_LIBRARY_PATH >> /etc/ld.so.conf.d/oracle.conf && ldconfig
25-
2620
WORKDIR /go/src/oracledb_exporter
2721
COPY . .
2822
RUN go get -d -v

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ require (
66
github.com/BurntSushi/toml v1.2.1
77
github.com/alecthomas/kingpin/v2 v2.3.2
88
github.com/go-kit/log v0.2.1
9-
github.com/mattn/go-oci8 v0.1.1
109
github.com/prometheus/client_golang v1.14.0
1110
github.com/prometheus/common v0.42.0
1211
github.com/prometheus/exporter-toolkit v0.9.1
12+
github.com/sijms/go-ora/v2 v2.5.23
1313
)
1414

1515
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX
3131
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
3232
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
3333
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
34-
github.com/mattn/go-oci8 v0.1.1 h1:aEUDxNAyDG0tv8CA3TArnDQNyc4EhnWlsfxRgDHABHM=
35-
github.com/mattn/go-oci8 v0.1.1/go.mod h1:wjDx6Xm9q7dFtHJvIlrI99JytznLw5wQ4R+9mNXJwGI=
3634
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
3735
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
3836
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=
@@ -51,6 +49,8 @@ github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJf
5149
github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY=
5250
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
5351
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
52+
github.com/sijms/go-ora/v2 v2.5.23 h1:b+TLHgbic5ry/LM99Rx4+17T5R9SEObltmpgRi0DKEk=
53+
github.com/sijms/go-ora/v2 v2.5.23/go.mod h1:EHxlY6x7y9HAsdfumurRfTd+v8NrEOTR3Xl4FWlH6xk=
5454
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
5555
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
5656
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import (
66
"os"
77

88
"github.com/go-kit/log/level"
9-
_ "github.com/mattn/go-oci8"
109
"github.com/prometheus/client_golang/prometheus"
1110
"github.com/prometheus/client_golang/prometheus/promhttp"
1211
"github.com/prometheus/common/version"
1312
"github.com/prometheus/exporter-toolkit/web"
1413
webflag "github.com/prometheus/exporter-toolkit/web/kingpinflag"
14+
_ "github.com/sijms/go-ora/v2"
1515

1616
"github.com/alecthomas/kingpin/v2"
1717
"github.com/prometheus/common/promlog"

oci8.pc.template

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

0 commit comments

Comments
 (0)