mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-27 04:28:20 +00:00
commit
eaeea2dfb8
@ -1,2 +0,0 @@
|
||||
xhyve/
|
||||
alpine/packages
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
test.log
|
||||
*.swp
|
||||
|
9
Dockerfile.media
Normal file
9
Dockerfile.media
Normal file
@ -0,0 +1,9 @@
|
||||
FROM scratch
|
||||
|
||||
ADD \
|
||||
alpine/initrd.img \
|
||||
alpine/kernel/x86_64/vmlinuz64 \
|
||||
alpine/mobylinux-bios.iso \
|
||||
alpine/mobylinux-efi.iso \
|
||||
alpine/mobylinux.efi \
|
||||
/
|
@ -1,8 +1,8 @@
|
||||
FROM justincormack/alpine-qemu
|
||||
FROM mobylinux/alpine-qemu:1f3de121e9dea39a198413344a72049839bea91b
|
||||
|
||||
COPY alpine/initrd.img.gz .
|
||||
COPY alpine/initrd.img .
|
||||
COPY alpine/kernel/x86_64/vmlinuz64 .
|
||||
|
||||
RUN qemu-img create -f raw disk.img 100M
|
||||
|
||||
ENTRYPOINT [ "qemu-system-x86_64", "-drive", "file=disk.img,format=raw", "-device", "virtio-rng-pci", "-serial", "stdio", "-kernel", "vmlinuz64", "-initrd", "initrd.img.gz", "-m", "2048", "-append", "earlyprintk=serial console=ttyS0 noapic", "-vnc", "none" ]
|
||||
ENTRYPOINT [ "qemu-system-x86_64", "-drive", "file=disk.img,format=raw", "-device", "virtio-rng-pci", "-serial", "stdio", "-kernel", "vmlinuz64", "-initrd", "initrd.img", "-m", "2048", "-append", "earlyprintk=serial console=ttyS0 noapic", "-vnc", "none" ]
|
||||
|
@ -1,9 +0,0 @@
|
||||
FROM justincormack/alpine-qemu
|
||||
|
||||
COPY alpine/initrd-arm.img .
|
||||
COPY alpine/kernel/arm/zImage .
|
||||
COPY alpine/kernel/dtb dtb
|
||||
|
||||
RUN gzip -9 initrd-arm.img
|
||||
|
||||
ENTRYPOINT [ "qemu-system-arm", "-machine", "vexpress-a15", "-cpu", "cortex-a15", "-no-reboot", "-netdev", "user,id=eth0", "-device", "virtio-net-device,netdev=eth0", "-serial", "stdio", "-kernel", "zImage", "-initrd", "initrd-arm.img.gz", "-dtb", "dtb/vexpress-v2p-ca15-tc1.dtb", "-m", "1024", "-append", "console=ttyAMA0,38400n8", "-vnc", "none" ]
|
@ -1,4 +1,4 @@
|
||||
FROM justincormack/alpine-qemu
|
||||
FROM mobylinux/alpine-qemu:1f3de121e9dea39a198413344a72049839bea91b
|
||||
|
||||
COPY alpine/mobylinux-bios.iso .
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
FROM justincormack/alpine-qemu
|
||||
FROM mobylinux/alpine-qemu:1f3de121e9dea39a198413344a72049839bea91b
|
||||
|
||||
COPY alpine/initrd.img.gz .
|
||||
COPY alpine/initrd.img .
|
||||
COPY alpine/kernel/x86_64/vmlinuz64 .
|
||||
|
||||
RUN qemu-img create -f raw disk.img 100M
|
||||
|
||||
ENTRYPOINT [ "qemu-system-x86_64", "-drive", "file=disk.img,format=raw", "-device", "virtio-rng-pci", "-serial", "stdio", "-kernel", "vmlinuz64", "-initrd", "initrd.img.gz", "-m", "1024", "-append", "earlyprintk=serial console=ttyS0 noapic mobyplatform=test", "-vnc", "none" ]
|
||||
ENTRYPOINT [ "qemu-system-x86_64", "-drive", "file=disk.img,format=raw", "-device", "virtio-rng-pci", "-serial", "stdio", "-kernel", "vmlinuz64", "-initrd", "initrd.img", "-m", "1024", "-append", "earlyprintk=serial console=ttyS0 noapic mobyplatform=test", "-vnc", "none" ]
|
||||
|
53
Makefile
53
Makefile
@ -1,36 +1,49 @@
|
||||
DOCKER_EXPERIMENTAL?=1
|
||||
|
||||
all:
|
||||
$(MAKE) -C alpine/kernel
|
||||
$(MAKE) -C alpine
|
||||
|
||||
qemu: all
|
||||
tar cf - Dockerfile.qemu alpine/initrd.img.gz alpine/kernel/x86_64/vmlinuz64 | \
|
||||
docker build -f Dockerfile.qemu -t mobyqemu:build -
|
||||
alpine/initrd.img:
|
||||
$(MAKE) -C alpine initrd.img
|
||||
|
||||
alpine/kernel/x86_64/vmlinuz64:
|
||||
$(MAKE) -C alpine/kernel x86_64/vmlinuz64
|
||||
|
||||
alpine/mobylinux-bios.iso:
|
||||
$(MAKE) -C alpine mobylinux-bios.iso
|
||||
|
||||
qemu: Dockerfile.qemu alpine/initrd.img alpine/kernel/x86_64/vmlinuz64
|
||||
tar cf - $^ | docker build -f Dockerfile.qemu -t mobyqemu:build -
|
||||
docker run -it --rm mobyqemu:build
|
||||
|
||||
qemu-iso: all
|
||||
$(MAKE) -C alpine mobylinux-bios.iso
|
||||
docker build -f Dockerfile.qemuiso -t mobyqemuiso:build .
|
||||
qemu-iso: Dockerfile.qemuiso alpine/mobylinux-bios.iso
|
||||
tar cf - $^ | docker build -f Dockerfile.qemuiso -t mobyqemuiso:build -
|
||||
docker run -it --rm mobyqemuiso:build
|
||||
|
||||
arm:
|
||||
$(MAKE) -C alpine/kernel arm
|
||||
$(MAKE) -C alpine arm
|
||||
|
||||
qemu-arm: Dockerfile.qemu.armhf arm
|
||||
docker build -f Dockerfile.qemu.armhf -t mobyarmqemu:build .
|
||||
docker run -it --rm mobyarmqemu:build
|
||||
|
||||
test: Dockerfile.test all
|
||||
tar cf - Dockerfile.test alpine/initrd.img.gz alpine/kernel/x86_64/vmlinuz64 | \
|
||||
docker build -f Dockerfile.test -t mobytest:build -
|
||||
test: Dockerfile.test alpine/initrd.img alpine/kernel/x86_64/vmlinuz64
|
||||
$(MAKE) -C alpine
|
||||
tar cf - $^ | docker build -f Dockerfile.test -t mobytest:build -
|
||||
touch test.log
|
||||
docker run --rm mobytest:build 2>&1 | tee -a test.log &
|
||||
tail -f test.log 2>/dev/null | grep -m 1 -q 'Moby test suite '
|
||||
cat test.log | grep -q 'Moby test suite PASSED'
|
||||
|
||||
TAG=$(shell git rev-parse HEAD)
|
||||
STATUS=$(shell git status -s)
|
||||
ifeq ($(DOCKER_EXPERIMENTAL),1)
|
||||
MEDIA_PREFIX?=experimental-
|
||||
endif
|
||||
media: Dockerfile.media alpine/initrd.img alpine/kernel/x86_64/vmlinuz64 alpine/mobylinux-bios.iso alpine/mobylinux-efi.iso
|
||||
ifeq ($(STATUS),)
|
||||
tar cf - $^ alpine/mobylinux.efi | docker build -f Dockerfile.media -t mobylinux/media:$(MEDIA_PREFIX)latest -
|
||||
docker tag mobylinux/media:$(EXP_PREFIX)latest mobylinux/media:$(MEDIA_PREFIX)$(TAG)
|
||||
docker push mobylinux/media:$(MEDIA_PREFIX)$(TAG)
|
||||
docker push mobylinux/media:$(MEDIA_PREFIX)latest
|
||||
else
|
||||
$(error "git not clean")
|
||||
endif
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
$(MAKE) -C alpine clean
|
||||
docker images -q mobyqemu:build | xargs docker rmi -f || true
|
||||
docker images -q mobytest:build | xargs docker rmi -f || true
|
||||
|
@ -1,9 +1,5 @@
|
||||
Base repo for Moby, codename for the Docker Linux distro
|
||||
|
||||
Initial requirements are being driven by the very minimal goal of replacing boot2docker for the new Mac app.
|
||||
|
||||
However these requirements are fairly small and the scope is intended to be much broader.
|
||||
Moby, the Alpine Linux distro for Docker editions
|
||||
|
||||
Simple build instructions: use `make` to build. `make qemu` will boot up in qemu in a container.
|
||||
|
||||
You can build for arm, some parts still under development, `make clean` first, then `make qemu-arm` will run in qemu.
|
||||
Requires GNU `make`, GNU `tar` (not Busybox tar), Docker to build.
|
||||
|
@ -1 +0,0 @@
|
||||
packages/docker/docker.git
|
@ -1,58 +1,15 @@
|
||||
FROM mobylinux/alpine-base:77722e15bd14c8de88e2d2a8235bac75ee6187b3
|
||||
FROM mobylinux/alpine-base:5ee3744f0fbcdd3e9c6216322e1d023e4cdf9ee4
|
||||
|
||||
ENV ARCH=x86_64
|
||||
|
||||
RUN \
|
||||
addgroup -g 50 docker && \
|
||||
adduser -G docker -u 1001 -s /bin/sh -D -g "Docker" docker && \
|
||||
passwd -d root
|
||||
passwd -d root && \
|
||||
adduser -D -H -s /sbin/nologin dockremap
|
||||
|
||||
COPY etc /etc/
|
||||
RUN mkdir -p /etc/docker
|
||||
|
||||
ADD kernel/$ARCH/aufs-utils.tar /
|
||||
COPY mkinitrd.sh /bin/
|
||||
COPY kernel/$ARCH/kernel-source-info /etc/
|
||||
ADD kernel/$ARCH/kernel-patches.tar /etc/kernel-patches
|
||||
ADD kernel/$ARCH/kernel-modules.tar /
|
||||
|
||||
COPY packages/proxy/slirp-proxy /usr/bin/
|
||||
COPY packages/proxy/slirp-proxy /sbin/proxy-vsockd
|
||||
COPY packages/proxy/etc /etc/
|
||||
COPY packages/transfused/transfused /sbin/
|
||||
COPY packages/transfused/etc /etc/
|
||||
COPY packages/tap-vsockd/tap-vsockd /sbin/
|
||||
COPY packages/tap-vsockd/etc /etc/
|
||||
COPY packages/docker/bin/* /usr/bin/
|
||||
COPY packages/docker/etc /etc/
|
||||
COPY packages/diagnostics/diagnostics /usr/bin/
|
||||
COPY packages/diagnostics/diagnostics-server /usr/bin/
|
||||
COPY packages/diagnostics/etc /etc/
|
||||
COPY packages/automount/etc /etc/
|
||||
COPY packages/binfmt_misc/etc /etc/
|
||||
COPY packages/hostsettings/etc /etc/
|
||||
COPY packages/hvtools/hv_kvp_daemon /sbin/
|
||||
COPY packages/hvtools/hv_vss_daemon /sbin/
|
||||
COPY packages/hvtools/etc /etc/
|
||||
COPY packages/hvtools/hv_get_dhcp_info /sbin/
|
||||
COPY packages/hvtools/hv_get_dns_info /sbin/
|
||||
COPY packages/hvtools/hv_set_ifconfig /sbin/
|
||||
COPY packages/hvtools/hvtools.tar.gz /usr/share/src/
|
||||
COPY packages/chronyd/etc /etc/
|
||||
COPY packages/userns/etc /etc/
|
||||
#COPY packages/nc-vsock/nc-vsock /usr/bin/
|
||||
COPY packages/vsudd/vsudd /sbin/
|
||||
COPY packages/vsudd/etc /etc/
|
||||
COPY packages/mobyconfig/mobyconfig /usr/bin/
|
||||
COPY packages/mobyplatform/mobyplatform /usr/bin/
|
||||
COPY packages/oom/etc /etc/
|
||||
COPY packages/9pmount-vsock/9pmount-vsock /sbin/
|
||||
COPY packages/test/etc /etc/
|
||||
COPY packages/test/mobytest /usr/bin/
|
||||
COPY packages/iptables/iptables /usr/local/sbin/
|
||||
COPY packages/containerd/etc /etc/
|
||||
COPY packages/aws/etc /etc/
|
||||
COPY packages/azure/etc /etc/
|
||||
COPY . .
|
||||
RUN rm Dockerfile
|
||||
|
||||
RUN \
|
||||
rc-update add swap boot && \
|
||||
@ -94,14 +51,4 @@ RUN \
|
||||
rc-update add azure default && \
|
||||
true
|
||||
|
||||
COPY init /
|
||||
|
||||
RUN adduser -D -H -s /sbin/nologin dockremap
|
||||
|
||||
RUN cd /usr/bin && \
|
||||
ln -s docker-runc runc && \
|
||||
ln -s docker-containerd-shim containerd-shim && \
|
||||
ln -s docker-containerd-ctr containerd-ctr && \
|
||||
ln -s docker-containerd containerd
|
||||
|
||||
CMD ["/bin/sh"]
|
||||
CMD ["/mkinitrd.sh"]
|
||||
|
@ -1,20 +1,16 @@
|
||||
# Create a legacy BIOS bootable ISO
|
||||
FROM alpine:3.4
|
||||
FROM mobylinux/alpine-bios:626757290dbb54109514af22108645cae9ea40c3
|
||||
|
||||
RUN apk update && apk add \
|
||||
cdrkit \
|
||||
syslinux
|
||||
WORKDIR /tmp/iso
|
||||
|
||||
RUN mkdir -p /tmp/iso/isolinux && \
|
||||
cp /usr/share/syslinux/isolinux.bin /tmp/iso/isolinux && \
|
||||
cp /usr/share/syslinux/ldlinux.c32 /tmp/iso/isolinux
|
||||
COPY initrd.img ./
|
||||
COPY kernel/x86_64/vmlinuz64 ./
|
||||
COPY isolinux.cfg ./isolinux/
|
||||
|
||||
COPY initrd.img /tmp/iso
|
||||
COPY kernel/x86_64/vmlinuz64 /tmp/iso
|
||||
COPY isolinux.cfg /tmp/iso/isolinux
|
||||
RUN cp /usr/share/syslinux/isolinux.bin ./isolinux/ && \
|
||||
cp /usr/share/syslinux/ldlinux.c32 ./isolinux/
|
||||
|
||||
RUN cd /tmp/iso && \
|
||||
genisoimage -o ../mobylinux-bios.iso -l -J -R \
|
||||
RUN genisoimage -o ../mobylinux-bios.iso -l -J -R \
|
||||
-c isolinux/boot.cat \
|
||||
-b isolinux/isolinux.bin \
|
||||
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
||||
|
@ -1,36 +1,29 @@
|
||||
# Create a EFI Bootable ISO
|
||||
FROM alpine:3.4
|
||||
FROM mobylinux/alpine-efi:2f8c8e9ecc4bfefaf1b5ca56bac5506baba301f2
|
||||
|
||||
ENV ARCH=x86_64
|
||||
WORKDIR /tmp/efi
|
||||
|
||||
RUN apk add --no-cache binutils mtools xorriso gummiboot
|
||||
|
||||
RUN mkdir -p /tmp/efi
|
||||
|
||||
COPY initrd.img.gz /tmp/efi
|
||||
COPY kernel/$ARCH/vmlinuz64 /tmp/efi
|
||||
COPY initrd.img ./
|
||||
COPY kernel/x86_64/vmlinuz64 ./
|
||||
|
||||
# Create a EFI boot file with kernel and initrd. From:
|
||||
# https://github.com/haraldh/mkrescue-uefi/blob/master/mkrescue-uefi.sh
|
||||
RUN cd /tmp/efi && \
|
||||
cp /usr/lib/gummiboot/linuxx64.efi.stub . && \
|
||||
RUN cp /usr/lib/gummiboot/linuxx64.efi.stub . && \
|
||||
echo "earlyprintk=serial console=ttyS0 mobyplatform=windows" > cmdline.txt && \
|
||||
objcopy \
|
||||
--add-section .osrel=/etc/os-release --change-section-vma .osrel=0x20000 \
|
||||
--add-section .cmdline=./cmdline.txt --change-section-vma .cmdline=0x30000 \
|
||||
--add-section .linux=./vmlinuz64 --change-section-vma .linux=0x40000 \
|
||||
--add-section .initrd=initrd.img.gz --change-section-vma .initrd=0x3000000 \
|
||||
--add-section .initrd=initrd.img --change-section-vma .initrd=0x3000000 \
|
||||
./linuxx64.efi.stub \
|
||||
mobylinux.efi
|
||||
|
||||
# create a ISO with a EFI boot partition
|
||||
RUN cd /tmp/efi && \
|
||||
mkdir -p iso && \
|
||||
RUN mkdir -p iso && \
|
||||
dd if=/dev/zero of=iso/efi.raw bs=1024 count=70000 && \
|
||||
mkfs.vfat iso/efi.raw
|
||||
|
||||
RUN cd /tmp/efi && \
|
||||
echo "mtools_skip_check=1" >> /etc/mtools.conf && \
|
||||
RUN echo "mtools_skip_check=1" >> /etc/mtools.conf && \
|
||||
mmd -i iso/efi.raw ::/EFI && \
|
||||
mmd -i iso/efi.raw ::/EFI/BOOT && \
|
||||
mcopy -i iso/efi.raw mobylinux.efi ::/EFI/BOOT/BOOTX64.EFI && \
|
||||
|
@ -1,54 +1,50 @@
|
||||
all: initrd.img.gz mobylinux-efi.iso
|
||||
all: initrd.img mobylinux-efi.iso mobylinux-bios.iso
|
||||
|
||||
ETCFILES=etc/issue etc/motd etc/network/interfaces
|
||||
ETCFILES+=etc/inittab etc/fstab
|
||||
|
||||
initrd.img: Dockerfile mkinitrd.sh init $(ETCFILES)
|
||||
rm -f initrd.img
|
||||
$(MAKE) -C packages
|
||||
$(MAKE) -C kernel
|
||||
docker build -t moby-initrd:build .
|
||||
docker run --net=none --rm moby-initrd:build /bin/mkinitrd.sh > $@
|
||||
initrd.img: Dockerfile mkinitrd.sh init $(ETCFILES) common
|
||||
tar cf - \
|
||||
Dockerfile etc init mkinitrd.sh \
|
||||
-C kernel usr etc sbin lib -C .. \
|
||||
-C packages/proxy usr sbin etc -C ../.. \
|
||||
-C packages/transfused sbin etc -C ../.. \
|
||||
-C packages/tap-vsockd sbin etc -C ../.. \
|
||||
-C packages/docker usr etc -C ../.. \
|
||||
-C packages/diagnostics usr etc -C ../.. \
|
||||
-C packages/automount etc -C ../.. \
|
||||
-C packages/binfmt_misc etc -C ../.. \
|
||||
-C packages/hostsettings etc -C ../.. \
|
||||
-C packages/hvtools sbin etc usr -C ../.. \
|
||||
-C packages/chronyd etc -C ../.. \
|
||||
-C packages/userns etc -C ../.. \
|
||||
-C packages/nc-vsock usr -C ../.. \
|
||||
-C packages/vsudd sbin etc -C ../.. \
|
||||
-C packages/mobyconfig usr -C ../.. \
|
||||
-C packages/mobyplatform usr -C ../.. \
|
||||
-C packages/oom etc -C ../.. \
|
||||
-C packages/9pmount-vsock sbin -C ../.. \
|
||||
-C packages/test etc usr -C ../.. \
|
||||
-C packages/iptables usr -C ../.. \
|
||||
-C packages/containerd etc -C ../.. \
|
||||
-C packages/aws etc -C ../.. \
|
||||
-C packages/azure etc -C ../.. \
|
||||
| \
|
||||
docker build -t moby-initrd:build -
|
||||
docker run --net=none --rm moby-initrd:build > $@
|
||||
|
||||
initrd.img.gz: initrd.img
|
||||
cat initrd.img | gzip -9 > initrd.img.gz
|
||||
|
||||
mobylinux-efi.iso: initrd.img.gz Dockerfile.efi
|
||||
docker build -t moby-efi:build -f Dockerfile.efi .
|
||||
mobylinux-efi.iso: Dockerfile.efi initrd.img kernel/x86_64/vmlinuz64
|
||||
tar cf - $^ | docker build -t moby-efi:build -f Dockerfile.efi -
|
||||
docker run --net=none --rm --cap-add sys_admin moby-efi:build cat /tmp/efi/mobylinux.efi > mobylinux.efi
|
||||
docker run --net=none --rm --cap-add sys_admin moby-efi:build cat /tmp/efi/mobylinux-efi.iso > $@
|
||||
|
||||
mobylinux-bios.iso: initrd.img Dockerfile.bios isolinux.cfg
|
||||
docker build -t moby-bios:build -f Dockerfile.bios .
|
||||
mobylinux-bios.iso: Dockerfile.bios initrd.img kernel/x86_64/vmlinuz64 isolinux.cfg
|
||||
tar cf - $^ | docker build -t moby-bios:build -f Dockerfile.bios -
|
||||
docker run --net=none --rm moby-bios:build cat /tmp/mobylinux-bios.iso > $@
|
||||
|
||||
arm: initrd-arm.img
|
||||
|
||||
Dockerfile.armhf: Dockerfile
|
||||
cat Dockerfile | \
|
||||
sed 's@FROM alpine@FROM justincormack/armhf-alpine@' | \
|
||||
sed '/hv_/d' | \
|
||||
sed '/hvtools/d' | \
|
||||
sed 's/syslinux//' | \
|
||||
sed '/proxy/d' | \
|
||||
sed '/diagnostics/d' | \
|
||||
sed '/nc-vsock/d' | \
|
||||
sed '/vsudd/d' | \
|
||||
sed '/gummiboot/d' | \
|
||||
grep -v 'tap-vsockd' | \
|
||||
grep -v '9pmount-vsock' | \
|
||||
grep -v 'rc-update add binfmt_misc sysinit' > $@
|
||||
|
||||
initrd-arm.img: Dockerfile.armhf
|
||||
rm -f initrd-arm.img
|
||||
$(MAKE) -C packages arm
|
||||
$(MAKE) -C kernel arm
|
||||
docker build -t moby-arm:build -f Dockerfile.armhf .
|
||||
docker run --net=none --rm moby-arm:build /bin/mkinitrd.sh > $@
|
||||
|
||||
common: initrd.img
|
||||
$(MAKE) -C kernel
|
||||
$(MAKE) -C packages
|
||||
$(MAKE) -j -C packages
|
||||
|
||||
ami: common
|
||||
docker-compose build ami
|
||||
@ -63,11 +59,7 @@ azure: common
|
||||
docker-compose run --rm -T azure uploadvhd
|
||||
|
||||
clean:
|
||||
rm -f initrd.img initrd.img.gz initrd-arm.img Dockerfile.armhf mobylinux.vhd mobylinux.img
|
||||
rm -f mobylinux-bios.iso mobylinux-efi.iso mobylinux.efi
|
||||
docker images -q moby-efi:build | xargs docker rmi -f || true
|
||||
docker images -q moby-bios:build | xargs docker rmi -f || true
|
||||
docker images -q moby-arm:build | xargs docker rmi -f || true
|
||||
rm -f initrd.img mobylinux.vhd mobylinux.img mobylinux-bios.iso mobylinux-efi.iso mobylinux.efi
|
||||
docker images -q alpine_ami:latest | xargs docker rmi -f || true
|
||||
docker images -q alpine_azure:latest | xargs docker rmi -f || true
|
||||
$(MAKE) -C packages clean
|
||||
|
@ -3,24 +3,26 @@ FROM alpine:3.4
|
||||
RUN \
|
||||
apk update && apk upgrade && \
|
||||
apk add \
|
||||
e2fsprogs \
|
||||
chrony \
|
||||
git \
|
||||
xz \
|
||||
iptables \
|
||||
sfdisk \
|
||||
lvm2 \
|
||||
syslinux \
|
||||
openrc \
|
||||
busybox-initscripts \
|
||||
alpine-conf \
|
||||
bind-tools \
|
||||
openssh-client \
|
||||
strace \
|
||||
fuse \
|
||||
busybox-initscripts \
|
||||
chrony \
|
||||
cifs-utils \
|
||||
e2fsprogs \
|
||||
e2fsprogs-extra \
|
||||
openssl \
|
||||
fuse \
|
||||
git \
|
||||
iptables \
|
||||
jq \
|
||||
lvm2 \
|
||||
make \
|
||||
openrc \
|
||||
openssh-client \
|
||||
openssl \
|
||||
sfdisk \
|
||||
strace \
|
||||
sysklogd \
|
||||
syslinux \
|
||||
tar \
|
||||
xz \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
8
alpine/base/alpine-bios/Dockerfile
Normal file
8
alpine/base/alpine-bios/Dockerfile
Normal file
@ -0,0 +1,8 @@
|
||||
FROM alpine:3.4
|
||||
|
||||
RUN \
|
||||
apk update && apk upgrade && \
|
||||
apk add \
|
||||
cdrkit \
|
||||
syslinux \
|
||||
&& rm -rf /var/cache/apk/*
|
32
alpine/base/alpine-bios/Makefile
Normal file
32
alpine/base/alpine-bios/Makefile
Normal file
@ -0,0 +1,32 @@
|
||||
.PHONY: tag push
|
||||
|
||||
BASE=alpine:3.4
|
||||
IMAGE=alpine-bios
|
||||
|
||||
default: push
|
||||
|
||||
hash:
|
||||
docker pull $(BASE)
|
||||
tar cf - Dockerfile | docker build --no-cache -t $(IMAGE):build -
|
||||
docker run --rm $(IMAGE):build sha1sum /lib/apk/db/installed | sed 's/ .*//' > hash
|
||||
|
||||
push: hash
|
||||
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
|
||||
(docker tag $(IMAGE):build mobylinux/$(IMAGE):latest && \
|
||||
docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash) && \
|
||||
docker push mobylinux/$(IMAGE):$(shell cat hash) && \
|
||||
docker push mobylinux/$(IMAGE):latest)
|
||||
docker rmi $(IMAGE):build
|
||||
rm -f hash
|
||||
|
||||
tag: hash
|
||||
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
|
||||
(docker tag $(IMAGE):build mobylinux/$(IMAGE):latest && \
|
||||
docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash))
|
||||
docker rmi $(IMAGE):build
|
||||
rm -f hash
|
||||
|
||||
clean:
|
||||
rm -f hash
|
||||
|
||||
.DELETE_ON_ERROR:
|
10
alpine/base/alpine-efi/Dockerfile
Normal file
10
alpine/base/alpine-efi/Dockerfile
Normal file
@ -0,0 +1,10 @@
|
||||
FROM alpine:3.4
|
||||
|
||||
RUN \
|
||||
apk update && apk upgrade && \
|
||||
apk add \
|
||||
binutils \
|
||||
mtools \
|
||||
xorriso \
|
||||
gummiboot \
|
||||
&& rm -rf /var/cache/apk/*
|
32
alpine/base/alpine-efi/Makefile
Normal file
32
alpine/base/alpine-efi/Makefile
Normal file
@ -0,0 +1,32 @@
|
||||
.PHONY: tag push
|
||||
|
||||
BASE=alpine:3.4
|
||||
IMAGE=alpine-efi
|
||||
|
||||
default: push
|
||||
|
||||
hash:
|
||||
docker pull $(BASE)
|
||||
tar cf - Dockerfile | docker build --no-cache -t $(IMAGE):build -
|
||||
docker run --rm $(IMAGE):build sha1sum /lib/apk/db/installed | sed 's/ .*//' > hash
|
||||
|
||||
push: hash
|
||||
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
|
||||
(docker tag $(IMAGE):build mobylinux/$(IMAGE):latest && \
|
||||
docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash) && \
|
||||
docker push mobylinux/$(IMAGE):$(shell cat hash) && \
|
||||
docker push mobylinux/$(IMAGE):latest)
|
||||
docker rmi $(IMAGE):build
|
||||
rm -f hash
|
||||
|
||||
tag: hash
|
||||
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
|
||||
(docker tag $(IMAGE):build mobylinux/$(IMAGE):latest && \
|
||||
docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash))
|
||||
docker rmi $(IMAGE):build
|
||||
rm -f hash
|
||||
|
||||
clean:
|
||||
rm -f hash
|
||||
|
||||
.DELETE_ON_ERROR:
|
9
alpine/base/alpine-qemu/Dockerfile
Normal file
9
alpine/base/alpine-qemu/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
||||
FROM alpine:3.4
|
||||
|
||||
RUN \
|
||||
apk update && apk upgrade && \
|
||||
apk add \
|
||||
qemu-img \
|
||||
qemu-system-arm \
|
||||
qemu-system-x86_64 \
|
||||
&& rm -rf /var/cache/apk/*
|
32
alpine/base/alpine-qemu/Makefile
Normal file
32
alpine/base/alpine-qemu/Makefile
Normal file
@ -0,0 +1,32 @@
|
||||
.PHONY: tag push
|
||||
|
||||
BASE=alpine:3.4
|
||||
IMAGE=alpine-qemu
|
||||
|
||||
default: push
|
||||
|
||||
hash:
|
||||
docker pull $(BASE)
|
||||
tar cf - Dockerfile | docker build --no-cache -t $(IMAGE):build -
|
||||
docker run --rm $(IMAGE):build sha1sum /lib/apk/db/installed | sed 's/ .*//' > hash
|
||||
|
||||
push: hash
|
||||
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
|
||||
(docker tag $(IMAGE):build mobylinux/$(IMAGE):latest && \
|
||||
docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash) && \
|
||||
docker push mobylinux/$(IMAGE):$(shell cat hash) && \
|
||||
docker push mobylinux/$(IMAGE):latest)
|
||||
docker rmi $(IMAGE):build
|
||||
rm -f hash
|
||||
|
||||
tag: hash
|
||||
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
|
||||
(docker tag $(IMAGE):build mobylinux/$(IMAGE):latest && \
|
||||
docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash))
|
||||
docker rmi $(IMAGE):build
|
||||
rm -f hash
|
||||
|
||||
clean:
|
||||
rm -f hash
|
||||
|
||||
.DELETE_ON_ERROR:
|
24
alpine/base/debian-build-kernel/Dockerfile
Normal file
24
alpine/base/debian-build-kernel/Dockerfile
Normal file
@ -0,0 +1,24 @@
|
||||
FROM debian:jessie
|
||||
|
||||
RUN apt-get update && apt-get -y upgrade && apt-get -y install \
|
||||
unzip \
|
||||
xz-utils \
|
||||
curl \
|
||||
bc \
|
||||
build-essential \
|
||||
cpio \
|
||||
gcc libc6 libc6-dev \
|
||||
kmod \
|
||||
squashfs-tools \
|
||||
genisoimage \
|
||||
xorriso \
|
||||
syslinux \
|
||||
isolinux \
|
||||
automake \
|
||||
pkg-config \
|
||||
git \
|
||||
ncurses-dev \
|
||||
p7zip-full \
|
||||
lzop \
|
||||
wget \
|
||||
vim
|
14
alpine/base/debian-build-kernel/Makefile
Normal file
14
alpine/base/debian-build-kernel/Makefile
Normal file
@ -0,0 +1,14 @@
|
||||
# no easy hashing scheme for Debian, will switch to Alpine soon so temporarily use sha256
|
||||
.PHONY: push
|
||||
|
||||
BASE=debian:jessie
|
||||
IMAGE=debian-build-kernel
|
||||
|
||||
TAG := $(shell cat /dev/urandom | od -N6 -t x2 | head -n1 | cut -b9- | sed 's/ //g')
|
||||
|
||||
push:
|
||||
docker pull $(BASE)
|
||||
tar cf - Dockerfile | docker build --no-cache -t mobylinux/$(IMAGE):$(TAG) -
|
||||
docker tag mobylinux/$(IMAGE):$(TAG) mobylinux/$(IMAGE):latest
|
||||
docker push mobylinux/$(IMAGE):$(TAG)
|
||||
docker push mobylinux/$(IMAGE):latest
|
7
alpine/kernel/.gitignore
vendored
7
alpine/kernel/.gitignore
vendored
@ -1,2 +1,5 @@
|
||||
x86_64
|
||||
arm
|
||||
x86_64/
|
||||
etc/
|
||||
lib/
|
||||
usr/
|
||||
sbin/
|
||||
|
@ -1,33 +1,10 @@
|
||||
FROM ubuntu:16.04
|
||||
FROM mobylinux/debian-build-kernel:a009a11bf0ad
|
||||
|
||||
ARG KERNEL_VERSION=4.4.20
|
||||
ARG DEBUG=0
|
||||
|
||||
ENV KERNEL_SOURCE=https://www.kernel.org/pub/linux/kernel/v4.x/linux-${KERNEL_VERSION}.tar.xz
|
||||
|
||||
RUN apt-get update && apt-get -y upgrade && apt-get -y install \
|
||||
unzip \
|
||||
xz-utils \
|
||||
curl \
|
||||
bc \
|
||||
build-essential \
|
||||
cpio \
|
||||
gcc libc6 libc6-dev \
|
||||
kmod \
|
||||
squashfs-tools \
|
||||
genisoimage \
|
||||
xorriso \
|
||||
syslinux \
|
||||
isolinux \
|
||||
automake \
|
||||
pkg-config \
|
||||
git \
|
||||
ncurses-dev \
|
||||
p7zip-full \
|
||||
lzop \
|
||||
wget \
|
||||
vim
|
||||
|
||||
RUN curl -sSL -o linux-${KERNEL_VERSION}.tar.xz ${KERNEL_SOURCE}
|
||||
|
||||
RUN cat linux-${KERNEL_VERSION}.tar.xz | tar --absolute-names -xJ && mv /linux-${KERNEL_VERSION} /linux
|
||||
@ -37,11 +14,13 @@ ENV AUFS_REPO https://github.com/sfjro/aufs4-standalone
|
||||
ENV AUFS_BRANCH aufs4.4
|
||||
ENV AUFS_COMMIT 8be74e42b108f9cbbb0d59a87468505a48ff2757
|
||||
|
||||
# Download AUFS and patch kernel
|
||||
# Download AUFS
|
||||
RUN git clone -b "$AUFS_BRANCH" "$AUFS_REPO" /aufs && \
|
||||
cd /aufs && \
|
||||
git checkout -q "$AUFS_COMMIT" && \
|
||||
cd /linux && \
|
||||
git checkout -q "$AUFS_COMMIT"
|
||||
|
||||
# patch kernel with aufs
|
||||
RUN cd /linux && \
|
||||
cp -r /aufs/Documentation /linux && \
|
||||
cp -r /aufs/fs /linux && \
|
||||
cp -r /aufs/include/uapi/linux/aufs_type.h /linux/include/uapi/linux/ && \
|
||||
@ -66,13 +45,10 @@ RUN if [ $DEBUG -ne "0" ]; then \
|
||||
# Apply local patches
|
||||
COPY patches /patches
|
||||
RUN cd /linux && \
|
||||
mkdir /etc/kernel-patches && \
|
||||
set -e && for patch in /patches/*.patch; do \
|
||||
echo "Applying $patch"; \
|
||||
cp "$patch" /etc/kernel-patches; \
|
||||
patch -p1 < "$patch"; \
|
||||
done && \
|
||||
cd /etc/kernel-patches && tar cf /kernel-patches.tar .
|
||||
done
|
||||
|
||||
RUN jobs=$(nproc); \
|
||||
cd /linux && \
|
||||
|
@ -8,21 +8,17 @@ $(ARCH)/mobykernel-build: Dockerfile kernel_config
|
||||
docker build --build-arg DEBUG=$(DEBUG) -t mobykernel:build .
|
||||
touch $@
|
||||
|
||||
$(ARCH)/aufs-utils.tar $(ARCH)/kernel-source-info $(ARCH)/kernel-patches.tar $(ARCH)/kernel-modules.tar: $(ARCH)/mobykernel-build
|
||||
docker run --rm mobykernel:build cat /$(notdir $@) > $@ || ! rm $@
|
||||
|
||||
$(ARCH)/bzImage $(ARCH)/zImage: $(ARCH)/aufs-utils.tar $(ARCH)/kernel-source-info $(ARCH)/kernel-patches.tar $(ARCH)/kernel-modules.tar $(ARCH)/mobykernel-build
|
||||
$(ARCH)/bzImage: $(ARCH)/mobykernel-build
|
||||
docker run --rm mobykernel:build cat /linux/arch/$(ARCH)/boot/$(notdir $@) > $@ || ! rm $@
|
||||
|
||||
$(ARCH)/vmlinux: $(ARCH)/bzImage
|
||||
docker run --rm mobykernel:build cat /linux/vmlinux > $@ || ! rm $@
|
||||
docker run --rm --net=none mobykernel:build cat /kernel-modules.tar | tar xf -
|
||||
docker run --rm mobykernel:build cat /aufs-utils.tar | tar xf -
|
||||
docker run --rm mobykernel:build cat /kernel-source-info > etc/kernel-source-info
|
||||
mkdir -p etc
|
||||
cp -a patches etc/kernel-patches
|
||||
|
||||
$(ARCH)/vmlinuz64: $(ARCH)/bzImage
|
||||
cp $< $@
|
||||
|
||||
clean-arch:
|
||||
rm -rf $(ARCH)
|
||||
docker images -q mobykernel:build | xargs docker rmi -f || true
|
||||
|
||||
clean:
|
||||
$(MAKE) clean-arch ARCH=x86_64
|
||||
rm -rf $(ARCH) lib etc usr sbin
|
||||
docker images -q mobykernel:build | xargs docker rmi -f || true
|
||||
|
@ -32,7 +32,7 @@ EOF
|
||||
|
||||
printf 'moby' > /tmp/etc/hostname
|
||||
|
||||
rm /tmp/bin/mkinitrd.sh
|
||||
rm /tmp/mkinitrd.sh
|
||||
|
||||
cd /tmp
|
||||
find . | cpio -H newc -o
|
||||
find . | cpio -H newc -o | gzip -9
|
||||
|
2
alpine/packages/9pmount-vsock/.gitignore
vendored
2
alpine/packages/9pmount-vsock/.gitignore
vendored
@ -1 +1 @@
|
||||
9pmount-vsock
|
||||
sbin/
|
||||
|
@ -1,8 +1,9 @@
|
||||
FROM mobylinux/alpine-build-c:1b53976210ba819823eda5b1d0d3ea337772e97b
|
||||
|
||||
RUN mkdir -p /9pmount-vsock
|
||||
WORKDIR /9pmount-vsock
|
||||
FROM mobylinux/alpine-build-c:1ea690a7438cdd8a5965eaa034e0a0c521d9cb40
|
||||
|
||||
COPY . /9pmount-vsock
|
||||
|
||||
RUN make 9pmount-vsock
|
||||
WORKDIR /9pmount-vsock
|
||||
|
||||
RUN cc -Wall -Werror 9pmount-vsock.c hvsock.c -lpthread -o 9pmount-vsock
|
||||
|
||||
CMD ["tar", "cf", "-", "9pmount-vsock"]
|
||||
|
@ -1,21 +1,9 @@
|
||||
.PHONY: all
|
||||
DEPS=Dockerfile $(wildcard *.c *.h)
|
||||
|
||||
DEPS=9pmount-vsock.c hvsock.c hvsock.h
|
||||
|
||||
all: Dockerfile $(DEPS)
|
||||
docker build -t 9pmount-vsock:build .
|
||||
docker run --rm 9pmount-vsock:build cat 9pmount-vsock > 9pmount-vsock
|
||||
chmod 755 9pmount-vsock
|
||||
|
||||
9pmount-vsock: 9pmount-vsock.o hvsock.o
|
||||
gcc -Wall -Werror -o 9pmount-vsock 9pmount-vsock.o hvsock.o -lpthread
|
||||
|
||||
9pmount-vsock.o: 9pmount-vsock.c hvsock.h
|
||||
gcc -Wall -Werror -c 9pmount-vsock.c
|
||||
|
||||
hvsock.o: hvsock.c hvsock.h
|
||||
gcc -Wall -Werror -c hvsock.c
|
||||
9pmount-vsock: $(DEPS)
|
||||
mkdir -p sbin
|
||||
tar cf - $(DEPS) | docker build -t 9pmount-vsock:build -
|
||||
docker run --rm --net=none 9pmount-vsock:build | tar xf - -C sbin
|
||||
|
||||
clean:
|
||||
rm -f 9pmount-vsock
|
||||
docker images -q 9pmount-vsock:build | xargs docker rmi -f || true
|
||||
rm -rf sbin
|
||||
|
@ -1,28 +1,10 @@
|
||||
all:
|
||||
$(MAKE) -C proxy OS=linux
|
||||
$(MAKE) -C diagnostics OS=linux
|
||||
$(MAKE) -C transfused OS=linux
|
||||
$(MAKE) -C tap-vsockd OS=linux
|
||||
$(MAKE) -C hvtools OS=linux
|
||||
$(MAKE) -C docker OS=Linux
|
||||
$(MAKE) -C nc-vsock OS=linux
|
||||
$(MAKE) -C vsudd OS=linux
|
||||
$(MAKE) -C 9pmount-vsock OS=linux
|
||||
$(MAKE) -C iptables OS=linux
|
||||
DEPS=proxy diagnostics transfused tap-vsockd hvtools docker nc-vsock vsudd 9pmount-vsock iptables
|
||||
.PHONY: clean $(DEPS)
|
||||
|
||||
arm:
|
||||
$(MAKE) -C docker arm OS=Linux ARCH=arm
|
||||
# Not cross building at present (C code)
|
||||
# $(MAKE) -C diagnostics OS=linux ARCH=arm
|
||||
default: $(DEPS)
|
||||
|
||||
$(DEPS):
|
||||
$(MAKE) -C $@
|
||||
|
||||
clean:
|
||||
$(MAKE) -C proxy clean
|
||||
$(MAKE) -C diagnostics clean
|
||||
$(MAKE) -C transfused clean
|
||||
$(MAKE) -C tap-vsockd clean
|
||||
$(MAKE) -C docker clean
|
||||
$(MAKE) -C hvtools clean
|
||||
$(MAKE) -C nc-vsock clean
|
||||
$(MAKE) -C vsudd clean
|
||||
$(MAKE) -C 9pmount-vsock clean
|
||||
$(MAKE) -C iptables clean
|
||||
for f in $(DEPS); do $(MAKE) -C $$f clean; done
|
||||
|
@ -1,3 +0,0 @@
|
||||
The directories below should be turned into proper packages, built from upstream.
|
||||
|
||||
Currently these are temporarily vendored from pinata.
|
@ -13,6 +13,14 @@ start()
|
||||
ulimit -n 1048576
|
||||
ulimit -p unlimited
|
||||
|
||||
[ ! -e /usr/bin/containerd ] && \
|
||||
( cd /usr/bin && \
|
||||
ln -s docker-runc runc && \
|
||||
ln -s docker-containerd-shim containerd-shim && \
|
||||
ln -s docker-containerd-ctr containerd-ctr && \
|
||||
ln -s docker-containerd containerd \
|
||||
)
|
||||
|
||||
/usr/bin/containerd 1>&2 2>/var/log/containerd.log &
|
||||
|
||||
ewaitfile 5 /var/run/containerd/containerd.sock
|
||||
|
3
alpine/packages/diagnostics/.gitignore
vendored
3
alpine/packages/diagnostics/.gitignore
vendored
@ -1,2 +1 @@
|
||||
diagnostics-server
|
||||
/vendor
|
||||
usr/bin/diagnostics-server
|
||||
|
@ -1,13 +1,9 @@
|
||||
FROM mobylinux/alpine-build-go:30067067003d565887d7efe533eba03ed46038d2
|
||||
FROM mobylinux/alpine-build-go:21b413791b4fed2e16126c77c6b860feaf889d70
|
||||
|
||||
RUN mkdir -p /go/src/diagnostics
|
||||
WORKDIR /go/src/diagnostics
|
||||
COPY ./ /go/src/diagnostics-server/
|
||||
|
||||
COPY . /go/src/diagnostics
|
||||
|
||||
ARG GOARCH
|
||||
ARG GOOS
|
||||
WORKDIR /go/src/diagnostics-server
|
||||
|
||||
RUN go install --ldflags '-extldflags "-fno-PIC"'
|
||||
|
||||
RUN [ -f /go/bin/*/diagnostics ] && mv /go/bin/*/diagnostics /go/bin/ || true
|
||||
CMD ["tar", "cf", "-", "-C", "/go/bin", "diagnostics-server"]
|
||||
|
@ -1,15 +1,12 @@
|
||||
all: diagnostics-server
|
||||
all: usr/bin/diagnostics-server
|
||||
|
||||
.PHONY: vendor
|
||||
vendor:
|
||||
mkdir -p ./vendor
|
||||
cp -r ../go/vendor/* ./vendor/
|
||||
DEPS=Dockerfile $(wildcard *.go)
|
||||
|
||||
diagnostics-server: Dockerfile main.go vendor
|
||||
docker build --build-arg GOOS=$(OS) --build-arg GOARCH=$(ARCH) -t diagnostics:build .
|
||||
docker run --rm diagnostics:build cat /go/bin/diagnostics > diagnostics-server
|
||||
chmod 755 diagnostics-server
|
||||
usr/bin/diagnostics-server: $(DEPS) ../vendor/manifest
|
||||
tar cf - $(DEPS) -C .. vendor | docker build -t diagnostics-server:build -
|
||||
docker run --rm --net=none diagnostics-server:build | tar xf - -C usr/bin
|
||||
|
||||
clean:
|
||||
rm -rf diagnostics-server vendor
|
||||
docker images -q diagnostics:build | xargs docker rmi -f || true
|
||||
rm -f usr/bin/diagnostics-server
|
||||
|
||||
.DELETE_ON_ERROR:
|
||||
|
3
alpine/packages/docker/.gitignore
vendored
3
alpine/packages/docker/.gitignore
vendored
@ -1,2 +1 @@
|
||||
bin/
|
||||
docker.git
|
||||
usr/
|
||||
|
@ -3,16 +3,37 @@ ARCH?=x86_64
|
||||
OS?=Linux
|
||||
DOCKER_EXPERIMENTAL?=1
|
||||
|
||||
all: bin
|
||||
DOCKER_BINARIES?=docker dockerd docker-proxy docker-runc docker-containerd docker-containerd-ctr docker-containerd-shim
|
||||
|
||||
all: usr/bin/docker
|
||||
|
||||
TEST_HOST=$(shell if echo "$(DOCKER_VERSION)" | grep -q -- '-rc'; then echo "test.docker.com"; else echo "get.docker.com"; fi)
|
||||
DOCKER_HOST?=$(shell [ "${DOCKER_EXPERIMENTAL}" -eq 1 ] && printf "experimental.docker.com" || printf "${TEST_HOST}")
|
||||
DOCKER_BIN_URL?="https://${DOCKER_HOST}/builds/${OS}/${ARCH}/docker-${DOCKER_VERSION}.tgz"
|
||||
ifeq ($(DOCKER_EXPERIMENTAL),1)
|
||||
DOCKER_HOST=experimental.docker.com
|
||||
DOCKER_IMAGE?=docker:$(DOCKER_VERSION)-experimental
|
||||
else
|
||||
DOCKER_HOST=$(TEST_HOST)
|
||||
DOCKER_IMAGE?=docker:$(DOCKER_VERSION)
|
||||
endif
|
||||
|
||||
bin:
|
||||
mkdir -p bin
|
||||
curl -sSL -o docker.tgz ${DOCKER_BIN_URL}
|
||||
tar xzf docker.tgz && \
|
||||
.PHONY: download hub cleanusr
|
||||
|
||||
ifeq ($(DOCKER_BIN_URL)$(FORCE_CURL),)
|
||||
usr/bin/docker: hub
|
||||
else
|
||||
usr/bin/docker: download
|
||||
endif
|
||||
|
||||
cleanusr:
|
||||
mkdir -p usr/bin
|
||||
rm -f usr/bin/*
|
||||
|
||||
download: cleanusr
|
||||
ifdef DOCKER_BIN_URL
|
||||
curl -sSL ${DOCKER_BIN_URL} | tar xzf -
|
||||
else
|
||||
curl -sSL https://${DOCKER_HOST}/builds/${OS}/${ARCH}/docker-${DOCKER_VERSION}.tgz | tar xzf -
|
||||
endif
|
||||
mv docker/docker-containerd-ctr \
|
||||
docker/docker \
|
||||
docker/docker-containerd \
|
||||
@ -20,9 +41,12 @@ bin:
|
||||
docker/docker-proxy \
|
||||
docker/docker-runc \
|
||||
docker/docker-containerd-shim \
|
||||
bin/
|
||||
rm -rf docker/ docker.tgz
|
||||
chmod +x bin/*
|
||||
usr/bin/
|
||||
|
||||
hub: cleanusr
|
||||
docker run --rm $(DOCKER_IMAGE) tar cf - -C /usr/local/bin $(DOCKER_BINARIES) | tar xf - -C usr/bin
|
||||
|
||||
clean:
|
||||
rm -rf bin docker/ docker.tgz
|
||||
rm -rf usr/ docker/
|
||||
|
||||
.DELETE_ON_ERROR:
|
||||
|
@ -41,6 +41,7 @@ start()
|
||||
esac
|
||||
|
||||
# some config is always in /etc/docker cannot specify alternative eg certs
|
||||
mkdir -p /etc/docker
|
||||
if mobyconfig exists etc/docker
|
||||
then
|
||||
for f in $(mobyconfig find etc/docker)
|
||||
|
1
alpine/packages/go/vendor/github.com/Sirupsen/logrus/.gitignore
generated
vendored
1
alpine/packages/go/vendor/github.com/Sirupsen/logrus/.gitignore
generated
vendored
@ -1 +0,0 @@
|
||||
logrus
|
8
alpine/packages/go/vendor/github.com/Sirupsen/logrus/.travis.yml
generated
vendored
8
alpine/packages/go/vendor/github.com/Sirupsen/logrus/.travis.yml
generated
vendored
@ -1,8 +0,0 @@
|
||||
language: go
|
||||
go:
|
||||
- 1.2
|
||||
- 1.3
|
||||
- 1.4
|
||||
- tip
|
||||
install:
|
||||
- go get -t ./...
|
47
alpine/packages/go/vendor/github.com/Sirupsen/logrus/CHANGELOG.md
generated
vendored
47
alpine/packages/go/vendor/github.com/Sirupsen/logrus/CHANGELOG.md
generated
vendored
@ -1,47 +0,0 @@
|
||||
# 0.8.7
|
||||
|
||||
* logrus/core: fix possible race (#216)
|
||||
* logrus/doc: small typo fixes and doc improvements
|
||||
|
||||
|
||||
# 0.8.6
|
||||
|
||||
* hooks/raven: allow passing an initialized client
|
||||
|
||||
# 0.8.5
|
||||
|
||||
* logrus/core: revert #208
|
||||
|
||||
# 0.8.4
|
||||
|
||||
* formatter/text: fix data race (#218)
|
||||
|
||||
# 0.8.3
|
||||
|
||||
* logrus/core: fix entry log level (#208)
|
||||
* logrus/core: improve performance of text formatter by 40%
|
||||
* logrus/core: expose `LevelHooks` type
|
||||
* logrus/core: add support for DragonflyBSD and NetBSD
|
||||
* formatter/text: print structs more verbosely
|
||||
|
||||
# 0.8.2
|
||||
|
||||
* logrus: fix more Fatal family functions
|
||||
|
||||
# 0.8.1
|
||||
|
||||
* logrus: fix not exiting on `Fatalf` and `Fatalln`
|
||||
|
||||
# 0.8.0
|
||||
|
||||
* logrus: defaults to stderr instead of stdout
|
||||
* hooks/sentry: add special field for `*http.Request`
|
||||
* formatter/text: ignore Windows for colors
|
||||
|
||||
# 0.7.3
|
||||
|
||||
* formatter/\*: allow configuration of timestamp layout
|
||||
|
||||
# 0.7.2
|
||||
|
||||
* formatter/text: Add configuration option for time format (#158)
|
21
alpine/packages/go/vendor/github.com/Sirupsen/logrus/LICENSE
generated
vendored
21
alpine/packages/go/vendor/github.com/Sirupsen/logrus/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Simon Eskildsen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
357
alpine/packages/go/vendor/github.com/Sirupsen/logrus/README.md
generated
vendored
357
alpine/packages/go/vendor/github.com/Sirupsen/logrus/README.md
generated
vendored
@ -1,357 +0,0 @@
|
||||
# Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:"/> [](https://travis-ci.org/Sirupsen/logrus) [][godoc]
|
||||
|
||||
Logrus is a structured logger for Go (golang), completely API compatible with
|
||||
the standard library logger. [Godoc][godoc]. **Please note the Logrus API is not
|
||||
yet stable (pre 1.0). Logrus itself is completely stable and has been used in
|
||||
many large deployments. The core API is unlikely to change much but please
|
||||
version control your Logrus to make sure you aren't fetching latest `master` on
|
||||
every build.**
|
||||
|
||||
Nicely color-coded in development (when a TTY is attached, otherwise just
|
||||
plain text):
|
||||
|
||||

|
||||
|
||||
With `log.Formatter = new(logrus.JSONFormatter)`, for easy parsing by logstash
|
||||
or Splunk:
|
||||
|
||||
```json
|
||||
{"animal":"walrus","level":"info","msg":"A group of walrus emerges from the
|
||||
ocean","size":10,"time":"2014-03-10 19:57:38.562264131 -0400 EDT"}
|
||||
|
||||
{"level":"warning","msg":"The group's number increased tremendously!",
|
||||
"number":122,"omg":true,"time":"2014-03-10 19:57:38.562471297 -0400 EDT"}
|
||||
|
||||
{"animal":"walrus","level":"info","msg":"A giant walrus appears!",
|
||||
"size":10,"time":"2014-03-10 19:57:38.562500591 -0400 EDT"}
|
||||
|
||||
{"animal":"walrus","level":"info","msg":"Tremendously sized cow enters the ocean.",
|
||||
"size":9,"time":"2014-03-10 19:57:38.562527896 -0400 EDT"}
|
||||
|
||||
{"level":"fatal","msg":"The ice breaks!","number":100,"omg":true,
|
||||
"time":"2014-03-10 19:57:38.562543128 -0400 EDT"}
|
||||
```
|
||||
|
||||
With the default `log.Formatter = new(&log.TextFormatter{})` when a TTY is not
|
||||
attached, the output is compatible with the
|
||||
[logfmt](http://godoc.org/github.com/kr/logfmt) format:
|
||||
|
||||
```text
|
||||
time="2015-03-26T01:27:38-04:00" level=debug msg="Started observing beach" animal=walrus number=8
|
||||
time="2015-03-26T01:27:38-04:00" level=info msg="A group of walrus emerges from the ocean" animal=walrus size=10
|
||||
time="2015-03-26T01:27:38-04:00" level=warning msg="The group's number increased tremendously!" number=122 omg=true
|
||||
time="2015-03-26T01:27:38-04:00" level=debug msg="Temperature changes" temperature=-4
|
||||
time="2015-03-26T01:27:38-04:00" level=panic msg="It's over 9000!" animal=orca size=9009
|
||||
time="2015-03-26T01:27:38-04:00" level=fatal msg="The ice breaks!" err=&{0x2082280c0 map[animal:orca size:9009] 2015-03-26 01:27:38.441574009 -0400 EDT panic It's over 9000!} number=100 omg=true
|
||||
exit status 1
|
||||
```
|
||||
|
||||
#### Example
|
||||
|
||||
The simplest way to use Logrus is simply the package-level exported logger:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
log "github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.WithFields(log.Fields{
|
||||
"animal": "walrus",
|
||||
}).Info("A walrus appears")
|
||||
}
|
||||
```
|
||||
|
||||
Note that it's completely api-compatible with the stdlib logger, so you can
|
||||
replace your `log` imports everywhere with `log "github.com/Sirupsen/logrus"`
|
||||
and you'll now have the flexibility of Logrus. You can customize it all you
|
||||
want:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/Sirupsen/logrus/hooks/airbrake"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Log as JSON instead of the default ASCII formatter.
|
||||
log.SetFormatter(&log.JSONFormatter{})
|
||||
|
||||
// Use the Airbrake hook to report errors that have Error severity or above to
|
||||
// an exception tracker. You can create custom hooks, see the Hooks section.
|
||||
log.AddHook(airbrake.NewHook("https://example.com", "xyz", "development"))
|
||||
|
||||
// Output to stderr instead of stdout, could also be a file.
|
||||
log.SetOutput(os.Stderr)
|
||||
|
||||
// Only log the warning severity or above.
|
||||
log.SetLevel(log.WarnLevel)
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.WithFields(log.Fields{
|
||||
"animal": "walrus",
|
||||
"size": 10,
|
||||
}).Info("A group of walrus emerges from the ocean")
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"omg": true,
|
||||
"number": 122,
|
||||
}).Warn("The group's number increased tremendously!")
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"omg": true,
|
||||
"number": 100,
|
||||
}).Fatal("The ice breaks!")
|
||||
|
||||
// A common pattern is to re-use fields between logging statements by re-using
|
||||
// the logrus.Entry returned from WithFields()
|
||||
contextLogger := log.WithFields(log.Fields{
|
||||
"common": "this is a common field",
|
||||
"other": "I also should be logged always",
|
||||
})
|
||||
|
||||
contextLogger.Info("I'll be logged with common and other field")
|
||||
contextLogger.Info("Me too")
|
||||
}
|
||||
```
|
||||
|
||||
For more advanced usage such as logging to multiple locations from the same
|
||||
application, you can also create an instance of the `logrus` Logger:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Create a new instance of the logger. You can have any number of instances.
|
||||
var log = logrus.New()
|
||||
|
||||
func main() {
|
||||
// The API for setting attributes is a little different than the package level
|
||||
// exported logger. See Godoc.
|
||||
log.Out = os.Stderr
|
||||
|
||||
log.WithFields(logrus.Fields{
|
||||
"animal": "walrus",
|
||||
"size": 10,
|
||||
}).Info("A group of walrus emerges from the ocean")
|
||||
}
|
||||
```
|
||||
|
||||
#### Fields
|
||||
|
||||
Logrus encourages careful, structured logging though logging fields instead of
|
||||
long, unparseable error messages. For example, instead of: `log.Fatalf("Failed
|
||||
to send event %s to topic %s with key %d")`, you should log the much more
|
||||
discoverable:
|
||||
|
||||
```go
|
||||
log.WithFields(log.Fields{
|
||||
"event": event,
|
||||
"topic": topic,
|
||||
"key": key,
|
||||
}).Fatal("Failed to send event")
|
||||
```
|
||||
|
||||
We've found this API forces you to think about logging in a way that produces
|
||||
much more useful logging messages. We've been in countless situations where just
|
||||
a single added field to a log statement that was already there would've saved us
|
||||
hours. The `WithFields` call is optional.
|
||||
|
||||
In general, with Logrus using any of the `printf`-family functions should be
|
||||
seen as a hint you should add a field, however, you can still use the
|
||||
`printf`-family functions with Logrus.
|
||||
|
||||
#### Hooks
|
||||
|
||||
You can add hooks for logging levels. For example to send errors to an exception
|
||||
tracking service on `Error`, `Fatal` and `Panic`, info to StatsD or log to
|
||||
multiple places simultaneously, e.g. syslog.
|
||||
|
||||
Logrus comes with [built-in hooks](hooks/). Add those, or your custom hook, in
|
||||
`init`:
|
||||
|
||||
```go
|
||||
import (
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/Sirupsen/logrus/hooks/airbrake"
|
||||
logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog"
|
||||
"log/syslog"
|
||||
)
|
||||
|
||||
func init() {
|
||||
log.AddHook(airbrake.NewHook("https://example.com", "xyz", "development"))
|
||||
|
||||
hook, err := logrus_syslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
|
||||
if err != nil {
|
||||
log.Error("Unable to connect to local syslog daemon")
|
||||
} else {
|
||||
log.AddHook(hook)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
| Hook | Description |
|
||||
| ----- | ----------- |
|
||||
| [Airbrake](https://github.com/Sirupsen/logrus/blob/master/hooks/airbrake/airbrake.go) | Send errors to an exception tracking service compatible with the Airbrake API. Uses [`airbrake-go`](https://github.com/tobi/airbrake-go) behind the scenes. |
|
||||
| [Papertrail](https://github.com/Sirupsen/logrus/blob/master/hooks/papertrail/papertrail.go) | Send errors to the Papertrail hosted logging service via UDP. |
|
||||
| [Syslog](https://github.com/Sirupsen/logrus/blob/master/hooks/syslog/syslog.go) | Send errors to remote syslog server. Uses standard library `log/syslog` behind the scenes. |
|
||||
| [BugSnag](https://github.com/Sirupsen/logrus/blob/master/hooks/bugsnag/bugsnag.go) | Send errors to the Bugsnag exception tracking service. |
|
||||
| [Sentry](https://github.com/Sirupsen/logrus/blob/master/hooks/sentry/sentry.go) | Send errors to the Sentry error logging and aggregation service. |
|
||||
| [Hiprus](https://github.com/nubo/hiprus) | Send errors to a channel in hipchat. |
|
||||
| [Logrusly](https://github.com/sebest/logrusly) | Send logs to [Loggly](https://www.loggly.com/) |
|
||||
| [Slackrus](https://github.com/johntdyer/slackrus) | Hook for Slack chat. |
|
||||
| [Journalhook](https://github.com/wercker/journalhook) | Hook for logging to `systemd-journald` |
|
||||
| [Graylog](https://github.com/gemnasium/logrus-hooks/tree/master/graylog) | Hook for logging to [Graylog](http://graylog2.org/) |
|
||||
| [Raygun](https://github.com/squirkle/logrus-raygun-hook) | Hook for logging to [Raygun.io](http://raygun.io/) |
|
||||
| [LFShook](https://github.com/rifflock/lfshook) | Hook for logging to the local filesystem |
|
||||
| [Honeybadger](https://github.com/agonzalezro/logrus_honeybadger) | Hook for sending exceptions to Honeybadger |
|
||||
| [Mail](https://github.com/zbindenren/logrus_mail) | Hook for sending exceptions via mail |
|
||||
| [Rollrus](https://github.com/heroku/rollrus) | Hook for sending errors to rollbar |
|
||||
| [Fluentd](https://github.com/evalphobia/logrus_fluent) | Hook for logging to fluentd |
|
||||
| [Mongodb](https://github.com/weekface/mgorus) | Hook for logging to mongodb |
|
||||
|
||||
#### Level logging
|
||||
|
||||
Logrus has six logging levels: Debug, Info, Warning, Error, Fatal and Panic.
|
||||
|
||||
```go
|
||||
log.Debug("Useful debugging information.")
|
||||
log.Info("Something noteworthy happened!")
|
||||
log.Warn("You should probably take a look at this.")
|
||||
log.Error("Something failed but I'm not quitting.")
|
||||
// Calls os.Exit(1) after logging
|
||||
log.Fatal("Bye.")
|
||||
// Calls panic() after logging
|
||||
log.Panic("I'm bailing.")
|
||||
```
|
||||
|
||||
You can set the logging level on a `Logger`, then it will only log entries with
|
||||
that severity or anything above it:
|
||||
|
||||
```go
|
||||
// Will log anything that is info or above (warn, error, fatal, panic). Default.
|
||||
log.SetLevel(log.InfoLevel)
|
||||
```
|
||||
|
||||
It may be useful to set `log.Level = logrus.DebugLevel` in a debug or verbose
|
||||
environment if your application has that.
|
||||
|
||||
#### Entries
|
||||
|
||||
Besides the fields added with `WithField` or `WithFields` some fields are
|
||||
automatically added to all logging events:
|
||||
|
||||
1. `time`. The timestamp when the entry was created.
|
||||
2. `msg`. The logging message passed to `{Info,Warn,Error,Fatal,Panic}` after
|
||||
the `AddFields` call. E.g. `Failed to send event.`
|
||||
3. `level`. The logging level. E.g. `info`.
|
||||
|
||||
#### Environments
|
||||
|
||||
Logrus has no notion of environment.
|
||||
|
||||
If you wish for hooks and formatters to only be used in specific environments,
|
||||
you should handle that yourself. For example, if your application has a global
|
||||
variable `Environment`, which is a string representation of the environment you
|
||||
could do:
|
||||
|
||||
```go
|
||||
import (
|
||||
log "github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
init() {
|
||||
// do something here to set environment depending on an environment variable
|
||||
// or command-line flag
|
||||
if Environment == "production" {
|
||||
log.SetFormatter(&log.JSONFormatter{})
|
||||
} else {
|
||||
// The TextFormatter is default, you don't actually have to do this.
|
||||
log.SetFormatter(&log.TextFormatter{})
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This configuration is how `logrus` was intended to be used, but JSON in
|
||||
production is mostly only useful if you do log aggregation with tools like
|
||||
Splunk or Logstash.
|
||||
|
||||
#### Formatters
|
||||
|
||||
The built-in logging formatters are:
|
||||
|
||||
* `logrus.TextFormatter`. Logs the event in colors if stdout is a tty, otherwise
|
||||
without colors.
|
||||
* *Note:* to force colored output when there is no TTY, set the `ForceColors`
|
||||
field to `true`. To force no colored output even if there is a TTY set the
|
||||
`DisableColors` field to `true`
|
||||
* `logrus.JSONFormatter`. Logs fields as JSON.
|
||||
* `logrus_logstash.LogstashFormatter`. Logs fields as Logstash Events (http://logstash.net).
|
||||
|
||||
```go
|
||||
logrus.SetFormatter(&logrus_logstash.LogstashFormatter{Type: “application_name"})
|
||||
```
|
||||
|
||||
Third party logging formatters:
|
||||
|
||||
* [`zalgo`](https://github.com/aybabtme/logzalgo): invoking the P͉̫o̳̼̊w̖͈̰͎e̬͔̭͂r͚̼̹̲ ̫͓͉̳͈ō̠͕͖̚f̝͍̠ ͕̲̞͖͑Z̖̫̤̫ͪa͉̬͈̗l͖͎g̳̥o̰̥̅!̣͔̲̻͊̄ ̙̘̦̹̦.
|
||||
|
||||
You can define your formatter by implementing the `Formatter` interface,
|
||||
requiring a `Format` method. `Format` takes an `*Entry`. `entry.Data` is a
|
||||
`Fields` type (`map[string]interface{}`) with all your fields as well as the
|
||||
default ones (see Entries section above):
|
||||
|
||||
```go
|
||||
type MyJSONFormatter struct {
|
||||
}
|
||||
|
||||
log.SetFormatter(new(MyJSONFormatter))
|
||||
|
||||
func (f *MyJSONFormatter) Format(entry *Entry) ([]byte, error) {
|
||||
// Note this doesn't include Time, Level and Message which are available on
|
||||
// the Entry. Consult `godoc` on information about those fields or read the
|
||||
// source of the official loggers.
|
||||
serialized, err := json.Marshal(entry.Data)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
|
||||
}
|
||||
return append(serialized, '\n'), nil
|
||||
}
|
||||
```
|
||||
|
||||
#### Logger as an `io.Writer`
|
||||
|
||||
Logrus can be transformed into an `io.Writer`. That writer is the end of an `io.Pipe` and it is your responsibility to close it.
|
||||
|
||||
```go
|
||||
w := logger.Writer()
|
||||
defer w.Close()
|
||||
|
||||
srv := http.Server{
|
||||
// create a stdlib log.Logger that writes to
|
||||
// logrus.Logger.
|
||||
ErrorLog: log.New(w, "", 0),
|
||||
}
|
||||
```
|
||||
|
||||
Each line written to that writer will be printed the usual way, using formatters
|
||||
and hooks. The level for those entries is `info`.
|
||||
|
||||
#### Rotation
|
||||
|
||||
Log rotation is not provided with Logrus. Log rotation should be done by an
|
||||
external program (like `logrotate(8)`) that can compress and delete old log
|
||||
entries. It should not be a feature of the application-level logger.
|
||||
|
||||
|
||||
[godoc]: https://godoc.org/github.com/Sirupsen/logrus
|
26
alpine/packages/go/vendor/github.com/Sirupsen/logrus/doc.go
generated
vendored
26
alpine/packages/go/vendor/github.com/Sirupsen/logrus/doc.go
generated
vendored
@ -1,26 +0,0 @@
|
||||
/*
|
||||
Package logrus is a structured logger for Go, completely API compatible with the standard library logger.
|
||||
|
||||
|
||||
The simplest way to use Logrus is simply the package-level exported logger:
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
log "github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.WithFields(log.Fields{
|
||||
"animal": "walrus",
|
||||
"number": 1,
|
||||
"size": 10,
|
||||
}).Info("A walrus appears")
|
||||
}
|
||||
|
||||
Output:
|
||||
time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10
|
||||
|
||||
For a full guide visit https://github.com/Sirupsen/logrus
|
||||
*/
|
||||
package logrus
|
264
alpine/packages/go/vendor/github.com/Sirupsen/logrus/entry.go
generated
vendored
264
alpine/packages/go/vendor/github.com/Sirupsen/logrus/entry.go
generated
vendored
@ -1,264 +0,0 @@
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Defines the key when adding errors using WithError.
|
||||
var ErrorKey = "error"
|
||||
|
||||
// An entry is the final or intermediate Logrus logging entry. It contains all
|
||||
// the fields passed with WithField{,s}. It's finally logged when Debug, Info,
|
||||
// Warn, Error, Fatal or Panic is called on it. These objects can be reused and
|
||||
// passed around as much as you wish to avoid field duplication.
|
||||
type Entry struct {
|
||||
Logger *Logger
|
||||
|
||||
// Contains all the fields set by the user.
|
||||
Data Fields
|
||||
|
||||
// Time at which the log entry was created
|
||||
Time time.Time
|
||||
|
||||
// Level the log entry was logged at: Debug, Info, Warn, Error, Fatal or Panic
|
||||
Level Level
|
||||
|
||||
// Message passed to Debug, Info, Warn, Error, Fatal or Panic
|
||||
Message string
|
||||
}
|
||||
|
||||
func NewEntry(logger *Logger) *Entry {
|
||||
return &Entry{
|
||||
Logger: logger,
|
||||
// Default is three fields, give a little extra room
|
||||
Data: make(Fields, 5),
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a reader for the entry, which is a proxy to the formatter.
|
||||
func (entry *Entry) Reader() (*bytes.Buffer, error) {
|
||||
serialized, err := entry.Logger.Formatter.Format(entry)
|
||||
return bytes.NewBuffer(serialized), err
|
||||
}
|
||||
|
||||
// Returns the string representation from the reader and ultimately the
|
||||
// formatter.
|
||||
func (entry *Entry) String() (string, error) {
|
||||
reader, err := entry.Reader()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return reader.String(), err
|
||||
}
|
||||
|
||||
// Add an error as single field (using the key defined in ErrorKey) to the Entry.
|
||||
func (entry *Entry) WithError(err error) *Entry {
|
||||
return entry.WithField(ErrorKey, err)
|
||||
}
|
||||
|
||||
// Add a single field to the Entry.
|
||||
func (entry *Entry) WithField(key string, value interface{}) *Entry {
|
||||
return entry.WithFields(Fields{key: value})
|
||||
}
|
||||
|
||||
// Add a map of fields to the Entry.
|
||||
func (entry *Entry) WithFields(fields Fields) *Entry {
|
||||
data := Fields{}
|
||||
for k, v := range entry.Data {
|
||||
data[k] = v
|
||||
}
|
||||
for k, v := range fields {
|
||||
data[k] = v
|
||||
}
|
||||
return &Entry{Logger: entry.Logger, Data: data}
|
||||
}
|
||||
|
||||
// This function is not declared with a pointer value because otherwise
|
||||
// race conditions will occur when using multiple goroutines
|
||||
func (entry Entry) log(level Level, msg string) {
|
||||
entry.Time = time.Now()
|
||||
entry.Level = level
|
||||
entry.Message = msg
|
||||
|
||||
if err := entry.Logger.Hooks.Fire(level, &entry); err != nil {
|
||||
entry.Logger.mu.Lock()
|
||||
fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err)
|
||||
entry.Logger.mu.Unlock()
|
||||
}
|
||||
|
||||
reader, err := entry.Reader()
|
||||
if err != nil {
|
||||
entry.Logger.mu.Lock()
|
||||
fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err)
|
||||
entry.Logger.mu.Unlock()
|
||||
}
|
||||
|
||||
entry.Logger.mu.Lock()
|
||||
defer entry.Logger.mu.Unlock()
|
||||
|
||||
_, err = io.Copy(entry.Logger.Out, reader)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err)
|
||||
}
|
||||
|
||||
// To avoid Entry#log() returning a value that only would make sense for
|
||||
// panic() to use in Entry#Panic(), we avoid the allocation by checking
|
||||
// directly here.
|
||||
if level <= PanicLevel {
|
||||
panic(&entry)
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Debug(args ...interface{}) {
|
||||
if entry.Logger.Level >= DebugLevel {
|
||||
entry.log(DebugLevel, fmt.Sprint(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Print(args ...interface{}) {
|
||||
entry.Info(args...)
|
||||
}
|
||||
|
||||
func (entry *Entry) Info(args ...interface{}) {
|
||||
if entry.Logger.Level >= InfoLevel {
|
||||
entry.log(InfoLevel, fmt.Sprint(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Warn(args ...interface{}) {
|
||||
if entry.Logger.Level >= WarnLevel {
|
||||
entry.log(WarnLevel, fmt.Sprint(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Warning(args ...interface{}) {
|
||||
entry.Warn(args...)
|
||||
}
|
||||
|
||||
func (entry *Entry) Error(args ...interface{}) {
|
||||
if entry.Logger.Level >= ErrorLevel {
|
||||
entry.log(ErrorLevel, fmt.Sprint(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Fatal(args ...interface{}) {
|
||||
if entry.Logger.Level >= FatalLevel {
|
||||
entry.log(FatalLevel, fmt.Sprint(args...))
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (entry *Entry) Panic(args ...interface{}) {
|
||||
if entry.Logger.Level >= PanicLevel {
|
||||
entry.log(PanicLevel, fmt.Sprint(args...))
|
||||
}
|
||||
panic(fmt.Sprint(args...))
|
||||
}
|
||||
|
||||
// Entry Printf family functions
|
||||
|
||||
func (entry *Entry) Debugf(format string, args ...interface{}) {
|
||||
if entry.Logger.Level >= DebugLevel {
|
||||
entry.Debug(fmt.Sprintf(format, args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Infof(format string, args ...interface{}) {
|
||||
if entry.Logger.Level >= InfoLevel {
|
||||
entry.Info(fmt.Sprintf(format, args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Printf(format string, args ...interface{}) {
|
||||
entry.Infof(format, args...)
|
||||
}
|
||||
|
||||
func (entry *Entry) Warnf(format string, args ...interface{}) {
|
||||
if entry.Logger.Level >= WarnLevel {
|
||||
entry.Warn(fmt.Sprintf(format, args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Warningf(format string, args ...interface{}) {
|
||||
entry.Warnf(format, args...)
|
||||
}
|
||||
|
||||
func (entry *Entry) Errorf(format string, args ...interface{}) {
|
||||
if entry.Logger.Level >= ErrorLevel {
|
||||
entry.Error(fmt.Sprintf(format, args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Fatalf(format string, args ...interface{}) {
|
||||
if entry.Logger.Level >= FatalLevel {
|
||||
entry.Fatal(fmt.Sprintf(format, args...))
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (entry *Entry) Panicf(format string, args ...interface{}) {
|
||||
if entry.Logger.Level >= PanicLevel {
|
||||
entry.Panic(fmt.Sprintf(format, args...))
|
||||
}
|
||||
}
|
||||
|
||||
// Entry Println family functions
|
||||
|
||||
func (entry *Entry) Debugln(args ...interface{}) {
|
||||
if entry.Logger.Level >= DebugLevel {
|
||||
entry.Debug(entry.sprintlnn(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Infoln(args ...interface{}) {
|
||||
if entry.Logger.Level >= InfoLevel {
|
||||
entry.Info(entry.sprintlnn(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Println(args ...interface{}) {
|
||||
entry.Infoln(args...)
|
||||
}
|
||||
|
||||
func (entry *Entry) Warnln(args ...interface{}) {
|
||||
if entry.Logger.Level >= WarnLevel {
|
||||
entry.Warn(entry.sprintlnn(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Warningln(args ...interface{}) {
|
||||
entry.Warnln(args...)
|
||||
}
|
||||
|
||||
func (entry *Entry) Errorln(args ...interface{}) {
|
||||
if entry.Logger.Level >= ErrorLevel {
|
||||
entry.Error(entry.sprintlnn(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Fatalln(args ...interface{}) {
|
||||
if entry.Logger.Level >= FatalLevel {
|
||||
entry.Fatal(entry.sprintlnn(args...))
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (entry *Entry) Panicln(args ...interface{}) {
|
||||
if entry.Logger.Level >= PanicLevel {
|
||||
entry.Panic(entry.sprintlnn(args...))
|
||||
}
|
||||
}
|
||||
|
||||
// Sprintlnn => Sprint no newline. This is to get the behavior of how
|
||||
// fmt.Sprintln where spaces are always added between operands, regardless of
|
||||
// their type. Instead of vendoring the Sprintln implementation to spare a
|
||||
// string allocation, we do the simplest thing.
|
||||
func (entry *Entry) sprintlnn(args ...interface{}) string {
|
||||
msg := fmt.Sprintln(args...)
|
||||
return msg[:len(msg)-1]
|
||||
}
|
50
alpine/packages/go/vendor/github.com/Sirupsen/logrus/examples/basic/basic.go
generated
vendored
50
alpine/packages/go/vendor/github.com/Sirupsen/logrus/examples/basic/basic.go
generated
vendored
@ -1,50 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
var log = logrus.New()
|
||||
|
||||
func init() {
|
||||
log.Formatter = new(logrus.JSONFormatter)
|
||||
log.Formatter = new(logrus.TextFormatter) // default
|
||||
log.Level = logrus.DebugLevel
|
||||
}
|
||||
|
||||
func main() {
|
||||
defer func() {
|
||||
err := recover()
|
||||
if err != nil {
|
||||
log.WithFields(logrus.Fields{
|
||||
"omg": true,
|
||||
"err": err,
|
||||
"number": 100,
|
||||
}).Fatal("The ice breaks!")
|
||||
}
|
||||
}()
|
||||
|
||||
log.WithFields(logrus.Fields{
|
||||
"animal": "walrus",
|
||||
"number": 8,
|
||||
}).Debug("Started observing beach")
|
||||
|
||||
log.WithFields(logrus.Fields{
|
||||
"animal": "walrus",
|
||||
"size": 10,
|
||||
}).Info("A group of walrus emerges from the ocean")
|
||||
|
||||
log.WithFields(logrus.Fields{
|
||||
"omg": true,
|
||||
"number": 122,
|
||||
}).Warn("The group's number increased tremendously!")
|
||||
|
||||
log.WithFields(logrus.Fields{
|
||||
"temperature": -4,
|
||||
}).Debug("Temperature changes")
|
||||
|
||||
log.WithFields(logrus.Fields{
|
||||
"animal": "orca",
|
||||
"size": 9009,
|
||||
}).Panic("It's over 9000!")
|
||||
}
|
30
alpine/packages/go/vendor/github.com/Sirupsen/logrus/examples/hook/hook.go
generated
vendored
30
alpine/packages/go/vendor/github.com/Sirupsen/logrus/examples/hook/hook.go
generated
vendored
@ -1,30 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/Sirupsen/logrus/hooks/airbrake"
|
||||
)
|
||||
|
||||
var log = logrus.New()
|
||||
|
||||
func init() {
|
||||
log.Formatter = new(logrus.TextFormatter) // default
|
||||
log.Hooks.Add(airbrake.NewHook("https://example.com", "xyz", "development"))
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.WithFields(logrus.Fields{
|
||||
"animal": "walrus",
|
||||
"size": 10,
|
||||
}).Info("A group of walrus emerges from the ocean")
|
||||
|
||||
log.WithFields(logrus.Fields{
|
||||
"omg": true,
|
||||
"number": 122,
|
||||
}).Warn("The group's number increased tremendously!")
|
||||
|
||||
log.WithFields(logrus.Fields{
|
||||
"omg": true,
|
||||
"number": 100,
|
||||
}).Fatal("The ice breaks!")
|
||||
}
|
193
alpine/packages/go/vendor/github.com/Sirupsen/logrus/exported.go
generated
vendored
193
alpine/packages/go/vendor/github.com/Sirupsen/logrus/exported.go
generated
vendored
@ -1,193 +0,0 @@
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
var (
|
||||
// std is the name of the standard logger in stdlib `log`
|
||||
std = New()
|
||||
)
|
||||
|
||||
func StandardLogger() *Logger {
|
||||
return std
|
||||
}
|
||||
|
||||
// SetOutput sets the standard logger output.
|
||||
func SetOutput(out io.Writer) {
|
||||
std.mu.Lock()
|
||||
defer std.mu.Unlock()
|
||||
std.Out = out
|
||||
}
|
||||
|
||||
// SetFormatter sets the standard logger formatter.
|
||||
func SetFormatter(formatter Formatter) {
|
||||
std.mu.Lock()
|
||||
defer std.mu.Unlock()
|
||||
std.Formatter = formatter
|
||||
}
|
||||
|
||||
// SetLevel sets the standard logger level.
|
||||
func SetLevel(level Level) {
|
||||
std.mu.Lock()
|
||||
defer std.mu.Unlock()
|
||||
std.Level = level
|
||||
}
|
||||
|
||||
// GetLevel returns the standard logger level.
|
||||
func GetLevel() Level {
|
||||
std.mu.Lock()
|
||||
defer std.mu.Unlock()
|
||||
return std.Level
|
||||
}
|
||||
|
||||
// AddHook adds a hook to the standard logger hooks.
|
||||
func AddHook(hook Hook) {
|
||||
std.mu.Lock()
|
||||
defer std.mu.Unlock()
|
||||
std.Hooks.Add(hook)
|
||||
}
|
||||
|
||||
// WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key.
|
||||
func WithError(err error) *Entry {
|
||||
return std.WithField(ErrorKey, err)
|
||||
}
|
||||
|
||||
// WithField creates an entry from the standard logger and adds a field to
|
||||
// it. If you want multiple fields, use `WithFields`.
|
||||
//
|
||||
// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
|
||||
// or Panic on the Entry it returns.
|
||||
func WithField(key string, value interface{}) *Entry {
|
||||
return std.WithField(key, value)
|
||||
}
|
||||
|
||||
// WithFields creates an entry from the standard logger and adds multiple
|
||||
// fields to it. This is simply a helper for `WithField`, invoking it
|
||||
// once for each field.
|
||||
//
|
||||
// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
|
||||
// or Panic on the Entry it returns.
|
||||
func WithFields(fields Fields) *Entry {
|
||||
return std.WithFields(fields)
|
||||
}
|
||||
|
||||
// Debug logs a message at level Debug on the standard logger.
|
||||
func Debug(args ...interface{}) {
|
||||
std.Debug(args...)
|
||||
}
|
||||
|
||||
// Print logs a message at level Info on the standard logger.
|
||||
func Print(args ...interface{}) {
|
||||
std.Print(args...)
|
||||
}
|
||||
|
||||
// Info logs a message at level Info on the standard logger.
|
||||
func Info(args ...interface{}) {
|
||||
std.Info(args...)
|
||||
}
|
||||
|
||||
// Warn logs a message at level Warn on the standard logger.
|
||||
func Warn(args ...interface{}) {
|
||||
std.Warn(args...)
|
||||
}
|
||||
|
||||
// Warning logs a message at level Warn on the standard logger.
|
||||
func Warning(args ...interface{}) {
|
||||
std.Warning(args...)
|
||||
}
|
||||
|
||||
// Error logs a message at level Error on the standard logger.
|
||||
func Error(args ...interface{}) {
|
||||
std.Error(args...)
|
||||
}
|
||||
|
||||
// Panic logs a message at level Panic on the standard logger.
|
||||
func Panic(args ...interface{}) {
|
||||
std.Panic(args...)
|
||||
}
|
||||
|
||||
// Fatal logs a message at level Fatal on the standard logger.
|
||||
func Fatal(args ...interface{}) {
|
||||
std.Fatal(args...)
|
||||
}
|
||||
|
||||
// Debugf logs a message at level Debug on the standard logger.
|
||||
func Debugf(format string, args ...interface{}) {
|
||||
std.Debugf(format, args...)
|
||||
}
|
||||
|
||||
// Printf logs a message at level Info on the standard logger.
|
||||
func Printf(format string, args ...interface{}) {
|
||||
std.Printf(format, args...)
|
||||
}
|
||||
|
||||
// Infof logs a message at level Info on the standard logger.
|
||||
func Infof(format string, args ...interface{}) {
|
||||
std.Infof(format, args...)
|
||||
}
|
||||
|
||||
// Warnf logs a message at level Warn on the standard logger.
|
||||
func Warnf(format string, args ...interface{}) {
|
||||
std.Warnf(format, args...)
|
||||
}
|
||||
|
||||
// Warningf logs a message at level Warn on the standard logger.
|
||||
func Warningf(format string, args ...interface{}) {
|
||||
std.Warningf(format, args...)
|
||||
}
|
||||
|
||||
// Errorf logs a message at level Error on the standard logger.
|
||||
func Errorf(format string, args ...interface{}) {
|
||||
std.Errorf(format, args...)
|
||||
}
|
||||
|
||||
// Panicf logs a message at level Panic on the standard logger.
|
||||
func Panicf(format string, args ...interface{}) {
|
||||
std.Panicf(format, args...)
|
||||
}
|
||||
|
||||
// Fatalf logs a message at level Fatal on the standard logger.
|
||||
func Fatalf(format string, args ...interface{}) {
|
||||
std.Fatalf(format, args...)
|
||||
}
|
||||
|
||||
// Debugln logs a message at level Debug on the standard logger.
|
||||
func Debugln(args ...interface{}) {
|
||||
std.Debugln(args...)
|
||||
}
|
||||
|
||||
// Println logs a message at level Info on the standard logger.
|
||||
func Println(args ...interface{}) {
|
||||
std.Println(args...)
|
||||
}
|
||||
|
||||
// Infoln logs a message at level Info on the standard logger.
|
||||
func Infoln(args ...interface{}) {
|
||||
std.Infoln(args...)
|
||||
}
|
||||
|
||||
// Warnln logs a message at level Warn on the standard logger.
|
||||
func Warnln(args ...interface{}) {
|
||||
std.Warnln(args...)
|
||||
}
|
||||
|
||||
// Warningln logs a message at level Warn on the standard logger.
|
||||
func Warningln(args ...interface{}) {
|
||||
std.Warningln(args...)
|
||||
}
|
||||
|
||||
// Errorln logs a message at level Error on the standard logger.
|
||||
func Errorln(args ...interface{}) {
|
||||
std.Errorln(args...)
|
||||
}
|
||||
|
||||
// Panicln logs a message at level Panic on the standard logger.
|
||||
func Panicln(args ...interface{}) {
|
||||
std.Panicln(args...)
|
||||
}
|
||||
|
||||
// Fatalln logs a message at level Fatal on the standard logger.
|
||||
func Fatalln(args ...interface{}) {
|
||||
std.Fatalln(args...)
|
||||
}
|
48
alpine/packages/go/vendor/github.com/Sirupsen/logrus/formatter.go
generated
vendored
48
alpine/packages/go/vendor/github.com/Sirupsen/logrus/formatter.go
generated
vendored
@ -1,48 +0,0 @@
|
||||
package logrus
|
||||
|
||||
import "time"
|
||||
|
||||
const DefaultTimestampFormat = time.RFC3339
|
||||
|
||||
// The Formatter interface is used to implement a custom Formatter. It takes an
|
||||
// `Entry`. It exposes all the fields, including the default ones:
|
||||
//
|
||||
// * `entry.Data["msg"]`. The message passed from Info, Warn, Error ..
|
||||
// * `entry.Data["time"]`. The timestamp.
|
||||
// * `entry.Data["level"]. The level the entry was logged at.
|
||||
//
|
||||
// Any additional fields added with `WithField` or `WithFields` are also in
|
||||
// `entry.Data`. Format is expected to return an array of bytes which are then
|
||||
// logged to `logger.Out`.
|
||||
type Formatter interface {
|
||||
Format(*Entry) ([]byte, error)
|
||||
}
|
||||
|
||||
// This is to not silently overwrite `time`, `msg` and `level` fields when
|
||||
// dumping it. If this code wasn't there doing:
|
||||
//
|
||||
// logrus.WithField("level", 1).Info("hello")
|
||||
//
|
||||
// Would just silently drop the user provided level. Instead with this code
|
||||
// it'll logged as:
|
||||
//
|
||||
// {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."}
|
||||
//
|
||||
// It's not exported because it's still using Data in an opinionated way. It's to
|
||||
// avoid code duplication between the two default formatters.
|
||||
func prefixFieldClashes(data Fields) {
|
||||
_, ok := data["time"]
|
||||
if ok {
|
||||
data["fields.time"] = data["time"]
|
||||
}
|
||||
|
||||
_, ok = data["msg"]
|
||||
if ok {
|
||||
data["fields.msg"] = data["msg"]
|
||||
}
|
||||
|
||||
_, ok = data["level"]
|
||||
if ok {
|
||||
data["fields.level"] = data["level"]
|
||||
}
|
||||
}
|
56
alpine/packages/go/vendor/github.com/Sirupsen/logrus/formatters/logstash/logstash.go
generated
vendored
56
alpine/packages/go/vendor/github.com/Sirupsen/logrus/formatters/logstash/logstash.go
generated
vendored
@ -1,56 +0,0 @@
|
||||
package logstash
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Formatter generates json in logstash format.
|
||||
// Logstash site: http://logstash.net/
|
||||
type LogstashFormatter struct {
|
||||
Type string // if not empty use for logstash type field.
|
||||
|
||||
// TimestampFormat sets the format used for timestamps.
|
||||
TimestampFormat string
|
||||
}
|
||||
|
||||
func (f *LogstashFormatter) Format(entry *logrus.Entry) ([]byte, error) {
|
||||
entry.Data["@version"] = 1
|
||||
|
||||
if f.TimestampFormat == "" {
|
||||
f.TimestampFormat = logrus.DefaultTimestampFormat
|
||||
}
|
||||
|
||||
entry.Data["@timestamp"] = entry.Time.Format(f.TimestampFormat)
|
||||
|
||||
// set message field
|
||||
v, ok := entry.Data["message"]
|
||||
if ok {
|
||||
entry.Data["fields.message"] = v
|
||||
}
|
||||
entry.Data["message"] = entry.Message
|
||||
|
||||
// set level field
|
||||
v, ok = entry.Data["level"]
|
||||
if ok {
|
||||
entry.Data["fields.level"] = v
|
||||
}
|
||||
entry.Data["level"] = entry.Level.String()
|
||||
|
||||
// set type field
|
||||
if f.Type != "" {
|
||||
v, ok = entry.Data["type"]
|
||||
if ok {
|
||||
entry.Data["fields.type"] = v
|
||||
}
|
||||
entry.Data["type"] = f.Type
|
||||
}
|
||||
|
||||
serialized, err := json.Marshal(entry.Data)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
|
||||
}
|
||||
return append(serialized, '\n'), nil
|
||||
}
|
34
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks.go
generated
vendored
34
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks.go
generated
vendored
@ -1,34 +0,0 @@
|
||||
package logrus
|
||||
|
||||
// A hook to be fired when logging on the logging levels returned from
|
||||
// `Levels()` on your implementation of the interface. Note that this is not
|
||||
// fired in a goroutine or a channel with workers, you should handle such
|
||||
// functionality yourself if your call is non-blocking and you don't wish for
|
||||
// the logging calls for levels returned from `Levels()` to block.
|
||||
type Hook interface {
|
||||
Levels() []Level
|
||||
Fire(*Entry) error
|
||||
}
|
||||
|
||||
// Internal type for storing the hooks on a logger instance.
|
||||
type LevelHooks map[Level][]Hook
|
||||
|
||||
// Add a hook to an instance of logger. This is called with
|
||||
// `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface.
|
||||
func (hooks LevelHooks) Add(hook Hook) {
|
||||
for _, level := range hook.Levels() {
|
||||
hooks[level] = append(hooks[level], hook)
|
||||
}
|
||||
}
|
||||
|
||||
// Fire all the hooks for the passed level. Used by `entry.log` to fire
|
||||
// appropriate hooks for a log entry.
|
||||
func (hooks LevelHooks) Fire(level Level, entry *Entry) error {
|
||||
for _, hook := range hooks[level] {
|
||||
if err := hook.Fire(entry); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
54
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks/airbrake/airbrake.go
generated
vendored
54
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks/airbrake/airbrake.go
generated
vendored
@ -1,54 +0,0 @@
|
||||
package airbrake
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/tobi/airbrake-go"
|
||||
)
|
||||
|
||||
// AirbrakeHook to send exceptions to an exception-tracking service compatible
|
||||
// with the Airbrake API.
|
||||
type airbrakeHook struct {
|
||||
APIKey string
|
||||
Endpoint string
|
||||
Environment string
|
||||
}
|
||||
|
||||
func NewHook(endpoint, apiKey, env string) *airbrakeHook {
|
||||
return &airbrakeHook{
|
||||
APIKey: apiKey,
|
||||
Endpoint: endpoint,
|
||||
Environment: env,
|
||||
}
|
||||
}
|
||||
|
||||
func (hook *airbrakeHook) Fire(entry *logrus.Entry) error {
|
||||
airbrake.ApiKey = hook.APIKey
|
||||
airbrake.Endpoint = hook.Endpoint
|
||||
airbrake.Environment = hook.Environment
|
||||
|
||||
var notifyErr error
|
||||
err, ok := entry.Data["error"].(error)
|
||||
if ok {
|
||||
notifyErr = err
|
||||
} else {
|
||||
notifyErr = errors.New(entry.Message)
|
||||
}
|
||||
|
||||
airErr := airbrake.Notify(notifyErr)
|
||||
if airErr != nil {
|
||||
return fmt.Errorf("Failed to send error to Airbrake: %s", airErr)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (hook *airbrakeHook) Levels() []logrus.Level {
|
||||
return []logrus.Level{
|
||||
logrus.ErrorLevel,
|
||||
logrus.FatalLevel,
|
||||
logrus.PanicLevel,
|
||||
}
|
||||
}
|
68
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks/bugsnag/bugsnag.go
generated
vendored
68
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks/bugsnag/bugsnag.go
generated
vendored
@ -1,68 +0,0 @@
|
||||
package logrus_bugsnag
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/bugsnag/bugsnag-go"
|
||||
)
|
||||
|
||||
type bugsnagHook struct{}
|
||||
|
||||
// ErrBugsnagUnconfigured is returned if NewBugsnagHook is called before
|
||||
// bugsnag.Configure. Bugsnag must be configured before the hook.
|
||||
var ErrBugsnagUnconfigured = errors.New("bugsnag must be configured before installing this logrus hook")
|
||||
|
||||
// ErrBugsnagSendFailed indicates that the hook failed to submit an error to
|
||||
// bugsnag. The error was successfully generated, but `bugsnag.Notify()`
|
||||
// failed.
|
||||
type ErrBugsnagSendFailed struct {
|
||||
err error
|
||||
}
|
||||
|
||||
func (e ErrBugsnagSendFailed) Error() string {
|
||||
return "failed to send error to Bugsnag: " + e.err.Error()
|
||||
}
|
||||
|
||||
// NewBugsnagHook initializes a logrus hook which sends exceptions to an
|
||||
// exception-tracking service compatible with the Bugsnag API. Before using
|
||||
// this hook, you must call bugsnag.Configure(). The returned object should be
|
||||
// registered with a log via `AddHook()`
|
||||
//
|
||||
// Entries that trigger an Error, Fatal or Panic should now include an "error"
|
||||
// field to send to Bugsnag.
|
||||
func NewBugsnagHook() (*bugsnagHook, error) {
|
||||
if bugsnag.Config.APIKey == "" {
|
||||
return nil, ErrBugsnagUnconfigured
|
||||
}
|
||||
return &bugsnagHook{}, nil
|
||||
}
|
||||
|
||||
// Fire forwards an error to Bugsnag. Given a logrus.Entry, it extracts the
|
||||
// "error" field (or the Message if the error isn't present) and sends it off.
|
||||
func (hook *bugsnagHook) Fire(entry *logrus.Entry) error {
|
||||
var notifyErr error
|
||||
err, ok := entry.Data["error"].(error)
|
||||
if ok {
|
||||
notifyErr = err
|
||||
} else {
|
||||
notifyErr = errors.New(entry.Message)
|
||||
}
|
||||
|
||||
bugsnagErr := bugsnag.Notify(notifyErr)
|
||||
if bugsnagErr != nil {
|
||||
return ErrBugsnagSendFailed{bugsnagErr}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Levels enumerates the log levels on which the error should be forwarded to
|
||||
// bugsnag: everything at or above the "Error" level.
|
||||
func (hook *bugsnagHook) Levels() []logrus.Level {
|
||||
return []logrus.Level{
|
||||
logrus.ErrorLevel,
|
||||
logrus.FatalLevel,
|
||||
logrus.PanicLevel,
|
||||
}
|
||||
}
|
28
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks/papertrail/README.md
generated
vendored
28
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks/papertrail/README.md
generated
vendored
@ -1,28 +0,0 @@
|
||||
# Papertrail Hook for Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:" />
|
||||
|
||||
[Papertrail](https://papertrailapp.com) provides hosted log management. Once stored in Papertrail, you can [group](http://help.papertrailapp.com/kb/how-it-works/groups/) your logs on various dimensions, [search](http://help.papertrailapp.com/kb/how-it-works/search-syntax) them, and trigger [alerts](http://help.papertrailapp.com/kb/how-it-works/alerts).
|
||||
|
||||
In most deployments, you'll want to send logs to Papertrail via their [remote_syslog](http://help.papertrailapp.com/kb/configuration/configuring-centralized-logging-from-text-log-files-in-unix/) daemon, which requires no application-specific configuration. This hook is intended for relatively low-volume logging, likely in managed cloud hosting deployments where installing `remote_syslog` is not possible.
|
||||
|
||||
## Usage
|
||||
|
||||
You can find your Papertrail UDP port on your [Papertrail account page](https://papertrailapp.com/account/destinations). Substitute it below for `YOUR_PAPERTRAIL_UDP_PORT`.
|
||||
|
||||
For `YOUR_APP_NAME`, substitute a short string that will readily identify your application or service in the logs.
|
||||
|
||||
```go
|
||||
import (
|
||||
"log/syslog"
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/Sirupsen/logrus/hooks/papertrail"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log := logrus.New()
|
||||
hook, err := logrus_papertrail.NewPapertrailHook("logs.papertrailapp.com", YOUR_PAPERTRAIL_UDP_PORT, YOUR_APP_NAME)
|
||||
|
||||
if err == nil {
|
||||
log.Hooks.Add(hook)
|
||||
}
|
||||
}
|
||||
```
|
55
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks/papertrail/papertrail.go
generated
vendored
55
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks/papertrail/papertrail.go
generated
vendored
@ -1,55 +0,0 @@
|
||||
package logrus_papertrail
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
format = "Jan 2 15:04:05"
|
||||
)
|
||||
|
||||
// PapertrailHook to send logs to a logging service compatible with the Papertrail API.
|
||||
type PapertrailHook struct {
|
||||
Host string
|
||||
Port int
|
||||
AppName string
|
||||
UDPConn net.Conn
|
||||
}
|
||||
|
||||
// NewPapertrailHook creates a hook to be added to an instance of logger.
|
||||
func NewPapertrailHook(host string, port int, appName string) (*PapertrailHook, error) {
|
||||
conn, err := net.Dial("udp", fmt.Sprintf("%s:%d", host, port))
|
||||
return &PapertrailHook{host, port, appName, conn}, err
|
||||
}
|
||||
|
||||
// Fire is called when a log event is fired.
|
||||
func (hook *PapertrailHook) Fire(entry *logrus.Entry) error {
|
||||
date := time.Now().Format(format)
|
||||
msg, _ := entry.String()
|
||||
payload := fmt.Sprintf("<22> %s %s: %s", date, hook.AppName, msg)
|
||||
|
||||
bytesWritten, err := hook.UDPConn.Write([]byte(payload))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Unable to send log line to Papertrail via UDP. Wrote %d bytes before error: %v", bytesWritten, err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Levels returns the available logging levels.
|
||||
func (hook *PapertrailHook) Levels() []logrus.Level {
|
||||
return []logrus.Level{
|
||||
logrus.PanicLevel,
|
||||
logrus.FatalLevel,
|
||||
logrus.ErrorLevel,
|
||||
logrus.WarnLevel,
|
||||
logrus.InfoLevel,
|
||||
logrus.DebugLevel,
|
||||
}
|
||||
}
|
111
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks/sentry/README.md
generated
vendored
111
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks/sentry/README.md
generated
vendored
@ -1,111 +0,0 @@
|
||||
# Sentry Hook for Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:" />
|
||||
|
||||
[Sentry](https://getsentry.com) provides both self-hosted and hosted
|
||||
solutions for exception tracking.
|
||||
Both client and server are
|
||||
[open source](https://github.com/getsentry/sentry).
|
||||
|
||||
## Usage
|
||||
|
||||
Every sentry application defined on the server gets a different
|
||||
[DSN](https://www.getsentry.com/docs/). In the example below replace
|
||||
`YOUR_DSN` with the one created for your application.
|
||||
|
||||
```go
|
||||
import (
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/Sirupsen/logrus/hooks/sentry"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log := logrus.New()
|
||||
hook, err := logrus_sentry.NewSentryHook(YOUR_DSN, []logrus.Level{
|
||||
logrus.PanicLevel,
|
||||
logrus.FatalLevel,
|
||||
logrus.ErrorLevel,
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
log.Hooks.Add(hook)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you wish to initialize a SentryHook with tags, you can use the `NewWithTagsSentryHook` constructor to provide default tags:
|
||||
|
||||
```go
|
||||
tags := map[string]string{
|
||||
"site": "example.com",
|
||||
}
|
||||
levels := []logrus.Level{
|
||||
logrus.PanicLevel,
|
||||
logrus.FatalLevel,
|
||||
logrus.ErrorLevel,
|
||||
}
|
||||
hook, err := logrus_sentry.NewWithTagsSentryHook(YOUR_DSN, tags, levels)
|
||||
|
||||
```
|
||||
|
||||
If you wish to initialize a SentryHook with an already initialized raven client, you can use
|
||||
the `NewWithClientSentryHook` constructor:
|
||||
|
||||
```go
|
||||
import (
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/Sirupsen/logrus/hooks/sentry"
|
||||
"github.com/getsentry/raven-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log := logrus.New()
|
||||
|
||||
client, err := raven.New(YOUR_DSN)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
hook, err := logrus_sentry.NewWithClientSentryHook(client, []logrus.Level{
|
||||
logrus.PanicLevel,
|
||||
logrus.FatalLevel,
|
||||
logrus.ErrorLevel,
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
log.Hooks.Add(hook)
|
||||
}
|
||||
}
|
||||
|
||||
hook, err := NewWithClientSentryHook(client, []logrus.Level{
|
||||
logrus.ErrorLevel,
|
||||
})
|
||||
```
|
||||
|
||||
## Special fields
|
||||
|
||||
Some logrus fields have a special meaning in this hook,
|
||||
these are `server_name`, `logger` and `http_request`.
|
||||
When logs are sent to sentry these fields are treated differently.
|
||||
- `server_name` (also known as hostname) is the name of the server which
|
||||
is logging the event (hostname.example.com)
|
||||
- `logger` is the part of the application which is logging the event.
|
||||
In go this usually means setting it to the name of the package.
|
||||
- `http_request` is the in-coming request(*http.Request). The detailed request data are sent to Sentry.
|
||||
|
||||
## Timeout
|
||||
|
||||
`Timeout` is the time the sentry hook will wait for a response
|
||||
from the sentry server.
|
||||
|
||||
If this time elapses with no response from
|
||||
the server an error will be returned.
|
||||
|
||||
If `Timeout` is set to 0 the SentryHook will not wait for a reply
|
||||
and will assume a correct delivery.
|
||||
|
||||
The SentryHook has a default timeout of `100 milliseconds` when created
|
||||
with a call to `NewSentryHook`. This can be changed by assigning a value to the `Timeout` field:
|
||||
|
||||
```go
|
||||
hook, _ := logrus_sentry.NewSentryHook(...)
|
||||
hook.Timeout = 20*time.Second
|
||||
```
|
137
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks/sentry/sentry.go
generated
vendored
137
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks/sentry/sentry.go
generated
vendored
@ -1,137 +0,0 @@
|
||||
package logrus_sentry
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/getsentry/raven-go"
|
||||
)
|
||||
|
||||
var (
|
||||
severityMap = map[logrus.Level]raven.Severity{
|
||||
logrus.DebugLevel: raven.DEBUG,
|
||||
logrus.InfoLevel: raven.INFO,
|
||||
logrus.WarnLevel: raven.WARNING,
|
||||
logrus.ErrorLevel: raven.ERROR,
|
||||
logrus.FatalLevel: raven.FATAL,
|
||||
logrus.PanicLevel: raven.FATAL,
|
||||
}
|
||||
)
|
||||
|
||||
func getAndDel(d logrus.Fields, key string) (string, bool) {
|
||||
var (
|
||||
ok bool
|
||||
v interface{}
|
||||
val string
|
||||
)
|
||||
if v, ok = d[key]; !ok {
|
||||
return "", false
|
||||
}
|
||||
|
||||
if val, ok = v.(string); !ok {
|
||||
return "", false
|
||||
}
|
||||
delete(d, key)
|
||||
return val, true
|
||||
}
|
||||
|
||||
func getAndDelRequest(d logrus.Fields, key string) (*http.Request, bool) {
|
||||
var (
|
||||
ok bool
|
||||
v interface{}
|
||||
req *http.Request
|
||||
)
|
||||
if v, ok = d[key]; !ok {
|
||||
return nil, false
|
||||
}
|
||||
if req, ok = v.(*http.Request); !ok || req == nil {
|
||||
return nil, false
|
||||
}
|
||||
delete(d, key)
|
||||
return req, true
|
||||
}
|
||||
|
||||
// SentryHook delivers logs to a sentry server.
|
||||
type SentryHook struct {
|
||||
// Timeout sets the time to wait for a delivery error from the sentry server.
|
||||
// If this is set to zero the server will not wait for any response and will
|
||||
// consider the message correctly sent
|
||||
Timeout time.Duration
|
||||
|
||||
client *raven.Client
|
||||
levels []logrus.Level
|
||||
}
|
||||
|
||||
// NewSentryHook creates a hook to be added to an instance of logger
|
||||
// and initializes the raven client.
|
||||
// This method sets the timeout to 100 milliseconds.
|
||||
func NewSentryHook(DSN string, levels []logrus.Level) (*SentryHook, error) {
|
||||
client, err := raven.New(DSN)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SentryHook{100 * time.Millisecond, client, levels}, nil
|
||||
}
|
||||
|
||||
// NewWithTagsSentryHook creates a hook with tags to be added to an instance
|
||||
// of logger and initializes the raven client. This method sets the timeout to
|
||||
// 100 milliseconds.
|
||||
func NewWithTagsSentryHook(DSN string, tags map[string]string, levels []logrus.Level) (*SentryHook, error) {
|
||||
client, err := raven.NewWithTags(DSN, tags)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SentryHook{100 * time.Millisecond, client, levels}, nil
|
||||
}
|
||||
|
||||
// NewWithClientSentryHook creates a hook using an initialized raven client.
|
||||
// This method sets the timeout to 100 milliseconds.
|
||||
func NewWithClientSentryHook(client *raven.Client, levels []logrus.Level) (*SentryHook, error) {
|
||||
return &SentryHook{100 * time.Millisecond, client, levels}, nil
|
||||
}
|
||||
|
||||
// Called when an event should be sent to sentry
|
||||
// Special fields that sentry uses to give more information to the server
|
||||
// are extracted from entry.Data (if they are found)
|
||||
// These fields are: logger, server_name and http_request
|
||||
func (hook *SentryHook) Fire(entry *logrus.Entry) error {
|
||||
packet := &raven.Packet{
|
||||
Message: entry.Message,
|
||||
Timestamp: raven.Timestamp(entry.Time),
|
||||
Level: severityMap[entry.Level],
|
||||
Platform: "go",
|
||||
}
|
||||
|
||||
d := entry.Data
|
||||
|
||||
if logger, ok := getAndDel(d, "logger"); ok {
|
||||
packet.Logger = logger
|
||||
}
|
||||
if serverName, ok := getAndDel(d, "server_name"); ok {
|
||||
packet.ServerName = serverName
|
||||
}
|
||||
if req, ok := getAndDelRequest(d, "http_request"); ok {
|
||||
packet.Interfaces = append(packet.Interfaces, raven.NewHttp(req))
|
||||
}
|
||||
packet.Extra = map[string]interface{}(d)
|
||||
|
||||
_, errCh := hook.client.Capture(packet, nil)
|
||||
timeout := hook.Timeout
|
||||
if timeout != 0 {
|
||||
timeoutCh := time.After(timeout)
|
||||
select {
|
||||
case err := <-errCh:
|
||||
return err
|
||||
case <-timeoutCh:
|
||||
return fmt.Errorf("no response from sentry server in %s", timeout)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Levels returns the available logging levels.
|
||||
func (hook *SentryHook) Levels() []logrus.Level {
|
||||
return hook.levels
|
||||
}
|
20
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks/syslog/README.md
generated
vendored
20
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks/syslog/README.md
generated
vendored
@ -1,20 +0,0 @@
|
||||
# Syslog Hooks for Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:"/>
|
||||
|
||||
## Usage
|
||||
|
||||
```go
|
||||
import (
|
||||
"log/syslog"
|
||||
"github.com/Sirupsen/logrus"
|
||||
logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log := logrus.New()
|
||||
hook, err := logrus_syslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
|
||||
|
||||
if err == nil {
|
||||
log.Hooks.Add(hook)
|
||||
}
|
||||
}
|
||||
```
|
59
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks/syslog/syslog.go
generated
vendored
59
alpine/packages/go/vendor/github.com/Sirupsen/logrus/hooks/syslog/syslog.go
generated
vendored
@ -1,59 +0,0 @@
|
||||
package logrus_syslog
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Sirupsen/logrus"
|
||||
"log/syslog"
|
||||
"os"
|
||||
)
|
||||
|
||||
// SyslogHook to send logs via syslog.
|
||||
type SyslogHook struct {
|
||||
Writer *syslog.Writer
|
||||
SyslogNetwork string
|
||||
SyslogRaddr string
|
||||
}
|
||||
|
||||
// Creates a hook to be added to an instance of logger. This is called with
|
||||
// `hook, err := NewSyslogHook("udp", "localhost:514", syslog.LOG_DEBUG, "")`
|
||||
// `if err == nil { log.Hooks.Add(hook) }`
|
||||
func NewSyslogHook(network, raddr string, priority syslog.Priority, tag string) (*SyslogHook, error) {
|
||||
w, err := syslog.Dial(network, raddr, priority, tag)
|
||||
return &SyslogHook{w, network, raddr}, err
|
||||
}
|
||||
|
||||
func (hook *SyslogHook) Fire(entry *logrus.Entry) error {
|
||||
line, err := entry.String()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Unable to read entry, %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
switch entry.Level {
|
||||
case logrus.PanicLevel:
|
||||
return hook.Writer.Crit(line)
|
||||
case logrus.FatalLevel:
|
||||
return hook.Writer.Crit(line)
|
||||
case logrus.ErrorLevel:
|
||||
return hook.Writer.Err(line)
|
||||
case logrus.WarnLevel:
|
||||
return hook.Writer.Warning(line)
|
||||
case logrus.InfoLevel:
|
||||
return hook.Writer.Info(line)
|
||||
case logrus.DebugLevel:
|
||||
return hook.Writer.Debug(line)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (hook *SyslogHook) Levels() []logrus.Level {
|
||||
return []logrus.Level{
|
||||
logrus.PanicLevel,
|
||||
logrus.FatalLevel,
|
||||
logrus.ErrorLevel,
|
||||
logrus.WarnLevel,
|
||||
logrus.InfoLevel,
|
||||
logrus.DebugLevel,
|
||||
}
|
||||
}
|
41
alpine/packages/go/vendor/github.com/Sirupsen/logrus/json_formatter.go
generated
vendored
41
alpine/packages/go/vendor/github.com/Sirupsen/logrus/json_formatter.go
generated
vendored
@ -1,41 +0,0 @@
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type JSONFormatter struct {
|
||||
// TimestampFormat sets the format used for marshaling timestamps.
|
||||
TimestampFormat string
|
||||
}
|
||||
|
||||
func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {
|
||||
data := make(Fields, len(entry.Data)+3)
|
||||
for k, v := range entry.Data {
|
||||
switch v := v.(type) {
|
||||
case error:
|
||||
// Otherwise errors are ignored by `encoding/json`
|
||||
// https://github.com/Sirupsen/logrus/issues/137
|
||||
data[k] = v.Error()
|
||||
default:
|
||||
data[k] = v
|
||||
}
|
||||
}
|
||||
prefixFieldClashes(data)
|
||||
|
||||
timestampFormat := f.TimestampFormat
|
||||
if timestampFormat == "" {
|
||||
timestampFormat = DefaultTimestampFormat
|
||||
}
|
||||
|
||||
data["time"] = entry.Time.Format(timestampFormat)
|
||||
data["msg"] = entry.Message
|
||||
data["level"] = entry.Level.String()
|
||||
|
||||
serialized, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
|
||||
}
|
||||
return append(serialized, '\n'), nil
|
||||
}
|
206
alpine/packages/go/vendor/github.com/Sirupsen/logrus/logger.go
generated
vendored
206
alpine/packages/go/vendor/github.com/Sirupsen/logrus/logger.go
generated
vendored
@ -1,206 +0,0 @@
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Logger struct {
|
||||
// The logs are `io.Copy`'d to this in a mutex. It's common to set this to a
|
||||
// file, or leave it default which is `os.Stderr`. You can also set this to
|
||||
// something more adventorous, such as logging to Kafka.
|
||||
Out io.Writer
|
||||
// Hooks for the logger instance. These allow firing events based on logging
|
||||
// levels and log entries. For example, to send errors to an error tracking
|
||||
// service, log to StatsD or dump the core on fatal errors.
|
||||
Hooks LevelHooks
|
||||
// All log entries pass through the formatter before logged to Out. The
|
||||
// included formatters are `TextFormatter` and `JSONFormatter` for which
|
||||
// TextFormatter is the default. In development (when a TTY is attached) it
|
||||
// logs with colors, but to a file it wouldn't. You can easily implement your
|
||||
// own that implements the `Formatter` interface, see the `README` or included
|
||||
// formatters for examples.
|
||||
Formatter Formatter
|
||||
// The logging level the logger should log at. This is typically (and defaults
|
||||
// to) `logrus.Info`, which allows Info(), Warn(), Error() and Fatal() to be
|
||||
// logged. `logrus.Debug` is useful in
|
||||
Level Level
|
||||
// Used to sync writing to the log.
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
// Creates a new logger. Configuration should be set by changing `Formatter`,
|
||||
// `Out` and `Hooks` directly on the default logger instance. You can also just
|
||||
// instantiate your own:
|
||||
//
|
||||
// var log = &Logger{
|
||||
// Out: os.Stderr,
|
||||
// Formatter: new(JSONFormatter),
|
||||
// Hooks: make(LevelHooks),
|
||||
// Level: logrus.DebugLevel,
|
||||
// }
|
||||
//
|
||||
// It's recommended to make this a global instance called `log`.
|
||||
func New() *Logger {
|
||||
return &Logger{
|
||||
Out: os.Stderr,
|
||||
Formatter: new(TextFormatter),
|
||||
Hooks: make(LevelHooks),
|
||||
Level: InfoLevel,
|
||||
}
|
||||
}
|
||||
|
||||
// Adds a field to the log entry, note that you it doesn't log until you call
|
||||
// Debug, Print, Info, Warn, Fatal or Panic. It only creates a log entry.
|
||||
// If you want multiple fields, use `WithFields`.
|
||||
func (logger *Logger) WithField(key string, value interface{}) *Entry {
|
||||
return NewEntry(logger).WithField(key, value)
|
||||
}
|
||||
|
||||
// Adds a struct of fields to the log entry. All it does is call `WithField` for
|
||||
// each `Field`.
|
||||
func (logger *Logger) WithFields(fields Fields) *Entry {
|
||||
return NewEntry(logger).WithFields(fields)
|
||||
}
|
||||
|
||||
func (logger *Logger) Debugf(format string, args ...interface{}) {
|
||||
if logger.Level >= DebugLevel {
|
||||
NewEntry(logger).Debugf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Infof(format string, args ...interface{}) {
|
||||
if logger.Level >= InfoLevel {
|
||||
NewEntry(logger).Infof(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Printf(format string, args ...interface{}) {
|
||||
NewEntry(logger).Printf(format, args...)
|
||||
}
|
||||
|
||||
func (logger *Logger) Warnf(format string, args ...interface{}) {
|
||||
if logger.Level >= WarnLevel {
|
||||
NewEntry(logger).Warnf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Warningf(format string, args ...interface{}) {
|
||||
if logger.Level >= WarnLevel {
|
||||
NewEntry(logger).Warnf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Errorf(format string, args ...interface{}) {
|
||||
if logger.Level >= ErrorLevel {
|
||||
NewEntry(logger).Errorf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Fatalf(format string, args ...interface{}) {
|
||||
if logger.Level >= FatalLevel {
|
||||
NewEntry(logger).Fatalf(format, args...)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (logger *Logger) Panicf(format string, args ...interface{}) {
|
||||
if logger.Level >= PanicLevel {
|
||||
NewEntry(logger).Panicf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Debug(args ...interface{}) {
|
||||
if logger.Level >= DebugLevel {
|
||||
NewEntry(logger).Debug(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Info(args ...interface{}) {
|
||||
if logger.Level >= InfoLevel {
|
||||
NewEntry(logger).Info(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Print(args ...interface{}) {
|
||||
NewEntry(logger).Info(args...)
|
||||
}
|
||||
|
||||
func (logger *Logger) Warn(args ...interface{}) {
|
||||
if logger.Level >= WarnLevel {
|
||||
NewEntry(logger).Warn(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Warning(args ...interface{}) {
|
||||
if logger.Level >= WarnLevel {
|
||||
NewEntry(logger).Warn(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Error(args ...interface{}) {
|
||||
if logger.Level >= ErrorLevel {
|
||||
NewEntry(logger).Error(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Fatal(args ...interface{}) {
|
||||
if logger.Level >= FatalLevel {
|
||||
NewEntry(logger).Fatal(args...)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (logger *Logger) Panic(args ...interface{}) {
|
||||
if logger.Level >= PanicLevel {
|
||||
NewEntry(logger).Panic(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Debugln(args ...interface{}) {
|
||||
if logger.Level >= DebugLevel {
|
||||
NewEntry(logger).Debugln(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Infoln(args ...interface{}) {
|
||||
if logger.Level >= InfoLevel {
|
||||
NewEntry(logger).Infoln(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Println(args ...interface{}) {
|
||||
NewEntry(logger).Println(args...)
|
||||
}
|
||||
|
||||
func (logger *Logger) Warnln(args ...interface{}) {
|
||||
if logger.Level >= WarnLevel {
|
||||
NewEntry(logger).Warnln(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Warningln(args ...interface{}) {
|
||||
if logger.Level >= WarnLevel {
|
||||
NewEntry(logger).Warnln(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Errorln(args ...interface{}) {
|
||||
if logger.Level >= ErrorLevel {
|
||||
NewEntry(logger).Errorln(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Fatalln(args ...interface{}) {
|
||||
if logger.Level >= FatalLevel {
|
||||
NewEntry(logger).Fatalln(args...)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (logger *Logger) Panicln(args ...interface{}) {
|
||||
if logger.Level >= PanicLevel {
|
||||
NewEntry(logger).Panicln(args...)
|
||||
}
|
||||
}
|
98
alpine/packages/go/vendor/github.com/Sirupsen/logrus/logrus.go
generated
vendored
98
alpine/packages/go/vendor/github.com/Sirupsen/logrus/logrus.go
generated
vendored
@ -1,98 +0,0 @@
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
)
|
||||
|
||||
// Fields type, used to pass to `WithFields`.
|
||||
type Fields map[string]interface{}
|
||||
|
||||
// Level type
|
||||
type Level uint8
|
||||
|
||||
// Convert the Level to a string. E.g. PanicLevel becomes "panic".
|
||||
func (level Level) String() string {
|
||||
switch level {
|
||||
case DebugLevel:
|
||||
return "debug"
|
||||
case InfoLevel:
|
||||
return "info"
|
||||
case WarnLevel:
|
||||
return "warning"
|
||||
case ErrorLevel:
|
||||
return "error"
|
||||
case FatalLevel:
|
||||
return "fatal"
|
||||
case PanicLevel:
|
||||
return "panic"
|
||||
}
|
||||
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
// ParseLevel takes a string level and returns the Logrus log level constant.
|
||||
func ParseLevel(lvl string) (Level, error) {
|
||||
switch lvl {
|
||||
case "panic":
|
||||
return PanicLevel, nil
|
||||
case "fatal":
|
||||
return FatalLevel, nil
|
||||
case "error":
|
||||
return ErrorLevel, nil
|
||||
case "warn", "warning":
|
||||
return WarnLevel, nil
|
||||
case "info":
|
||||
return InfoLevel, nil
|
||||
case "debug":
|
||||
return DebugLevel, nil
|
||||
}
|
||||
|
||||
var l Level
|
||||
return l, fmt.Errorf("not a valid logrus Level: %q", lvl)
|
||||
}
|
||||
|
||||
// These are the different logging levels. You can set the logging level to log
|
||||
// on your instance of logger, obtained with `logrus.New()`.
|
||||
const (
|
||||
// PanicLevel level, highest level of severity. Logs and then calls panic with the
|
||||
// message passed to Debug, Info, ...
|
||||
PanicLevel Level = iota
|
||||
// FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the
|
||||
// logging level is set to Panic.
|
||||
FatalLevel
|
||||
// ErrorLevel level. Logs. Used for errors that should definitely be noted.
|
||||
// Commonly used for hooks to send errors to an error tracking service.
|
||||
ErrorLevel
|
||||
// WarnLevel level. Non-critical entries that deserve eyes.
|
||||
WarnLevel
|
||||
// InfoLevel level. General operational entries about what's going on inside the
|
||||
// application.
|
||||
InfoLevel
|
||||
// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
|
||||
DebugLevel
|
||||
)
|
||||
|
||||
// Won't compile if StdLogger can't be realized by a log.Logger
|
||||
var (
|
||||
_ StdLogger = &log.Logger{}
|
||||
_ StdLogger = &Entry{}
|
||||
_ StdLogger = &Logger{}
|
||||
)
|
||||
|
||||
// StdLogger is what your logrus-enabled library should take, that way
|
||||
// it'll accept a stdlib logger and a logrus logger. There's no standard
|
||||
// interface, this is the closest we get, unfortunately.
|
||||
type StdLogger interface {
|
||||
Print(...interface{})
|
||||
Printf(string, ...interface{})
|
||||
Println(...interface{})
|
||||
|
||||
Fatal(...interface{})
|
||||
Fatalf(string, ...interface{})
|
||||
Fatalln(...interface{})
|
||||
|
||||
Panic(...interface{})
|
||||
Panicf(string, ...interface{})
|
||||
Panicln(...interface{})
|
||||
}
|
9
alpine/packages/go/vendor/github.com/Sirupsen/logrus/terminal_bsd.go
generated
vendored
9
alpine/packages/go/vendor/github.com/Sirupsen/logrus/terminal_bsd.go
generated
vendored
@ -1,9 +0,0 @@
|
||||
// +build darwin freebsd openbsd netbsd dragonfly
|
||||
|
||||
package logrus
|
||||
|
||||
import "syscall"
|
||||
|
||||
const ioctlReadTermios = syscall.TIOCGETA
|
||||
|
||||
type Termios syscall.Termios
|
12
alpine/packages/go/vendor/github.com/Sirupsen/logrus/terminal_linux.go
generated
vendored
12
alpine/packages/go/vendor/github.com/Sirupsen/logrus/terminal_linux.go
generated
vendored
@ -1,12 +0,0 @@
|
||||
// Based on ssh/terminal:
|
||||
// Copyright 2013 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package logrus
|
||||
|
||||
import "syscall"
|
||||
|
||||
const ioctlReadTermios = syscall.TCGETS
|
||||
|
||||
type Termios syscall.Termios
|
21
alpine/packages/go/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go
generated
vendored
21
alpine/packages/go/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go
generated
vendored
@ -1,21 +0,0 @@
|
||||
// Based on ssh/terminal:
|
||||
// Copyright 2011 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build linux darwin freebsd openbsd netbsd dragonfly
|
||||
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// IsTerminal returns true if the given file descriptor is a terminal.
|
||||
func IsTerminal() bool {
|
||||
fd := syscall.Stdout
|
||||
var termios Termios
|
||||
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
|
||||
return err == 0
|
||||
}
|
27
alpine/packages/go/vendor/github.com/Sirupsen/logrus/terminal_windows.go
generated
vendored
27
alpine/packages/go/vendor/github.com/Sirupsen/logrus/terminal_windows.go
generated
vendored
@ -1,27 +0,0 @@
|
||||
// Based on ssh/terminal:
|
||||
// Copyright 2011 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build windows
|
||||
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
||||
|
||||
var (
|
||||
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
|
||||
)
|
||||
|
||||
// IsTerminal returns true if the given file descriptor is a terminal.
|
||||
func IsTerminal() bool {
|
||||
fd := syscall.Stdout
|
||||
var st uint32
|
||||
r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0)
|
||||
return r != 0 && e == 0
|
||||
}
|
159
alpine/packages/go/vendor/github.com/Sirupsen/logrus/text_formatter.go
generated
vendored
159
alpine/packages/go/vendor/github.com/Sirupsen/logrus/text_formatter.go
generated
vendored
@ -1,159 +0,0 @@
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
nocolor = 0
|
||||
red = 31
|
||||
green = 32
|
||||
yellow = 33
|
||||
blue = 34
|
||||
gray = 37
|
||||
)
|
||||
|
||||
var (
|
||||
baseTimestamp time.Time
|
||||
isTerminal bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseTimestamp = time.Now()
|
||||
isTerminal = IsTerminal()
|
||||
}
|
||||
|
||||
func miniTS() int {
|
||||
return int(time.Since(baseTimestamp) / time.Second)
|
||||
}
|
||||
|
||||
type TextFormatter struct {
|
||||
// Set to true to bypass checking for a TTY before outputting colors.
|
||||
ForceColors bool
|
||||
|
||||
// Force disabling colors.
|
||||
DisableColors bool
|
||||
|
||||
// Disable timestamp logging. useful when output is redirected to logging
|
||||
// system that already adds timestamps.
|
||||
DisableTimestamp bool
|
||||
|
||||
// Enable logging the full timestamp when a TTY is attached instead of just
|
||||
// the time passed since beginning of execution.
|
||||
FullTimestamp bool
|
||||
|
||||
// TimestampFormat to use for display when a full timestamp is printed
|
||||
TimestampFormat string
|
||||
|
||||
// The fields are sorted by default for a consistent output. For applications
|
||||
// that log extremely frequently and don't use the JSON formatter this may not
|
||||
// be desired.
|
||||
DisableSorting bool
|
||||
}
|
||||
|
||||
func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
||||
var keys []string = make([]string, 0, len(entry.Data))
|
||||
for k := range entry.Data {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
|
||||
if !f.DisableSorting {
|
||||
sort.Strings(keys)
|
||||
}
|
||||
|
||||
b := &bytes.Buffer{}
|
||||
|
||||
prefixFieldClashes(entry.Data)
|
||||
|
||||
isColorTerminal := isTerminal && (runtime.GOOS != "windows")
|
||||
isColored := (f.ForceColors || isColorTerminal) && !f.DisableColors
|
||||
|
||||
timestampFormat := f.TimestampFormat
|
||||
if timestampFormat == "" {
|
||||
timestampFormat = DefaultTimestampFormat
|
||||
}
|
||||
if isColored {
|
||||
f.printColored(b, entry, keys, timestampFormat)
|
||||
} else {
|
||||
if !f.DisableTimestamp {
|
||||
f.appendKeyValue(b, "time", entry.Time.Format(timestampFormat))
|
||||
}
|
||||
f.appendKeyValue(b, "level", entry.Level.String())
|
||||
f.appendKeyValue(b, "msg", entry.Message)
|
||||
for _, key := range keys {
|
||||
f.appendKeyValue(b, key, entry.Data[key])
|
||||
}
|
||||
}
|
||||
|
||||
b.WriteByte('\n')
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []string, timestampFormat string) {
|
||||
var levelColor int
|
||||
switch entry.Level {
|
||||
case DebugLevel:
|
||||
levelColor = gray
|
||||
case WarnLevel:
|
||||
levelColor = yellow
|
||||
case ErrorLevel, FatalLevel, PanicLevel:
|
||||
levelColor = red
|
||||
default:
|
||||
levelColor = blue
|
||||
}
|
||||
|
||||
levelText := strings.ToUpper(entry.Level.String())[0:4]
|
||||
|
||||
if !f.FullTimestamp {
|
||||
fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, miniTS(), entry.Message)
|
||||
} else {
|
||||
fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %-44s ", levelColor, levelText, entry.Time.Format(timestampFormat), entry.Message)
|
||||
}
|
||||
for _, k := range keys {
|
||||
v := entry.Data[k]
|
||||
fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=%+v", levelColor, k, v)
|
||||
}
|
||||
}
|
||||
|
||||
func needsQuoting(text string) bool {
|
||||
for _, ch := range text {
|
||||
if !((ch >= 'a' && ch <= 'z') ||
|
||||
(ch >= 'A' && ch <= 'Z') ||
|
||||
(ch >= '0' && ch <= '9') ||
|
||||
ch == '-' || ch == '.') {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) {
|
||||
|
||||
b.WriteString(key)
|
||||
b.WriteByte('=')
|
||||
|
||||
switch value := value.(type) {
|
||||
case string:
|
||||
if needsQuoting(value) {
|
||||
b.WriteString(value)
|
||||
} else {
|
||||
fmt.Fprintf(b, "%q", value)
|
||||
}
|
||||
case error:
|
||||
errmsg := value.Error()
|
||||
if needsQuoting(errmsg) {
|
||||
b.WriteString(errmsg)
|
||||
} else {
|
||||
fmt.Fprintf(b, "%q", value)
|
||||
}
|
||||
default:
|
||||
fmt.Fprint(b, value)
|
||||
}
|
||||
|
||||
b.WriteByte(' ')
|
||||
}
|
31
alpine/packages/go/vendor/github.com/Sirupsen/logrus/writer.go
generated
vendored
31
alpine/packages/go/vendor/github.com/Sirupsen/logrus/writer.go
generated
vendored
@ -1,31 +0,0 @@
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func (logger *Logger) Writer() *io.PipeWriter {
|
||||
reader, writer := io.Pipe()
|
||||
|
||||
go logger.writerScanner(reader)
|
||||
runtime.SetFinalizer(writer, writerFinalizer)
|
||||
|
||||
return writer
|
||||
}
|
||||
|
||||
func (logger *Logger) writerScanner(reader *io.PipeReader) {
|
||||
scanner := bufio.NewScanner(reader)
|
||||
for scanner.Scan() {
|
||||
logger.Print(scanner.Text())
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
logger.Errorf("Error while reading from Writer: %s", err)
|
||||
}
|
||||
reader.Close()
|
||||
}
|
||||
|
||||
func writerFinalizer(writer *io.PipeWriter) {
|
||||
writer.Close()
|
||||
}
|
6
alpine/packages/hvtools/.gitignore
vendored
6
alpine/packages/hvtools/.gitignore
vendored
@ -1,4 +1,2 @@
|
||||
/hv_fcopy_daemon
|
||||
/hv_kvp_daemon
|
||||
/hv_vss_daemon
|
||||
/hvtools.tar.gz
|
||||
sbin/
|
||||
usr/
|
||||
|
@ -1,9 +1,8 @@
|
||||
FROM mobylinux/alpine-build-c:1b53976210ba819823eda5b1d0d3ea337772e97b
|
||||
|
||||
RUN mkdir -p /hvtools
|
||||
FROM mobylinux/alpine-build-c:1ea690a7438cdd8a5965eaa034e0a0c521d9cb40
|
||||
|
||||
COPY src /hvtools/
|
||||
RUN tar czvf /hvtools.tar.gz hvtools
|
||||
|
||||
WORKDIR /hvtools
|
||||
RUN make
|
||||
|
||||
CMD ["tar", "cf", "-", "hv_fcopy_daemon", "hv_kvp_daemon", "hv_vss_daemon"]
|
||||
|
@ -1,13 +1,14 @@
|
||||
all: hvtools
|
||||
all: sbin/hv_fcopy_daemon usr/share/src/hvtools.tar.gz
|
||||
|
||||
hvtools: Dockerfile src/*
|
||||
docker build -t hvtools:build .
|
||||
docker run --rm hvtools:build cat /hvtools.tar.gz > hvtools.tar.gz
|
||||
docker run --rm hvtools:build cat /hvtools/hv_fcopy_daemon > hv_fcopy_daemon
|
||||
docker run --rm hvtools:build cat /hvtools/hv_kvp_daemon > hv_kvp_daemon
|
||||
docker run --rm hvtools:build cat /hvtools/hv_vss_daemon > hv_vss_daemon
|
||||
chmod 755 hv_fcopy_daemon hv_kvp_daemon hv_vss_daemon
|
||||
sbin/hv_fcopy_daemon: Dockerfile src/*
|
||||
tar cf - Dockerfile src | docker build -t hvtools:build -
|
||||
docker run --rm --net=none hvtools:build | tar xf - -C sbin
|
||||
|
||||
usr/share/src/hvtools.tar.gz: src/*
|
||||
mkdir -p usr/share/src/
|
||||
tar czf usr/share/src/hvtools.tar.gz src
|
||||
|
||||
clean:
|
||||
rm -f hv_fcopy_daemon hv_kvp_daemon hv_vss_daemon
|
||||
docker images -q hvtools:build | xargs docker rmi -f || true
|
||||
rm -rf usr sbin/hv_fcopy_daemon sbin/hv_kvp_daemon sbin/hv_vss_daemon
|
||||
|
||||
.DELETE_ON_ERROR:
|
||||
|
@ -5,3 +5,4 @@ WORKDIR /app
|
||||
ADD . /app
|
||||
RUN sudo chown -R opam /app
|
||||
RUN opam config exec -- ocamlfind ocamlopt -package unix,astring,syslog -linkpkg -o iptables main.ml
|
||||
CMD ["tar", "cf", "-", "iptables"]
|
||||
|
@ -1,9 +1,10 @@
|
||||
all: iptables
|
||||
all: usr/local/sbin/iptables
|
||||
|
||||
iptables: Dockerfile main.ml
|
||||
usr/local/sbin/iptables: Dockerfile main.ml
|
||||
mkdir -p usr/local/sbin
|
||||
docker build -t iptables:build .
|
||||
docker run --rm iptables:build cat /app/iptables > iptables
|
||||
chmod 755 iptables
|
||||
docker run --rm iptables:build | tar xf - -C usr/local/sbin
|
||||
|
||||
clean:
|
||||
rm -rf usr
|
||||
docker images -q iptables:build | xargs docker rmi -f || true
|
||||
|
2
alpine/packages/nc-vsock/.gitignore
vendored
2
alpine/packages/nc-vsock/.gitignore
vendored
@ -1 +1 @@
|
||||
nc-vsock
|
||||
usr/
|
||||
|
@ -1,8 +1,9 @@
|
||||
FROM mobylinux/alpine-build-c:1b53976210ba819823eda5b1d0d3ea337772e97b
|
||||
|
||||
RUN mkdir -p /nc-vsock
|
||||
WORKDIR /nc-vsock
|
||||
FROM mobylinux/alpine-build-c:1ea690a7438cdd8a5965eaa034e0a0c521d9cb40
|
||||
|
||||
COPY . /nc-vsock
|
||||
|
||||
RUN make nc-vsock
|
||||
WORKDIR /nc-vsock
|
||||
|
||||
RUN cc -Wall -Werror -o nc-vsock nc-vsock.c -luuid
|
||||
|
||||
CMD ["tar", "cf", "-", "nc-vsock"]
|
||||
|
@ -1,15 +1,9 @@
|
||||
.PHONY: all
|
||||
DEPS=Dockerfile $(wildcard *.c *.h)
|
||||
|
||||
DEPS=nc-vsock.c
|
||||
|
||||
all: Dockerfile $(DEPS)
|
||||
docker build -t nc-vsock:build .
|
||||
docker run --rm nc-vsock:build cat nc-vsock > nc-vsock
|
||||
chmod 755 nc-vsock
|
||||
|
||||
nc-vsock: $(DEPS)
|
||||
gcc -Wall -Werror -o nc-vsock nc-vsock.c -luuid
|
||||
usr/bin/nc-vsock: $(DEPS)
|
||||
mkdir -p usr/bin
|
||||
tar cf - $(DEPS) | docker build -t nc-vsock:build -
|
||||
docker run --rm --net=none nc-vsock:build | tar xf - -C usr/bin
|
||||
|
||||
clean:
|
||||
rm -f nc-vsock
|
||||
docker images -q nc-vsock:build | xargs docker rmi -f || true
|
||||
rm -rf usr
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <sys/select.h>
|
||||
#include <netdb.h>
|
||||
#include <uuid/uuid.h>
|
||||
#include "include/uapi/linux/vm_sockets.h"
|
||||
#include "vm_sockets.h"
|
||||
|
||||
#define MODE_READ 1 /* From the vsock */
|
||||
#define MODE_WRITE 2 /* To the vsock */
|
||||
|
5
alpine/packages/proxy/.gitignore
vendored
5
alpine/packages/proxy/.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
/slirp-proxy
|
||||
/vendor
|
||||
proxy
|
||||
usr/
|
||||
sbin/
|
||||
|
@ -1,13 +1,9 @@
|
||||
FROM mobylinux/alpine-build-go:30067067003d565887d7efe533eba03ed46038d2
|
||||
|
||||
RUN mkdir -p /go/src/proxy
|
||||
WORKDIR /go/src/proxy
|
||||
FROM mobylinux/alpine-build-go:21b413791b4fed2e16126c77c6b860feaf889d70
|
||||
|
||||
COPY ./ /go/src/proxy/
|
||||
|
||||
ARG GOARCH
|
||||
ARG GOOS
|
||||
WORKDIR /go/src/proxy
|
||||
|
||||
RUN go install --ldflags '-extldflags "-fno-PIC"'
|
||||
|
||||
RUN [ -f /go/bin/*/proxy ] && mv /go/bin/*/proxy /go/bin/ || true
|
||||
CMD ["tar", "cf", "-", "-C", "/go/bin", "proxy"]
|
||||
|
@ -1,15 +1,20 @@
|
||||
all: proxy
|
||||
all: usr/bin/slirp-proxy sbin/proxy-vsockd
|
||||
|
||||
.PHONY: vendor
|
||||
vendor:
|
||||
mkdir -p ./vendor
|
||||
cp -r ../go/vendor/* ./vendor/
|
||||
DEPS=Dockerfile $(wildcard *.go libproxy/*.go)
|
||||
|
||||
proxy: Dockerfile main.go proxy.go vendor
|
||||
docker build --build-arg GOOS=$(OS) --build-arg GOARCH=$(ARCH) -t proxy:build .
|
||||
docker run --rm proxy:build cat /go/bin/proxy > slirp-proxy
|
||||
chmod 755 slirp-proxy
|
||||
proxy: $(DEPS) ../vendor/manifest
|
||||
tar cf - $(DEPS) -C .. vendor | docker build -t proxy:build -
|
||||
docker run --rm --net=none proxy:build | tar xf -
|
||||
|
||||
usr/bin/slirp-proxy: proxy
|
||||
mkdir -p usr/bin
|
||||
cp proxy $@
|
||||
|
||||
sbin/proxy-vsockd: proxy
|
||||
mkdir -p sbin
|
||||
cp proxy $@
|
||||
|
||||
clean:
|
||||
rm -rf slirp-proxy vendor
|
||||
docker images -q proxy:build | xargs docker rmi -f || true
|
||||
rm -rf proxy sbin usr
|
||||
|
||||
.DELETE_ON_ERROR:
|
||||
|
@ -2,9 +2,8 @@ package libproxy
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
type Conn interface {
|
||||
@ -37,7 +36,7 @@ func NewTCPProxy(listener net.Listener, backendAddr *net.TCPAddr) (*TCPProxy, er
|
||||
func HandleTCPConnection(client Conn, backendAddr *net.TCPAddr, quit chan bool) {
|
||||
backend, err := net.DialTCP("tcp", nil, backendAddr)
|
||||
if err != nil {
|
||||
logrus.Printf("Can't forward traffic to backend tcp/%v: %s\n", backendAddr, err)
|
||||
log.Printf("Can't forward traffic to backend tcp/%v: %s\n", backendAddr, err)
|
||||
client.Close()
|
||||
return
|
||||
}
|
||||
@ -46,15 +45,15 @@ func HandleTCPConnection(client Conn, backendAddr *net.TCPAddr, quit chan bool)
|
||||
var broker = func(to, from Conn) {
|
||||
written, err := io.Copy(to, from)
|
||||
if err != nil {
|
||||
logrus.Println("error copying:", err)
|
||||
log.Println("error copying:", err)
|
||||
}
|
||||
err = from.CloseRead()
|
||||
if err != nil {
|
||||
logrus.Println("error CloseRead from:", err)
|
||||
log.Println("error CloseRead from:", err)
|
||||
}
|
||||
err = to.CloseWrite()
|
||||
if err != nil {
|
||||
logrus.Println("error CloseWrite to:", err)
|
||||
log.Println("error CloseWrite to:", err)
|
||||
}
|
||||
event <- written
|
||||
}
|
||||
@ -88,7 +87,7 @@ func (proxy *TCPProxy) Run() {
|
||||
for {
|
||||
client, err := proxy.listener.Accept()
|
||||
if err != nil {
|
||||
logrus.Printf("Stopping proxy on tcp/%v for tcp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err)
|
||||
log.Printf("Stopping proxy on tcp/%v for tcp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err)
|
||||
return
|
||||
}
|
||||
go HandleTCPConnection(client.(Conn), proxy.backendAddr, quit)
|
||||
|
@ -4,10 +4,9 @@ import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"sync"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
type udpListener interface {
|
||||
@ -32,7 +31,7 @@ func (u *udpEncapsulator) getConn() (net.Conn, error) {
|
||||
}
|
||||
conn, err := u.listener.Accept()
|
||||
if err != nil {
|
||||
logrus.Printf("Failed to accept connection: %#v", err)
|
||||
log.Printf("Failed to accept connection: %#v", err)
|
||||
return nil, err
|
||||
}
|
||||
u.conn = &conn
|
||||
|
@ -2,13 +2,12 @@ package libproxy
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"log"
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -109,7 +108,7 @@ func (proxy *UDPProxy) Run() {
|
||||
// ECONNREFUSED like Read do (see comment in
|
||||
// UDPProxy.replyLoop)
|
||||
if !isClosedError(err) {
|
||||
logrus.Printf("Stopping proxy on %v for udp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err)
|
||||
log.Printf("Stopping proxy on %v for udp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err)
|
||||
}
|
||||
break
|
||||
}
|
||||
@ -120,7 +119,7 @@ func (proxy *UDPProxy) Run() {
|
||||
if !hit {
|
||||
proxyConn, err = net.DialUDP("udp", nil, proxy.backendAddr)
|
||||
if err != nil {
|
||||
logrus.Printf("Can't proxy a datagram to udp/%s: %s\n", proxy.backendAddr, err)
|
||||
log.Printf("Can't proxy a datagram to udp/%s: %s\n", proxy.backendAddr, err)
|
||||
proxy.connTrackLock.Unlock()
|
||||
continue
|
||||
}
|
||||
@ -131,7 +130,7 @@ func (proxy *UDPProxy) Run() {
|
||||
for i := 0; i != read; {
|
||||
written, err := proxyConn.Write(readBuf[i:read])
|
||||
if err != nil {
|
||||
logrus.Printf("Can't proxy a datagram to udp/%s: %s\n", proxy.backendAddr, err)
|
||||
log.Printf("Can't proxy a datagram to udp/%s: %s\n", proxy.backendAddr, err)
|
||||
break
|
||||
}
|
||||
i += written
|
||||
|
2
alpine/packages/tap-vsockd/.gitignore
vendored
2
alpine/packages/tap-vsockd/.gitignore
vendored
@ -1 +1 @@
|
||||
tap-vsockd
|
||||
sbin
|
||||
|
@ -1,8 +1,9 @@
|
||||
FROM mobylinux/alpine-build-c:1b53976210ba819823eda5b1d0d3ea337772e97b
|
||||
|
||||
RUN mkdir -p /tap-vsockd
|
||||
WORKDIR /tap-vsockd
|
||||
FROM mobylinux/alpine-build-c:1ea690a7438cdd8a5965eaa034e0a0c521d9cb40
|
||||
|
||||
COPY . /tap-vsockd
|
||||
|
||||
RUN make tap-vsockd
|
||||
WORKDIR /tap-vsockd
|
||||
|
||||
RUN cc -Wall -Werror tap-vsockd.c hvsock.c protocol.c -lpthread -o tap-vsockd
|
||||
|
||||
CMD ["tar", "cf", "-", "tap-vsockd"]
|
||||
|
@ -1,24 +1,9 @@
|
||||
.PHONY: all
|
||||
DEPS=Dockerfile $(wildcard *.c *.h)
|
||||
|
||||
DEPS=tap-vsockd.c hvsock.c hvsock.h protocol.c protocol.h
|
||||
|
||||
all: Dockerfile $(DEPS)
|
||||
docker build -t tap-vsockd:build .
|
||||
docker run --rm tap-vsockd:build cat tap-vsockd > tap-vsockd
|
||||
chmod 755 tap-vsockd
|
||||
|
||||
tap-vsockd: hvsock.o protocol.o tap-vsockd.o
|
||||
gcc -Wall -Werror -o tap-vsockd tap-vsockd.o protocol.o hvsock.o -lpthread
|
||||
|
||||
hvsock.o: hvsock.c hvsock.h
|
||||
gcc -Wall -Werror -c hvsock.c
|
||||
|
||||
protocol.o: protocol.c
|
||||
gcc -Wall -Werror -c protocol.c
|
||||
|
||||
tap-vsockd.o: tap-vsockd.c hvsock.h
|
||||
gcc -Wall -Werror -c tap-vsockd.c
|
||||
sbin/tap-vsockd: $(DEPS)
|
||||
mkdir -p sbin
|
||||
tar cf - $(DEPS) | docker build -t tap-vsockd:build -
|
||||
docker run --rm --net=none tap-vsockd:build | tar xf - -C sbin
|
||||
|
||||
clean:
|
||||
rm -f tap-vsockd
|
||||
docker images -q tap-vsockd:build | xargs docker rmi -f || true
|
||||
rm -rf sbin
|
||||
|
2
alpine/packages/transfused/.gitignore
vendored
2
alpine/packages/transfused/.gitignore
vendored
@ -1 +1 @@
|
||||
/transfused
|
||||
sbin
|
||||
|
@ -1,8 +1,9 @@
|
||||
FROM mobylinux/alpine-build-c:1b53976210ba819823eda5b1d0d3ea337772e97b
|
||||
|
||||
RUN mkdir -p /transfused
|
||||
WORKDIR /transfused
|
||||
FROM mobylinux/alpine-build-c:1ea690a7438cdd8a5965eaa034e0a0c521d9cb40
|
||||
|
||||
COPY . /transfused
|
||||
|
||||
RUN make transfused
|
||||
WORKDIR /transfused
|
||||
|
||||
RUN cc -g -static -Wall -Werror -o transfused transfused.c transfused_log.c transfused_vsock.c
|
||||
|
||||
CMD ["tar", "cf", "-", "transfused"]
|
||||
|
@ -1,18 +1,9 @@
|
||||
.PHONY: all
|
||||
DEPS=Dockerfile $(wildcard *.c *.h)
|
||||
|
||||
HDR=transfused.h transfused_log.h transfused_vsock.h
|
||||
SRC=transfused.c transfused_log.c transfused_vsock.c
|
||||
DEPS=$(HDR) $(SRC)
|
||||
|
||||
|
||||
all: Dockerfile $(DEPS)
|
||||
docker build -t transfused:build .
|
||||
docker run --rm transfused:build cat transfused > transfused
|
||||
chmod 755 transfused
|
||||
|
||||
transfused: $(DEPS)
|
||||
gcc -g -static -Wall -Werror -o transfused $(SRC)
|
||||
sbin/transfused: $(DEPS)
|
||||
mkdir -p sbin
|
||||
tar cf - $(DEPS) | docker build -t transfused:build -
|
||||
docker run --rm --net=none transfused:build | tar xf - -C sbin
|
||||
|
||||
clean:
|
||||
rm -f transfused
|
||||
docker images -q transfused:build | xargs docker rmi -f || true
|
||||
rm -rf sbin
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "include/uapi/linux/vm_sockets.h"
|
||||
#include "vm_sockets.h"
|
||||
|
||||
#include "transfused_log.h"
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user