diff --git a/.github/workflows/.github-ci.yaml b/.github/workflows/.github-ci.yaml index 7fce44c..083d681 100644 --- a/.github/workflows/.github-ci.yaml +++ b/.github/workflows/.github-ci.yaml @@ -1,42 +1,40 @@ -name: ci - -on: - push: - workflow_dispatch: - +name: ci-workflow + +on: [push] jobs: - build: - runs-on: ubuntu-host - + ci: + runs-on: docker + + container: + image: forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/pipe:v0.0.1 + steps: - - - name: Repository meta - id: repository + + - name: Clone Repository + uses: https://forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/DevFW-CICD/checkout@main + + - name: Lint the Repository run: | - registry=${{ github.server_url }} - registry=${registry##http*://} - echo "registry=${registry}" >> "$GITHUB_OUTPUT" - echo "registry=${registry}" - repository="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" - echo "repository=${repository}" >> "$GITHUB_OUTPUT" - echo "repository=${repository}" - - - name: Docker meta - uses: docker/metadata-action@v5 - id: docker - with: - images: ${{ steps.repository.outputs.registry }}/${{ steps.repository.outputs.repository }} - - - name: Login to registry - uses: docker/login-action@v3 - with: - registry: ${{ steps.repository.outputs.registry }} - username: "${{ secrets.PACKAGES_USER }}" - password: "${{ secrets.PACKAGES_TOKEN }}" - - - name: Build and push - uses: docker/build-push-action@v6 - with: - push: true - platforms: linux/amd64,linux/arm64 - tags: ${{ steps.docker.outputs.tags }} + which trivy + golangci-lint run ./... --out-format=json --timeout 5m --issues-exit-code 1 + + - name: Build Credentials File + run: | + mkdir -p /kaniko/.docker + AUTHSTRING=$(echo -n "${{ secrets.REGISTRY_USERNAME }}:${{ secrets.REGISTRY_PASSWORD }}" | base64 -w 0) + echo "{\"auths\":{\"https://forgejo.edf-bootstrap.cx.fg1.ffm.osc.live\":{\"auth\":\"${AUTHSTRING}\"}}}" > /kaniko/.docker/config.json + + - name: Build Docker Container + run: | + /kaniko/executor --dockerfile=./Dockerfile --context=. --destination=forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/fibonacci_go/fibonacci_go:latest + + - name: Vulnerability Scanning + run: | + exit 0 + pwd + whoami + which trivy || true + ls -la /usr/local/bin || true + ls -la /usr/bin || true + trivy image --scanners license,vuln,secret forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/fibonacci_go/fibonacci_go:latest + trivy image --image-config-scanners secret,misconfig forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/fibonacci_go/fibonacci_go:latest diff --git a/.github/workflows/.github-ci_podman.yaml b/.github/workflows/.github-ci_podman.yaml new file mode 100644 index 0000000..2975af0 --- /dev/null +++ b/.github/workflows/.github-ci_podman.yaml @@ -0,0 +1,32 @@ +name: ci-workflow + +on: [push] +jobs: + ci_podman: + runs-on: docker + + container: + image: forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/pipeline-container/complete_podman:v0.0.1 + + steps: + + - name: Clone Repository + uses: https://forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/DevFW-CICD/checkout@main + + - name: Lint the Repository + run: | + golangci-lint run ./... --out-format=json --timeout 5m --issues-exit-code 1 + + - name: Build Credentials File + run: | + echo "${{ secrets.REGISTRY_PASSWORD }}" | sudo podman login forgejo.edf-bootstrap.cx.fg1.ffm.osc.live -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin + + - name: Build Docker Container + run: | + sudo podman build -t fibonacci_go:latest -f Dockerfile . + sudo podman push fibonacci_go:latest forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/fibonacci_go/fibonacci_go:latest + + - name: Vulnerability Scanning + run: | + trivy image --scanners license,vuln,secret forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/fibonacci_go/fibonacci_go:latest + trivy image --image-config-scanners secret,misconfig forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/fibonacci_go/fibonacci_go:latest diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f1c181e --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, build with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out diff --git a/.sonarcloud.properties b/.sonarcloud.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.sonarcloud.properties @@ -0,0 +1 @@ + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..a2c4a90 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: go +go: + - 1.10.x +go_import_path: github.com/t-pwk/go-fibonacci +before_script: + - go get golang.org/x/tools/cmd/cover + - go get github.com/mattn/goveralls +script: + - go test -v -covermode=count -coverprofile=coverage.out ./... + - "$HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 4280220..469822d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,17 @@ FROM golang:1.23.2 AS builder -WORKDIR /app +WORKDIR /shared-data/app COPY ./ ./ # RUN go mod download -RUN echo jojo -RUN CGO_ENABLED=0 GOOS=linux go build -o fibonacci-go cmd/main.go +RUN CGO_ENABLED=0 GOOS=linux go build -o fibonacci_go . # ToDo: use stretch as image for a completly empty container FROM alpine:3.20.3 -WORKDIR /app +WORKDIR /shared-data/app -COPY --from=builder /app/fibonacci-go . +COPY --from=builder /shared-data/app/fibonacci_go . -ENTRYPOINT [ "/app/fibonacci-go" ] +ENTRYPOINT [ "/shared-data/app/fibonacci_go" ] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f84f48f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Tom + +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. diff --git a/README.md b/README.md index 93270eb..8f8e6f4 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,9 @@ Often, especially in modern usage, the sequence is extended by one more initial 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ... ``` -## Implementation Details -This implementation has three methods: `Fibonacci`, `FibonacciBig` and `FibonacciFromString`. +This implementation has two methods: `Fibonacci` and `FibonacciBig`. The `Fibonacci` function is more efficient, however, it returns correct numbers between 0 and 93 (inclusive). The `FibonacciBig` function, on the other hand, is less efficient but returns practically any Fibonacci number. -The `FibonacciFromString` function accepts the input number as a string and it can return an error if the input is not a positive number. This function is used, if the app is called from the HTTP-Server. Example: @@ -47,12 +45,3 @@ And the output is 20: 6765 200: 280571172992510140037611932413038677189525 ``` - - -# HTTP-Server for access - -A HTTP-Server is used to access the fibonacchi app remotely. -The HTTP-Server can be reached on port 9090 on the path '/fibonacchi' of the server domain. - -If it is used on the domain https://cnoe.localtest.me, the fibonacchi value of 1000 can be calculated using the URL https://cnoe.localtest.me/fibonacci?number=1000. The app can calculate the fibonacchi number of values up to 5.000.000. -The calculated result is displayed on the HTML page. \ No newline at end of file diff --git a/argo-workflows/ci-workflow-using-clusterWorkflowTemplates.yaml b/argo-workflows/ci-workflow-using-clusterWorkflowTemplates.yaml new file mode 100644 index 0000000..60c7295 --- /dev/null +++ b/argo-workflows/ci-workflow-using-clusterWorkflowTemplates.yaml @@ -0,0 +1,78 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: ci-workflow-using-cluster-templates- + namespace: argo + labels: + workflows.argoproj.io/archive-strategy: "false" + annotations: + workflows.argoproj.io/description: | + This is a simple ci workflow that utilizes ClusterWorkflowTemplates. +spec: + entrypoint: ci + serviceAccountName: admin + volumeClaimTemplates: + - metadata: + name: shared-data + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi + volumes: + - name: docker-config + secret: + secretName: my-docker-secret + templates: + - name: ci + dag: + tasks: + - name: git-clone + templateRef: + name: git-clone-template + template: git-clone + clusterScope: true + arguments: + parameters: + - name: git-repo + value: "https://forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/Franz.Germann/fibonacci_go.git" + - name: unit-tests + templateRef: + name: unit-tests-template + template: unit-tests + clusterScope: true + dependencies: [git-clone] + - name: lint-scan + templateRef: + name: lint-scan-template + template: lint-scan + clusterScope: true + dependencies: [git-clone] + - name: build + templateRef: + name: build-and-push-image-template + template: build + clusterScope: true + arguments: + parameters: + - name: dockerfile-name + value: "Dockerfile" + - name: image-destination + value: "gitea.cnoe.localtest.me/giteaadmin/fibonacci_go:latest" + dependencies: [unit-tests, lint-scan] + - name: trivy-filesystem-scan + templateRef: + name: trivy-filesystem-scan-template + template: trivy-filesystem-scan + clusterScope: true + dependencies: [git-clone] + - name: trivy-image-scan + templateRef: + name: trivy-image-scan-template + template: trivy-image-scan + clusterScope: true + arguments: + parameters: + - name: image + value: "gitea.cnoe.localtest.me/giteaadmin/fibonacci_go:latest" + dependencies: [build] diff --git a/argo-workflows/example-ci-workflow.yaml b/argo-workflows/example-ci-workflow.yaml new file mode 100644 index 0000000..cc97e83 --- /dev/null +++ b/argo-workflows/example-ci-workflow.yaml @@ -0,0 +1,168 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: example-ci-workflow- + namespace: argo + labels: + workflows.argoproj.io/archive-strategy: "false" + annotations: + workflows.argoproj.io/description: | + This is a simple workflow to show what steps we need to take to deploy an application. +spec: + entrypoint: ci + serviceAccountName: admin + volumeClaimTemplates: + - metadata: + name: shared-data + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi + volumes: + - name: docker-config + secret: + secretName: my-docker-secret + templates: + - name: ci + dag: + tasks: + - name: git-clone + template: git-clone + - name: ls + template: ls + dependencies: [git-clone] + - name: build + template: build + dependencies: [unit-tests, lint-scan] + - name: unit-tests + template: unit-tests + dependencies: [ls] + - name: lint-scan + template: lint-scan + dependencies: [ls] + - name: trivy-image-scan + template: trivy-image-scan + dependencies: [build] + - name: trivy-filesystem-scan + template: trivy-filesystem-scan + dependencies: [git-clone] + - name: deploy-image + template: simple-container + # when: " == true" + dependencies: [trivy-image-scan, trivy-filesystem-scan] + + - name: simple-container + container: + image: alpine:3.20.3 + command: [sh, -c] + args: ["echo test"] + + - name: ls + container: + image: alpine:3.20.3 + command: [sh, -c] + args: + - | + set -e + + ls -la / + ls -la /shared-data + ls -la /shared-data/repo + volumeMounts: + - name: shared-data + mountPath: /shared-data + + - name: git-clone + container: + image: ubuntu:24.10 + command: [sh, -c] + args: + - | + set -e + + apt update + apt install -y git + git clone -b main https://forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/Franz.Germann/fibonacci_go.git /shared-data/repo + + echo git-clone task completed + volumeMounts: + - name: shared-data + mountPath: /shared-data + + - name: build + container: + image: gcr.io/kaniko-project/executor:v1.23.2 + args: + [ + "--dockerfile=Dockerfile", + "--context=/shared-data/repo/", + "--destination=gitea.cnoe.localtest.me/giteaadmin/fibonacci_go:latest", + "--skip-tls-verify" + ] + volumeMounts: + - name: shared-data + mountPath: /shared-data + - name: docker-config + mountPath: /kaniko/.docker/ + + - name: unit-tests + container: + image: golang:1.23.2 + command: [sh, -c] + args: + - | + set -e + + cd /shared-data/repo + go test ./... -v + + echo unit-test task completed + volumeMounts: + - name: shared-data + mountPath: /shared-data + # How to extract artifacts + + - name: lint-scan + container: + image: golangci/golangci-lint:v1.61.0 + command: [sh, -c] + args: + - | + set -e + + cd /shared-data/repo + golangci-lint run ./... --out-format=json --timeout 5m --issues-exit-code 1 + + echo lint-scan task completed + volumeMounts: + - name: shared-data + mountPath: /shared-data + + - name: trivy-filesystem-scan + container: + image: aquasec/trivy:0.56.2 + command: [sh, -c] + args: + - | + set -e + + trivy fs --scanners license,vuln,misconfig,secret /shared-data/repo + + echo trivy-filesystem-scan task completed + volumeMounts: + - name: shared-data + mountPath: /shared-data + + - name: trivy-image-scan + container: + image: aquasec/trivy:0.56.2 + command: [sh, -c] + args: + - | + set -e + + TRIVY_INSECURE=true trivy image --scanners license,vuln,secret gitea.cnoe.localtest.me/giteaadmin/fibonacci_go:latest + TRIVY_INSECURE=true trivy image --image-config-scanners secret,misconfig gitea.cnoe.localtest.me/giteaadmin/fibonacci_go:latest + + echo trivy-image-scan task completed \ No newline at end of file diff --git a/argo-workflows/templates/build-and-push-image-template.yaml b/argo-workflows/templates/build-and-push-image-template.yaml new file mode 100644 index 0000000..d1b8e39 --- /dev/null +++ b/argo-workflows/templates/build-and-push-image-template.yaml @@ -0,0 +1,26 @@ +apiVersion: argoproj.io/v1alpha1 +kind: ClusterWorkflowTemplate +metadata: + name: build-and-push-image-template +spec: + entrypoint: build + templates: + - name: build + inputs: + parameters: + - name: dockerfile-name + - name: image-destination + container: + image: gcr.io/kaniko-project/executor:v1.23.2 + args: + [ + "--dockerfile={{inputs.parameters.dockerfile-name}}", + "--context=/shared-data/repo/", + "--destination={{inputs.parameters.image-destination}}", + "--skip-tls-verify" + ] + volumeMounts: + - name: shared-data + mountPath: /shared-data + - name: docker-config + mountPath: /kaniko/.docker/ \ No newline at end of file diff --git a/argo-workflows/templates/git-clone-template.yaml b/argo-workflows/templates/git-clone-template.yaml new file mode 100644 index 0000000..ba6c5f6 --- /dev/null +++ b/argo-workflows/templates/git-clone-template.yaml @@ -0,0 +1,26 @@ +apiVersion: argoproj.io/v1alpha1 +kind: ClusterWorkflowTemplate +metadata: + name: git-clone-template +spec: + entrypoint: git-clone + templates: + - name: git-clone + inputs: + parameters: + - name: git-repo + container: + image: ubuntu:24.10 + command: [sh, -c] + args: + - | + set -e + + apt update + apt install -y git + git clone -b main {{inputs.parameters.git-repo}} /shared-data/repo + + echo git-clone task completed + volumeMounts: + - name: shared-data + mountPath: /shared-data \ No newline at end of file diff --git a/argo-workflows/templates/lint-scan-template.yaml b/argo-workflows/templates/lint-scan-template.yaml new file mode 100644 index 0000000..ee82068 --- /dev/null +++ b/argo-workflows/templates/lint-scan-template.yaml @@ -0,0 +1,22 @@ +apiVersion: argoproj.io/v1alpha1 +kind: ClusterWorkflowTemplate +metadata: + name: lint-scan-template +spec: + entrypoint: lint-scan + templates: + - name: lint-scan + container: + image: golangci/golangci-lint:v1.61.0 + command: [sh, -c] + args: + - | + set -e + + cd /shared-data/repo + golangci-lint run ./... --out-format=json --timeout 5m --issues-exit-code 1 + + echo lint-scan task completed + volumeMounts: + - name: shared-data + mountPath: /shared-data \ No newline at end of file diff --git a/argo-workflows/templates/trivy-filesystem-scan-template.yaml b/argo-workflows/templates/trivy-filesystem-scan-template.yaml new file mode 100644 index 0000000..c33d970 --- /dev/null +++ b/argo-workflows/templates/trivy-filesystem-scan-template.yaml @@ -0,0 +1,21 @@ +apiVersion: argoproj.io/v1alpha1 +kind: ClusterWorkflowTemplate +metadata: + name: trivy-filesystem-scan-template +spec: + entrypoint: trivy-filesystem-scan + templates: + - name: trivy-filesystem-scan + container: + image: aquasec/trivy:0.56.2 + command: [sh, -c] + args: + - | + set -e + + trivy fs --scanners license,vuln,misconfig,secret /shared-data/repo + + echo trivy-filesystem-scan task completed + volumeMounts: + - name: shared-data + mountPath: /shared-data \ No newline at end of file diff --git a/argo-workflows/templates/trivy-image-scan-template.yaml b/argo-workflows/templates/trivy-image-scan-template.yaml new file mode 100644 index 0000000..d3152f5 --- /dev/null +++ b/argo-workflows/templates/trivy-image-scan-template.yaml @@ -0,0 +1,22 @@ +apiVersion: argoproj.io/v1alpha1 +kind: ClusterWorkflowTemplate +metadata: + name: trivy-image-scan-template +spec: + entrypoint: trivy-image-scan + templates: + - name: trivy-image-scan + inputs: + parameters: + - name: image + container: + image: aquasec/trivy:0.56.2 + command: [sh, -c] + args: + - | + set -e + + TRIVY_INSECURE=true trivy image --scanners license,vuln,secret {{inputs.parameters.image}} + TRIVY_INSECURE=true trivy image --image-config-scanners secret,misconfig {{inputs.parameters.image}} + + echo trivy-image-scan task completed \ No newline at end of file diff --git a/argo-workflows/templates/unit-tests-template.yaml b/argo-workflows/templates/unit-tests-template.yaml new file mode 100644 index 0000000..5e996b8 --- /dev/null +++ b/argo-workflows/templates/unit-tests-template.yaml @@ -0,0 +1,22 @@ +apiVersion: argoproj.io/v1alpha1 +kind: ClusterWorkflowTemplate +metadata: + name: unit-tests-template +spec: + entrypoint: unit-tests + templates: + - name: unit-tests + container: + image: golang:1.23.2 + command: [sh, -c] + args: + - | + set -e + + cd /shared-data/repo + go test ./... -v + + echo unit-test task completed + volumeMounts: + - name: shared-data + mountPath: /shared-data \ No newline at end of file diff --git a/cmd/main.go b/cmd/main.go deleted file mode 100644 index b2d2912..0000000 --- a/cmd/main.go +++ /dev/null @@ -1,17 +0,0 @@ -package main - -import ( - "log" - - "forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/fibonacci_go/internal/http" -) - -func main() { - - err := http.StartServer() - - log.Fatal(err) - - //fmt.Println("20: ", fibonacci.Fibonacci(20)) - //fmt.Println("200: ", fibonacci.FibonacciBig(200)) -} diff --git a/config.json b/config.json new file mode 100644 index 0000000..15bc556 --- /dev/null +++ b/config.json @@ -0,0 +1,7 @@ +{ + "auths": { + "https://gitea.cnoe.localtest.me": { + "auth": "Z2l0ZWFBZG1pbjozbUp5QkFYSUhqT3JPWlZaYlROMjlRPT0=" + } + } +} \ No newline at end of file diff --git a/fib.go b/fib.go new file mode 100644 index 0000000..29e81a9 --- /dev/null +++ b/fib.go @@ -0,0 +1,37 @@ +package fib + +import "math/big" + +// Fibonacci calculates Fibonacci number. +// This function generated correct values from 0 to 93 sequence number. +// For bigger values use FibonacciBig function. +func Fibonacci(n uint) uint64 { + if n <= 1 { + return uint64(n) + } + + var n2, n1 uint64 = 0, 1 + + for i := uint(2); i < n; i++ { + n2, n1 = n1, n1+n2 + } + + return n2 + n1 +} + +// FibonacciBig calculates Fibonacci number using bit.Int. +// For the sequence numbers below 94, it is recommended to use Fibonacci function as it is more efficient. +func FibonacciBig(n uint) *big.Int { + if n <= 1 { + return big.NewInt(int64(n)) + } + + var n2, n1 = big.NewInt(0), big.NewInt(1) + + for i := uint(1); i < n; i++ { + n2.Add(n2, n1) + n1, n2 = n2, n1 + } + + return n1 +} diff --git a/internal/fibonacci/fib_test.go b/fib_test.go similarity index 98% rename from internal/fibonacci/fib_test.go rename to fib_test.go index bfbe77a..df15027 100644 --- a/internal/fibonacci/fib_test.go +++ b/fib_test.go @@ -1,4 +1,4 @@ -package fibonacci +package fib import "testing" diff --git a/go.mod b/go.mod index e676857..bc7f561 100644 --- a/go.mod +++ b/go.mod @@ -1,34 +1,3 @@ -module forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/fibonacci_go +module forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/DevFW/fibonacci_go -go 1.23.1 - -require github.com/gin-gonic/gin v1.10.0 - -require ( - github.com/bytedance/sonic v1.11.6 // indirect - github.com/bytedance/sonic/loader v0.1.1 // indirect - github.com/cloudwego/base64x v0.1.4 // indirect - github.com/cloudwego/iasm v0.2.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.3 // indirect - github.com/gin-contrib/sse v0.1.0 // indirect - github.com/go-playground/locales v0.14.1 // indirect - github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.20.0 // indirect - github.com/goccy/go-json v0.10.2 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/cpuid/v2 v2.2.7 // indirect - github.com/leodido/go-urn v1.4.0 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/pelletier/go-toml/v2 v2.2.2 // indirect - github.com/twitchyliquid64/golang-asm v0.15.1 // indirect - github.com/ugorji/go/codec v1.2.12 // indirect - golang.org/x/arch v0.8.0 // indirect - golang.org/x/crypto v0.23.0 // indirect - golang.org/x/net v0.25.0 // indirect - golang.org/x/sys v0.20.0 // indirect - golang.org/x/text v0.15.0 // indirect - google.golang.org/protobuf v1.34.1 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) +go 1.23.2 diff --git a/go.sum b/go.sum deleted file mode 100644 index 7f08abb..0000000 --- a/go.sum +++ /dev/null @@ -1,89 +0,0 @@ -github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= -github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= -github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= -github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= -github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= -github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= -github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= -github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= -github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= -github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= -github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= -github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= -github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= -github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= -github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= -github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= -github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= -github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= -github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= -github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= -github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= -github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= -golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= -golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= -golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= -golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= -google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/internal/fibonacci/fib.go b/internal/fibonacci/fib.go deleted file mode 100644 index 6469838..0000000 --- a/internal/fibonacci/fib.go +++ /dev/null @@ -1,76 +0,0 @@ -package fibonacci - -import ( - "errors" - "fmt" - "math/big" -) - -// Fibonacci calculates Fibonacci number. -// This function generated correct values from 0 to 93 sequence number. -// For bigger values use FibonacciBig function. -func Fibonacci(n uint) uint64 { - if n <= 1 { - return uint64(n) - } - - var n2, n1 uint64 = 0, 1 - - for i := uint(2); i < n; i++ { - n2, n1 = n1, n1+n2 - } - - return n2 + n1 -} - -// FibonacciBig calculates Fibonacci number using bit.Int. -// For the sequence numbers below 94, it is recommended to use Fibonacci function as it is more efficient. -func FibonacciBig(n uint) *big.Int { - if n <= 1 { - return big.NewInt(int64(n)) - } - - var n2, n1 = big.NewInt(0), big.NewInt(1) - - for i := uint(1); i < n; i++ { - n2.Add(n2, n1) - n1, n2 = n2, n1 - } - - return n1 -} - -func FibonacciFromString(str string) (*big.Int, error) { - - n := new(big.Int) - n, ok := n.SetString(str, 10) - - if !ok { - return nil, errors.New("ConvertError") - } - - if n.Sign() != 1 { - return big.NewInt(int64(n.Int64())), nil - } - - // Initialize two big ints with the first two numbers in the sequence. - a := big.NewInt(0) - b := big.NewInt(1) - - // Loop while a is smaller than 1e100. - for i := int64(1); i <= n.Int64(); i++ { - // Compute the next Fibonacci number, storing it in a. - a.Add(a, b) - // Swap a and b so that b is the next number in the sequence. - a, b = b, a - } - - fmt.Println(a) // 100-digit Fibonacci number - - // Test a for primality. - // (ProbablyPrimes' argument sets the number of Miller-Rabin - // rounds to be performed. 20 is a good value.) - fmt.Println(a.ProbablyPrime(20)) - - return a, nil -} diff --git a/internal/http/server.go b/internal/http/server.go deleted file mode 100644 index 45e702a..0000000 --- a/internal/http/server.go +++ /dev/null @@ -1,39 +0,0 @@ -package http - -import ( - "fmt" - "net/http" - - //"github.com/chenjiandongx/ginprom" - "forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/fibonacci_go/internal/fibonacci" - "github.com/gin-gonic/gin" - //"github.com/prometheus/client_golang/prometheus/promhttp" -) - -func StartServer() error { - r := gin.Default() - - //r.Use(ginprom.PromMiddleware(nil)) - - r.GET("/fibonacci", CalculateFibonacci) - //r.GET("/metrics", gin.WrapH(promhttp.Handler())) - - return r.Run(":9090") -} - -func CalculateFibonacci(c *gin.Context) { - - numberstr := c.Query("number") - - result, err := fibonacci.FibonacciFromString(numberstr) - - if err != nil { - c.AbortWithStatus(http.StatusBadRequest) - - return - } - - c.JSON(200, gin.H{ - "result": fmt.Sprint(result), - }) -} diff --git a/just_a_change.txt b/just_a_change.txt new file mode 100644 index 0000000..e69de29 diff --git a/tls/gitea.cnoe.localtest.me.crt b/tls/gitea.cnoe.localtest.me.crt new file mode 100644 index 0000000..12c8bab --- /dev/null +++ b/tls/gitea.cnoe.localtest.me.crt @@ -0,0 +1,36 @@ +-----BEGIN CERTIFICATE----- +MIIGNDCCBBygAwIBAgIUNEvbJ9DWHN6yFqZHreKPK0HCEhowDQYJKoZIhvcNAQEL +BQAwgYkxCzAJBgNVBAYTAkFCMRIwEAYDVQQIDAlTdGF0ZU5hbWUxETAPBgNVBAcM +CENpdHlOYW1lMRQwEgYDVQQKDAtDb21wYW55TmFtZTEbMBkGA1UECwwSQ29tcGFu +eVNlY3Rpb25OYW1lMSAwHgYDVQQDDBdnaXRlYS5jbm9lLmxvY2FsdGVzdC5tZTAe +Fw0yNDEwMjEwOTIyNTRaFw0zNDEwMTkwOTIyNTRaMIGJMQswCQYDVQQGEwJBQjES +MBAGA1UECAwJU3RhdGVOYW1lMREwDwYDVQQHDAhDaXR5TmFtZTEUMBIGA1UECgwL +Q29tcGFueU5hbWUxGzAZBgNVBAsMEkNvbXBhbnlTZWN0aW9uTmFtZTEgMB4GA1UE +AwwXZ2l0ZWEuY25vZS5sb2NhbHRlc3QubWUwggIiMA0GCSqGSIb3DQEBAQUAA4IC +DwAwggIKAoICAQDwr1ZR+zwY6mBolLl011JppgH4dT0n7aRWkHSVQRIo+oKX6mmc +3/2XMr2LZ1ahdDMh/Ko3/rlc5VzrDGeH7cC1nuMROrHdl14Tx4IiY1xxbvrh0fCw +32cg/JTgeevKFSJkpLGwurmCxH7k/A5O6gcRnTlIR+BBZhjrKTskz3XEuZsV7ccI +o+II3x82Gc/ih12coP4+4yVXP08yTZR2u1aG/lABr0s95MekGegQX+JByXj5PegZ +WHt700WGZvoMTH89TJgsroT9mKv1WJN6qXWnILJzqDd+lt6xAoBRVnHMJ3Jj2CXB +x9xmkkKmYbH7YFN3EJZ9CQAtvA3qnnU6PZlJNSwjc32jGjKAeQz5Z4Qj/PJDQVxs +gjk6dkuBjaAO+kubdFJBaqPmyiVX3ylI1rgB5cPwi7BbMMvmoOjMxGGgWI8t0tmX +BNAoS2ENH6y4JdKLfdBQrsXcmssmVbqatOcQR9sOlcFS4gvTL5KJeCPCebMUYiju +/uluAEjDfT9CnzCGBrYj2xVRJ8m+LkEn0LrjoNK8NlYjnb3+O3mdscYuIcg9YK81 +R4b1besIR7/aRmumI3wfhBH/QHYimlPNBvsJzyFP9ZrJ++K1KgblgSdPsyF+q087 +Zp1tX7cb0gmmB1ryIJlO5PbYnqGPuXnNjH2mOAZGF0zTkU4HxpXduWIANwIDAQAB +o4GRMIGOMB0GA1UdDgQWBBTajUM3VQwD+OZGWXD8CT6YQtTknDAfBgNVHSMEGDAW +gBTajUM3VQwD+OZGWXD8CT6YQtTknDAPBgNVHRMBAf8EBTADAQH/MDsGA1UdEQQ0 +MDKCF2dpdGVhLmNub2UubG9jYWx0ZXN0Lm1lghdnaXRlYS5jbm9lLmxvY2FsdGVz +dC5tZTANBgkqhkiG9w0BAQsFAAOCAgEAfLltgC9MJolvWETmOGHoZtfZIYNKhuLN +uUHkWApoDwtXabhMLv6AsS9pWebcnV1VsuxPVvsUo5l2tH1eYgzqXZVOsWlAjinq +8FmFR+Zz/yt3TvbvLKlXhB7eENqmb+b6IWW35j/BFYaOWesiM0VnDgJDh+iR79RF +FRRjTreXobvG4RcFy9l7qO6/QsdtWpe/Ke7s2xP7cK4kedB9p6OL1kHA6r75T56/ +Smg1t+MXFLiSwFad9cnViHBGuGSOELHTI7hfijMJip98jC+ee0TRX2awh7sfZ9c4 +4WvpyA54mtf1PUosa22q5g219azwKcHofomwQhmEkMBGQuQMKRMXDXoG0TUaYYGz +GbK64ng8AnROz19rpBxPuZ4Ga6gmZOH+T58qlmjROUvroe/FKGfleQj8344H1kBt +OBCxeoJXFBJ0RL4zsKik06hHq9Km9o9GUjcvTrjngQos+TqsMa2b3oWKqTnX/jwk +3/C4b811g5M6eGwR+63Q9VFdsaPvY9lWokwGjuqx/sma8hJR/AOXnL7Lb/zhc60D +iRpsNw/Ye1rqppBDhYeGk0OwZDCn2ogqTm+n1h/8yUrDik74mbUlXsPEStwYMzM5 +KqsviXCYC6Jx3MpLD6fyw8TODTfwPwcv+JYPELQawClNGuy2UV8OR3eKdC5O1Usk +y3MQL06JFq0= +-----END CERTIFICATE-----