Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
move from bitbucket
Browse files Browse the repository at this point in the history
merged changes from bitbucket pr (#2)

* merged changes from bitbucket pr

* updated bitbucket pr review comments

added aliases for supported languages (#4)

Add options to ValidateDNS

Add tag prefix const

update specs for builder changes (#6)

* update specs for builder changes

* remove depreciated work dir stuff

* updated builder wd for cleaner usage

9 bbox specs (#11)

* minor changes for bbox

* wip

* specs for bboxes

* update go-simple-container

removed path from database (#10)

Add Basic Structure Methods (#13)

* clean up param names, add interfaces for mocks usage

* change license to BSD-3-Cause

* update LICENSE

---------

Co-authored-by: samyfodil <[email protected]>
  • Loading branch information
samyfodil authored and tafseer-khan committed Apr 13, 2023
1 parent ed910e1 commit 0baa737
Show file tree
Hide file tree
Showing 94 changed files with 3,382 additions and 21 deletions.
50 changes: 50 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# These are some examples of commonly ignored file patterns.
# You should customize this list as applicable to your project.
# Learn more about .gitignore:
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore

# Node artifact files
node_modules/
dist/

# Compiled Java class files
*.class

# Compiled Python bytecode
*.py[cod]

# Log files
*.log

# Package files
*.jar

# Maven
target/
dist/

# JetBrains IDE
.idea/

# Unit test reports
TEST*.xml

# Generated by MacOS
.DS_Store

# Generated by Windows
Thumbs.db

# Applications
*.app
*.exe
*.war

# Large media files
*.mp4
*.tiff
*.avi
*.flv
*.mov
*.wmv

78 changes: 57 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,57 @@
MIT License

Copyright (c) 2023 Taubyte

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.
Copyright (c) 2020 Taubyte. All rights reserved.

Redis Source Available License 2.0 dated November 15, 2022

## Acceptance

By using the software, you agree to all of the terms and conditions below.

## Copyright License

The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below.

## Limitations

You may not make the functionality of the software or a modified version available to third parties as a service, or distribute the software or a modified version in a manner that makes the functionality of the software available to third parties.
Making the functionality of the software or modified version available to third parties includes, without limitation, enabling third parties to interact with the functionality of the software or modified version in distributed form or remotely through a computer network, offering a product or service the value of which entirely or primarily derives from the value of the software or modified version, or offering a product or service that accomplishes for users the primary purpose of the software or modified version.

You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.

## Patents

The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.

## Notices

You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.

## No Other Rights

These terms do not imply any licenses other than those expressly granted in these terms.
Termination

If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violations of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.

## No Liability

As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.

## Definitions

The licensor is the entity offering these terms, and the software is the software the licensor makes available under these terms, including any portion of it.

To modify a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission other than making an exact copy. The resulting work is called a modified version of the earlier work.

you refers to the individual or entity agreeing to these terms.

your company is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. control means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.

your licenses are all the licenses granted to you for the software under these terms.

use means anything you do with the software requiring one of your licenses.

trademark means trademarks, service marks, and similar rights.



24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

[![Release](https://img.shields.io/github/release/taubyte/go-specs.svg)](https://github.com/taubyte/go-specs/releases)
[![License](https://img.shields.io/github/license/taubyte/go-specs)](LICENSE)
[![Go Report Card](https://goreportcard.com/badge/taubyte/go-specs)](https://goreportcard.com/report/taubyte/go-specs)
[![GoDoc](https://godoc.org/github.com/taubyte/go-specs?status.svg)](https://pkg.go.dev/github.com/taubyte/go-specs)
[![Discord](https://img.shields.io/discord/973677117722202152?color=%235865f2&label=discord)](https://tau.link/discord)

# taubyte/go-specs

A Go implementation of Taubyte Specs.

# License
Please see the LICENSE file for details.


# Help
Find us on our [Discord](https://discord.gg/taubyte)


# Maintainers
- Samy Fodil @samyfodil
- Sam Stoltenberg @skelouse
- Tafseer Khan @tafseer-khan
- Aron Jalbuena @arontaubyte
155 changes: 155 additions & 0 deletions builders/common/methods.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
package common

import (
"bytes"
"errors"
"fmt"
"io/fs"
"os"
"path"

ci "github.com/taubyte/go-simple-container"
"github.com/taubyte/go-specs/builders"
"github.com/taubyte/go-specs/builders/wasm"
"github.com/taubyte/go-specs/builders/website"
"github.com/taubyte/utils/bundle"
)

func Wd(workDir string) (*dir, error) {
taubyteDir := TaubyteDir
_, err := os.Stat(path.Join(workDir, TaubyteDir))
if err != nil {
taubyteDir = DepreciatedTaubyteDir
_, err := os.Stat(path.Join(workDir, taubyteDir))
if err != nil {
return nil, fmt.Errorf("no taubyte directory found in `%s`", workDir)
}
}

return &dir{
wd: workDir,
taubyteDir: taubyteDir,
}, nil
}

func (d *dir) Wasm() builders.Wasm {
return wasm.Dir{Dir: d}
}

func (d *dir) Website() builders.Website {
return website.Dir{Dir: d}
}

func (d *dir) String() string {
return d.wd
}

func (d *dir) CodeSource(file string) string {
return path.Join(d.String(), file)
}

func (d *dir) TaubyteDir() string {
return path.Join(d.String(), d.taubyteDir)
}

func (d *dir) ConfigFile() string {
return path.Join(d.TaubyteDir(), ConfigFile)
}

func (d *dir) DockerDir() builders.DockerDirType {
return dockerDir(path.Join(d.TaubyteDir(), DockerDir))
}

func (d *dir) DockerFile() string {
return path.Join(d.DockerDir().String(), Dockerfile)
}

func (d *dir) SetSourceVolume() ci.ContainerOption {
return ci.Volume(d.String(), "/"+builders.Source)
}

func (d *dir) SetOutVolume(dir string) ci.ContainerOption {
return ci.Volume(dir, "/"+builders.Output)
}

func (d *dir) SetEnvironmentVariables() ci.ContainerOption {
return ci.Variables(map[string]string{
"OUT": "/" + builders.Output,
"SRC": "/" + builders.Source,
})
}

func (d *dir) SetBuildCommand(script string) ci.ContainerOption {
return ci.Command([]string{"/bin/sh", "/" + builders.Source + "/" + d.taubyteDir + "/" + script + ScriptExtension})
}

func (d *dir) DefaultOptions(script, outDir string, environment builders.Environment) []ci.ContainerOption {
ops := []ci.ContainerOption{
d.SetSourceVolume(),
d.SetEnvironmentVariables(),
d.SetOutVolume(outDir),
d.SetBuildCommand(script),
}

if len(environment.Variables) > 0 {
ops = append(ops, ci.Variables(environment.Variables))
}

return ops
}

func ExtraVolumes(wd string, volumes ...ExtraVolume) ([]ci.ContainerOption, error) {
options := make([]ci.ContainerOption, 0, len(volumes))
for _, volume := range volumes {
if len(volume.SourcePath) == 0 || len(volume.ContainerPath) == 0 {
return nil, errors.New("attempting to parse an empty volume")
}

if volume.SourceIsRelativeToBuildDirectory == true {
volume.SourcePath = path.Join(wd, volume.SourcePath)
}

if string(volume.ContainerPath[0]) == "/" {
options = append(options, ci.Volume(volume.SourcePath, volume.ContainerPath))
} else {
options = append(options, ci.Volume(volume.SourcePath, "/"+volume.ContainerPath))
}
}

return options, nil
}

func (d dockerDir) String() string {
return string(d)
}

func (d dockerDir) Stat() (fs.FileInfo, error) {
fileInfo, err := os.Stat(string(d))
if err != nil {
return nil, err
}
if !fileInfo.IsDir() {
return nil, fmt.Errorf("expected path `%s` to be directory, got file", d)
}

return fileInfo, nil
}
func (d dockerDir) Tar() ([]byte, error) {
ops := bundle.Options{FileOptions: bundle.FileOptions{
AccessTime: DefaultTime,
ChangeTime: DefaultTime,
ModTime: DefaultTime,
}}

var buf bytes.Buffer
err := bundle.Tarball(string(d), &ops, &buf)
if err != nil {
return nil, fmt.Errorf("tarball failed with: %s", err)
}

return buf.Bytes(), nil
}

func DefaultWDError(err error) error {
return fmt.Errorf(defaultWDError, err)
}
14 changes: 14 additions & 0 deletions builders/common/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package common

type dir struct {
wd string
taubyteDir string
}

type dockerDir string

type ExtraVolume struct {
SourcePath string
ContainerPath string
SourceIsRelativeToBuildDirectory bool
}
20 changes: 20 additions & 0 deletions builders/common/vars.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package common

import "time"

const (
DockerDir = "Docker"
TaubyteDir = ".taubyte"
DepreciatedTaubyteDir = "taubyte"
Dockerfile = "Dockerfile"
ScriptExtension = ".sh"
ConfigFile = "config.yaml"
)

var (
ImageCleanInterval = 24 * time.Hour
ImageCleanAge = 7 * ImageCleanInterval
DefaultTime = time.Unix(0, 0)

defaultWDError = "setting working directory failed with: %s"
)
11 changes: 11 additions & 0 deletions builders/methods.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package builders

/******************** Backwards Compatibility ************************/

func (c *Config) HandleDepreciatedEnvironment() (environment Environment) {
if len(c.Environment.Image) == 0 {
return c.Enviroment
}

return c.Environment
}
Loading

0 comments on commit 0baa737

Please sign in to comment.