Skip to content
Snippets Groups Projects
Commit 443e4d9e authored by Sigmund, Dominik's avatar Sigmund, Dominik
Browse files

inital Files added

parent 93f68898
No related branches found
No related tags found
No related merge requests found
Pipeline #81985 canceled
build/
ds
\ No newline at end of file
stages:
- build
- scan
- release
build:
stage: build
image: docker:19.03.12
services:
- docker:dind
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE:latest -f Containerfile .
- docker push $CI_REGISTRY_IMAGE:latest
scan:
stage: scan
image:
name: docker.io/aquasec/trivy:latest
entrypoint: [""]
variables:
TRIVY_USERNAME: "$CI_REGISTRY_USER"
TRIVY_PASSWORD: "$CI_REGISTRY_PASSWORD"
TRIVY_AUTH_URL: "$CI_REGISTRY"
FULL_IMAGE_NAME: $CI_REGISTRY_IMAGE:latest
TRIVY_INSECURE: "true"
script:
- trivy image --clear-cache
- time trivy image --severity HIGH,CRITICAL $FULL_IMAGE_NAME
release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
script:
- release-cli create --name "Release $CI_COMMIT_SHORT_SHA" --description "Release of version $CI_COMMIT_SHORT_SHA" --tag-name "v$CI_COMMIT_SHORT_SHA" --ref "main"
only:
- main
\ No newline at end of file
# CHANGELOG
## [Unreleased]
- Added: `CHANGELOG.md` file.
- Added: `README.md` file.
- Added: `LICENSE` file.
# CONTRIBUTING
We appreciate and welcome contributions from the community to enhance the features and overall quality of DataSmith. Whether you're a developer, tester, or enthusiastic user, there are several ways you can contribute:
## Creating Issues
If you encounter a bug, have a feature request, or want to suggest improvements, please [create an issue]( https://gitlab.ard.de/apps/datasmith/-/issues/new) on our Gitlab repository. When creating an issue, provide detailed information about the problem or enhancement you're addressing. This includes steps to reproduce the issue and any relevant context that can help our team understand and address it effectively.
## Pull Requests
If you'd like to contribute code, documentation, or fixes, we encourage you to submit a pull request. Before creating a pull request, please:
1. Fork the repository.
2. Create a new branch for your changes.
3. Make your modifications, ensuring adherence to our coding standards.
4. Write tests for new features or modifications.
5. Ensure all tests pass.
6. Update the version.yml file
7. Update this README if necessary
8. Submit a merge request to the `main` branch of the repository.
We'll review your pull request, provide feedback, and work with you to ensure that your contribution aligns with the project's goals and standards.
# Use an official Golang image as a build stage
FROM golang:1.22 AS builder
# Set the Current Working Directory inside the container
WORKDIR /app
# Copy the Go Modules manifests
COPY go.mod ./
#COPY go.sum ./
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
# RUN go mod download
# Copy the source from the current directory to the Working Directory inside the container
COPY . .
# Build the Go app for Linux
RUN GOOS=linux GOARCH=amd64 go build -o ds
# Use an official Debian image as the base image
FROM debian:latest
# Install dependencies
RUN apt-get update && apt-get upgrade
# Set the Current Working Directory inside the container
WORKDIR /app
# Copy the built binary from the builder stage
COPY --from=builder /app/ds /usr/local/bin/ds
# Default command
CMD ["ds"]
\ No newline at end of file
# MIT License
Copyright (c) 2024 BR/Sigmund.Dominik
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.
\ No newline at end of file
# DataSmith
Create a Database from Scratch using a CLI like angular ng.
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
## Installation
```bash
sudo apt-get install git
```
cd existing_repo
git remote add origin https://gitlab.ard.de/apps/datasmith.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.ard.de/apps/datasmith/-/settings/integrations)
## Collaborate with your team
```bash
git https://gitlab.ard.de/apps/datasmith.git
cd datasmith
go build -o ds
ln -s $PWD/ds /usr/local/bin/ds
chmod +x /usr/local/bin/ds
```
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Usage
## Test and Deploy
```bash
ds
```
Use the built-in continuous integration in GitLab.
### Create a new project
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
```bash
ds init
```
***
### Add a new table
# Editing this README
```bash
ds add table "Table Name"
```
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Contributing
## Suggestions for a good README
We welcome contributions from the community! If you'd like to contribute to DataSmith, please follow [these guidelines](CONTRIBUTING.md) to help us ensure that your changes are successfully integrated into the project.
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## License
## Name
Choose a self-explaining name for your project.
BuzzBoard Database is licensed under the [MIT License](LICENSE.md). Feel free to use, modify, and distribute it according to your needs.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Authors
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
- **[Dominik Sigmund](https://gitlab.ard.de/dominik.sigmund)** - Lead Developer
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Acknowledgments
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
We appreciate the collaborative efforts that have contributed to the success of DataSmith. We'd like to thank the following individuals and organizations for their support and contributions:
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
- (none yet, but you could be the first!)
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
If you can't find a solution to your issue in the documentation, feel free to reach out to us for assistance. We offer support through the following channels:
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
- **Email:** For non-urgent matters or if you prefer email communication, you can reach us at [apps.datasmith@br.de](mailto:buzzboard@br.de). Please provide detailed information about your issue so that we can assist you more effectively.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
## Important Note
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
When seeking support, make sure to include the following information in your message:
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
1. A detailed description of the issue you're facing.
2. Steps to reproduce the problem (if applicable).
3. Relevant configuration details.
4. Any error messages or logs related to the issue.
## License
For open source projects, say how it is licensed.
This information will help us understand your situation better and provide a more accurate and timely response.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
Thank you for choosing DataSmith!! We're committed to ensuring you have a positive experience, and we appreciate your cooperation in following these support guidelines.
package commands
import (
"fmt"
"os"
"path/filepath"
"time"
"datasmith/config"
"datasmith/templates"
"datasmith/utils"
)
func Add(tablename string) {
utils.PromptIfEmpty(&tablename, "Enter the name of the table: ")
addTable(tablename)
}
func addTable(name string) {
slug := utils.Slugify(name)
// TODO: Do Stuff
fmt.Printf("Added new table '%s' to the project\n", name)
}
// Help returns the help information for the add command
func AddHelp() string {
return "add [tablename]: Add a table to the project."
}
\ No newline at end of file
package commands
import (
"fmt"
)
// Help prints the usage information
func Help() {
helpText := `
DataSmith
(ds) is a tool for generating database projects .
Usage: ds <command> [options]
Commands:
`
helpText += " " + InitHelp() + "\n"
helpText += " " + AddHelp() + "\n"
helpText += " " + VersionHelp() + "\n"
helpText += " " + HelpHelp() + "\n"
fmt.Println(helpText)
}
// HelpHelp returns the help information for the help command
func HelpHelp() string {
return "help: Show this help message."
}
\ No newline at end of file
package commands
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"time"
"datasmith/config"
"datasmith/templates"
"datasmith/utils"
)
func Init(name string) {
utils.PromptIfEmpty(&name, "Enter the name of the project: ")
slug := utils.Slugify(name)
fmt.Printf("Initialized new project structure in '%s'\n", slug)
fmt.Println("Initializing Git repository...")
cmd := exec.Command("git", "init", slug)
cmd.Run()
}
// Help returns the help information for the init command
func InitHelp() string {
return "init [name] : Create a new project with the specified name."
}
package commands
import "fmt"
// Version prints the version of the script
func Version(version string) {
fmt.Printf("ebg version %s\n", version)
}
func VersionHelp() string {
return "version: Show the version of the script."
}
\ No newline at end of file
package config
import (
"encoding/json"
"fmt"
"os"
"os/user"
"path/filepath"
)
type Configuration struct {
User string `json:"author"`
}
var Config Configuration
var configPath string
func LoadConfig() {
usr, err := user.Current()
if err != nil {
fmt.Println("Error getting current user:", err)
return
}
configPath = filepath.Join(usr.HomeDir, ".ds-config")
file, err := os.Open(configPath)
if err != nil {
if os.IsNotExist(err) {
return
}
fmt.Println("Error opening config file:", err)
return
}
defer file.Close()
decoder := json.NewDecoder(file)
if err := decoder.Decode(&Config); err != nil {
fmt.Println("Error decoding config file:", err)
}
}
func SaveConfig() {
file, err := os.Create(configPath)
if err != nil {
fmt.Println("Error creating config file:", err)
return
}
defer file.Close()
encoder := json.NewEncoder(file)
if err := encoder.Encode(&Config); err != nil {
fmt.Println("Error encoding config file:", err)
}
}
\ No newline at end of file
go.mod 0 → 100644
module datasmith
go 1.22.4
\ No newline at end of file
main.go 0 → 100644
package main
import (
"fmt"
"os"
"datasmith/commands"
"datasmith/config"
)
var version = "0.0.1"
func main() {
config.LoadConfig()
if len(os.Args) < 2 {
commands.Help()
return
}
command := os.Args[1]
switch command {
case "init":
var name string
args := os.Args[2:]
commands.InitProject(name, args)
fmt.Println("Done. Now run 'ds add table' to add a table to the database.")
case "add":
if len(os.Args) < 3 {
fmt.Println("Usage: ds add <tablename>")
return
}
name := os.Args[2]
commands.Add(name)
case "version":
commands.Version(version)
case "help":
commands.Help()
default:
fmt.Printf("Unknown command: %s\n", command)
commands.Help()
}
}
\ No newline at end of file
[sqlfluff]
#exclude_rules= LT05
package templates
import (
"embed"
"os"
"path/filepath"
"text/template"
"fmt"
)
//go:embed *.tmpl
var templateFS embed.FS
// LoadTemplate loads a template from the embedded filesystem
func LoadTemplate(tmplName string) (*template.Template, error) {
content, err := templateFS.ReadFile(tmplName + ".tmpl")
if err != nil {
return nil, fmt.Errorf("error reading template '%s': %v", tmplName, err)
}
return template.New(tmplName).Parse(string(content))
}
// CreateFileFromTemplate creates a file from a template
func CreateFileFromTemplate(bookDir, subDir, filename, tmplName string, data interface{}) error {
tmpl, err := LoadTemplate(tmplName)
if err != nil {
return err
}
filePath := filepath.Join(bookDir, subDir, filename)
file, err := os.Create(filePath)
if err != nil {
return err
}
defer file.Close()
if err := tmpl.Execute(file, data); err != nil {
return err
}
return nil
}
\ No newline at end of file
package utils
import (
"bufio"
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"
)
// CheckGit checks if Git is installed and available in PATH
func CheckGit() bool {
_, err := exec.LookPath("git")
return err == nil
}
// Slugify converts a string into a slug suitable for filenames and URLs
func Slugify(name string) string {
// Convert to lowercase, remove non-alphanumeric characters, and replace spaces with hyphens
re := regexp.MustCompile("[^a-z0-9]+")
slug := re.ReplaceAllString(strings.ToLower(name), "-")
slug = strings.Trim(slug, "-")
return slug
}
// PromptIfEmpty prompts the user for input if the given variable is empty
func PromptIfEmpty(value *string, prompt string) {
if *value == "" {
reader := bufio.NewReader(os.Stdin)
fmt.Print(prompt)
input, _ := reader.ReadString('\n')
*value = strings.TrimSpace(input)
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment