-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
101 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,12 @@ import ( | |
"github.com/buildsafedev/bsf/pkg/langdetect" | ||
) | ||
|
||
var ( | ||
commonDevDeps = []string{"[email protected]", "[email protected]"} | ||
commonRTDeps = []string{"[email protected]"} | ||
baseImageName = "ttl.sh/base" | ||
) | ||
|
||
func generatehcl2NixConf(pt langdetect.ProjectType, pd *langdetect.ProjectDetails) (hcl2nix.Config, error) { | ||
switch pt { | ||
case langdetect.GoModule: | ||
|
@@ -36,17 +42,17 @@ func generatehcl2NixConf(pt langdetect.ProjectType, pd *langdetect.ProjectDetail | |
func generateEmptyConf() hcl2nix.Config { | ||
return hcl2nix.Config{ | ||
Packages: hcl2nix.Packages{ | ||
Development: []string{""}, | ||
Runtime: []string{"[email protected]"}, | ||
Development: commonDevDeps, | ||
Runtime: commonRTDeps, | ||
}, | ||
OCIArtifact: []hcl2nix.OCIArtifact{ | ||
{ | ||
Artifact: "pkgs", | ||
Name: "bsf-base-image", | ||
Cmd: []string{}, | ||
Entrypoint: []string{}, | ||
EnvVars: []string{}, | ||
ExposedPorts: []string{}, | ||
Artifact: "pkgs", | ||
Name: baseImageName, | ||
Cmd: []string{}, | ||
Entrypoint: []string{}, | ||
EnvVars: []string{}, | ||
ExposedPorts: []string{}, | ||
ImportConfigs: []string{}, | ||
}, | ||
}, | ||
|
@@ -71,10 +77,12 @@ func genRustCargoConf() (hcl2nix.Config, error) { | |
} else { | ||
CrateName = "my-project" | ||
} | ||
|
||
rustDevDeps := append(commonDevDeps, "[email protected]") | ||
return hcl2nix.Config{ | ||
Packages: hcl2nix.Packages{ | ||
Development: []string{"[email protected]"}, | ||
Runtime: []string{"[email protected]"}, | ||
Development: rustDevDeps, | ||
Runtime: commonRTDeps, | ||
}, | ||
RustApp: &hcl2nix.RustApp{ | ||
WorkspaceSrc: "./.", | ||
|
@@ -84,12 +92,12 @@ func genRustCargoConf() (hcl2nix.Config, error) { | |
}, | ||
OCIArtifact: []hcl2nix.OCIArtifact{ | ||
{ | ||
Artifact: "pkgs", | ||
Name: "bsf-base-image", | ||
Cmd: []string{}, | ||
Entrypoint: []string{}, | ||
EnvVars: []string{}, | ||
ExposedPorts: []string{}, | ||
Artifact: "pkgs", | ||
Name: baseImageName, | ||
Cmd: []string{}, | ||
Entrypoint: []string{}, | ||
EnvVars: []string{}, | ||
ExposedPorts: []string{}, | ||
ImportConfigs: []string{}, | ||
}, | ||
}, | ||
|
@@ -98,10 +106,11 @@ func genRustCargoConf() (hcl2nix.Config, error) { | |
|
||
func genPythonPoetryConf() hcl2nix.Config { | ||
// TODO: maybe we should note down the path of the poetry.lock file and use it here. | ||
poetryDevDeps := append(commonDevDeps, "[email protected]", "[email protected]") | ||
return hcl2nix.Config{ | ||
Packages: hcl2nix.Packages{ | ||
Development: []string{"[email protected]", "[email protected]"}, | ||
Runtime: []string{"[email protected]"}, | ||
Development: poetryDevDeps, | ||
Runtime: commonRTDeps, | ||
}, | ||
PoetryApp: &hcl2nix.PoetryApp{ | ||
ProjectDir: "./.", | ||
|
@@ -113,12 +122,12 @@ func genPythonPoetryConf() hcl2nix.Config { | |
}, | ||
OCIArtifact: []hcl2nix.OCIArtifact{ | ||
{ | ||
Artifact: "pkgs", | ||
Name: "bsf-base-image", | ||
Cmd: []string{}, | ||
Entrypoint: []string{}, | ||
EnvVars: []string{}, | ||
ExposedPorts: []string{}, | ||
Artifact: "pkgs", | ||
Name: baseImageName, | ||
Cmd: []string{}, | ||
Entrypoint: []string{}, | ||
EnvVars: []string{}, | ||
ExposedPorts: []string{}, | ||
ImportConfigs: []string{}, | ||
}, | ||
}, | ||
|
@@ -135,24 +144,26 @@ func genGoModuleConf(pd *langdetect.ProjectDetails) hcl2nix.Config { | |
} | ||
|
||
} | ||
|
||
goDevDeps := append(commonDevDeps, "[email protected]", "[email protected]", "[email protected]") | ||
return hcl2nix.Config{ | ||
Packages: hcl2nix.Packages{ | ||
Development: []string{"[email protected]", "[email protected]", "[email protected]"}, | ||
Development: goDevDeps, | ||
// todo: maybe we should dynamically inject the latest version of such runtime packages(cacert)? | ||
Runtime: []string{"[email protected]"}, | ||
Runtime: commonRTDeps, | ||
}, | ||
GoModule: &hcl2nix.GoModule{ | ||
Name: name, | ||
SourcePath: entrypoint, | ||
}, | ||
OCIArtifact: []hcl2nix.OCIArtifact{ | ||
{ | ||
Artifact: "pkgs", | ||
Name: "bsf-base-image", | ||
Cmd: []string{}, | ||
Entrypoint: []string{}, | ||
EnvVars: []string{}, | ||
ExposedPorts: []string{}, | ||
Artifact: "pkgs", | ||
Name: baseImageName, | ||
Cmd: []string{}, | ||
Entrypoint: []string{}, | ||
EnvVars: []string{}, | ||
ExposedPorts: []string{}, | ||
ImportConfigs: []string{}, | ||
}, | ||
}, | ||
|
@@ -175,23 +186,25 @@ func genJsNpmConf() (hcl2nix.Config, error) { | |
if !ok { | ||
return hcl2nix.Config{}, fmt.Errorf("error fetching project name: %v", err) | ||
} | ||
|
||
nodeDevDeps := append(commonDevDeps, "[email protected]") | ||
return hcl2nix.Config{ | ||
Packages: hcl2nix.Packages{ | ||
Development: []string{"[email protected]"}, | ||
Runtime: []string{"[email protected]"}, | ||
Development: nodeDevDeps, | ||
Runtime: commonRTDeps, | ||
}, | ||
JsNpmApp: &hcl2nix.JsNpmApp{ | ||
PackageName: name, | ||
PackageRoot: "./.", | ||
}, | ||
OCIArtifact: []hcl2nix.OCIArtifact{ | ||
{ | ||
Artifact: "pkgs", | ||
Name: "bsf-base-image", | ||
Cmd: []string{}, | ||
Entrypoint: []string{}, | ||
EnvVars: []string{}, | ||
ExposedPorts: []string{}, | ||
Artifact: "pkgs", | ||
Name: baseImageName, | ||
Cmd: []string{}, | ||
Entrypoint: []string{}, | ||
EnvVars: []string{}, | ||
ExposedPorts: []string{}, | ||
ImportConfigs: []string{}, | ||
}, | ||
}, | ||
|