Skip to content

Commit ae857bc

Browse files
committed
chore: init repo
0 parents  commit ae857bc

File tree

2,201 files changed

+745044
-0
lines changed

Some content is hidden

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

2,201 files changed

+745044
-0
lines changed

.ameba.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
Excluded:
3+
- vendor/
4+
5+
Naming/BlockParameterName:
6+
Enabled: false
7+
8+
Lint/UselessAssign:
9+
Excluded:
10+
- src/netbox_extractor/cli.cr

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*.cr]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 2
9+
trim_trailing_whitespace = true

.github/workflows/ci.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
name: CI
3+
4+
permissions: {}
5+
6+
on:
7+
push:
8+
branches:
9+
- '**'
10+
paths-ignore:
11+
- "**.md"
12+
pull_request:
13+
branches:
14+
- '**'
15+
paths-ignore:
16+
- "**.md"
17+
schedule:
18+
- cron: '0 4 1 * *'
19+
# Run workflow manually
20+
workflow_dispatch:
21+
22+
jobs:
23+
ameba:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Git checkout
27+
uses: actions/checkout@v6
28+
with:
29+
persist-credentials: false
30+
31+
- name: Setup Crystal
32+
uses: crystal-lang/install-crystal@v1
33+
with:
34+
crystal: 1.18.2
35+
36+
- name: Install dependencies
37+
run: make deps
38+
39+
- name: Run static code analysis
40+
run: make ameba
41+
42+
test_linux:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Git checkout
46+
uses: actions/checkout@v6
47+
with:
48+
persist-credentials: false
49+
50+
- name: Setup Crystal
51+
uses: crystal-lang/install-crystal@v1
52+
with:
53+
crystal: 1.18.2
54+
55+
- name: Install dependencies
56+
run: make deps
57+
58+
- name: Run tests
59+
run: make spec
60+
61+
test_macos_arm64:
62+
runs-on: macos-26
63+
steps:
64+
- name: Git checkout
65+
uses: actions/checkout@v6
66+
with:
67+
persist-credentials: false
68+
69+
- name: Setup Crystal
70+
uses: crystal-lang/install-crystal@v1
71+
with:
72+
crystal: 1.18.2
73+
74+
- name: Install dependencies
75+
run: make deps
76+
77+
- name: Run tests
78+
run: make spec
79+
80+
test_macos_amd64:
81+
runs-on: macos-26-intel
82+
steps:
83+
- name: Git checkout
84+
uses: actions/checkout@v6
85+
with:
86+
persist-credentials: false
87+
88+
- name: Setup Crystal
89+
uses: crystal-lang/install-crystal@v1
90+
with:
91+
crystal: 1.18.2
92+
93+
- name: Install dependencies
94+
run: make deps
95+
96+
- name: Run tests
97+
run: make spec
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
name: Release Binaries
3+
4+
on:
5+
push:
6+
tags:
7+
- '*'
8+
9+
jobs:
10+
release_linux:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Git checkout
14+
uses: actions/checkout@v6
15+
16+
- name: Set up QEMU
17+
uses: docker/setup-qemu-action@v3
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v3
21+
22+
- name: Build static binaries
23+
run: make release-static
24+
25+
- name: Create release and publish assets
26+
uses: ncipollo/release-action@v1
27+
with:
28+
artifacts: "packages/*"
29+
token: ${{ secrets.GITHUB_TOKEN }}
30+
allowUpdates: true
31+
32+
release_macos_arm64:
33+
runs-on: macos-26
34+
steps:
35+
- name: Git checkout
36+
uses: actions/checkout@v6
37+
38+
- name: Setup Crystal
39+
uses: crystal-lang/install-crystal@v1
40+
with:
41+
crystal: 1.18.2
42+
43+
- name: Install dependencies
44+
run: make deps-release
45+
46+
- name: Build binary
47+
run: make release OUTPUT_FILE=netbox-extractor-darwin-arm64
48+
49+
- name: Create release and publish assets
50+
uses: ncipollo/release-action@v1
51+
with:
52+
artifacts: "bin/*"
53+
token: ${{ secrets.GITHUB_TOKEN }}
54+
allowUpdates: true
55+
56+
release_macos_amd64:
57+
runs-on: macos-26-intel
58+
steps:
59+
- name: Git checkout
60+
uses: actions/checkout@v6
61+
62+
- name: Setup Crystal
63+
uses: crystal-lang/install-crystal@v1
64+
with:
65+
crystal: 1.18.2
66+
67+
- name: Install dependencies
68+
run: make deps-release
69+
70+
- name: Build binary
71+
run: make release OUTPUT_FILE=netbox-extractor-darwin-amd64
72+
73+
- name: Create release and publish assets
74+
uses: ncipollo/release-action@v1
75+
with:
76+
artifacts: "bin/*"
77+
token: ${{ secrets.GITHUB_TOKEN }}
78+
allowUpdates: true

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Ignore generated data
2+
/docs/
3+
/lib/
4+
/packages/
5+
6+
# Ignore all bin files
7+
/bin/*
8+
!/bin/.keep
9+
10+
# Ignore config files
11+
netbox-extractor.yml
12+
/config/*
13+
14+
# Ignore env files
15+
.env
16+
17+
# Ignore MacOS files
18+
.DS_Store
19+
20+
# Ignore generated config
21+
/generated
22+
23+
# Ignore OpenAPI jar
24+
openapi-generator-cli.jar*

.tool-versions

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
crystal 1.18.2
2+
java openjdk-25
3+
python 3.11.14

Brewfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
# because we heavily rely on it
4+
brew 'bash'
5+
6+
# to run some tasks
7+
brew 'make'
8+
9+
# to install other tools
10+
brew 'asdf'
11+
12+
# to download OpenAPI cli
13+
brew 'curl'

Dockerfile

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
###########
2+
# CRYSTAL #
3+
###########
4+
5+
FROM alpine:3.23 AS crystal
6+
7+
RUN apk add --update --no-cache \
8+
make \
9+
crystal=~1.18 \
10+
shards \
11+
gc-dev \
12+
gc-static \
13+
git \
14+
libxml2-dev \
15+
libxml2-static \
16+
openssl-dev \
17+
openssl-libs-static \
18+
gmp-dev \
19+
gmp-static \
20+
pcre2-dev \
21+
pcre2-static \
22+
xz-dev \
23+
xz-static \
24+
yaml-dev \
25+
yaml-static \
26+
zlib-dev \
27+
zlib-static \
28+
upx
29+
30+
#########
31+
# BUILD #
32+
#########
33+
34+
FROM crystal AS build-binary-file
35+
36+
# Fetch platforms variables from ARGS
37+
ARG TARGETPLATFORM
38+
ARG TARGETOS
39+
ARG TARGETARCH
40+
ARG TARGETVARIANT
41+
42+
# Export them to build binary files with the right name: netbox-extractor-linux-amd64
43+
ENV \
44+
TARGETPLATFORM=${TARGETPLATFORM} \
45+
TARGETOS=${TARGETOS} \
46+
TARGETARCH=${TARGETARCH} \
47+
TARGETVARIANT=${TARGETVARIANT}
48+
49+
# Set build environment
50+
WORKDIR /build
51+
COPY .git/ /build/.git/
52+
COPY shard.yml shard.lock /build/
53+
COPY Makefile.release /build/Makefile
54+
COPY src/ /build/src/
55+
COPY vendor/ /build/vendor/
56+
COPY templates/ /build/templates/
57+
RUN mkdir /build/bin
58+
59+
# Build the binary
60+
RUN make release
61+
62+
# Extract binary from Docker image
63+
FROM scratch AS binary-file
64+
ARG TARGETOS
65+
ARG TARGETARCH
66+
COPY --from=build-binary-file /build/bin/netbox-extractor-${TARGETOS}-${TARGETARCH} /
67+
68+
###########
69+
# RUNTIME #
70+
###########
71+
72+
# Build distroless images \o/
73+
FROM gcr.io/distroless/static-debian12 AS docker-image
74+
75+
# Fetch platforms variables from ARGS
76+
ARG TARGETOS
77+
ARG TARGETARCH
78+
79+
# Grab netbox-extractor binary from **binary-file** step and inject it in the final image
80+
COPY --from=build-binary-file /build/bin/netbox-extractor-${TARGETOS}-${TARGETARCH} /usr/bin/netbox-extractor
81+
82+
# Set runtime environment
83+
USER nonroot
84+
ENV USER=nonroot
85+
ENV HOME=/home/nonroot
86+
WORKDIR /home/nonroot
87+
ENTRYPOINT ["netbox-extractor"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Nicolas Rodriguez <nico@nicoladmin.fr>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)