Navigation Menu

Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Check go version
Browse files Browse the repository at this point in the history
  • Loading branch information
kaduartur committed May 27, 2020
1 parent fd40119 commit 5edb6c0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .circleci/config.yml
Expand Up @@ -84,6 +84,10 @@ jobs:
<<: *ENVIRONMENT
steps:
- checkout
- run:
name: Check go version
command: |
. ./go-version.sh
- run:
name: Install gotestsum
command: |
Expand Down
7 changes: 7 additions & 0 deletions go-version.sh
@@ -0,0 +1,7 @@
#!/bin/bash
GO_VERSION=$(go version)

if [[ $GO_VERSION != *"go1.14"* ]]; then
echo "Go version is not compatible"
exit 1
fi
4 changes: 0 additions & 4 deletions pkg/formula/default_runner.go
@@ -1,7 +1,6 @@
package formula

import (
"fmt"
"os"
"os/exec"

Expand Down Expand Up @@ -29,9 +28,6 @@ func (d DefaultRunner) Run(def Definition, inputType api.TermInputType) error {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

ePwd := fmt.Sprintf(EnvPattern, PwdEnv, setup.pwd)
cmd.Env = append(cmd.Env, ePwd)

if err := d.Inputs(cmd, setup, inputType); err != nil {
return err
}
Expand Down
14 changes: 8 additions & 6 deletions pkg/formula/docker_runner.go
Expand Up @@ -9,11 +9,13 @@ import (
"github.com/ZupIT/ritchie-cli/pkg/file/fileutil"
)

const docker = "docker"
const dockerBuildCmd = "build"
const dockerRunCmd = "run"
const dockerRemoveCmd = "rm"
const envFile = ".env"
const (
docker = "docker"
dockerBuildCmd = "build"
dockerRunCmd = "run"
dockerRemoveCmd = "rm"
envFile = ".env"
)

type DockerRunner struct {
PreRunner
Expand Down Expand Up @@ -44,7 +46,7 @@ func (d DockerRunner) Run(def Definition, inputType api.TermInputType) error {

for _, e := range cmd.Env { // Create a file named .env and add the environment variable inName=inValue
if !fileutil.Exists(envFile) {
if err := fileutil.WriteFile(envFile, []byte(e+ "\n")); err != nil {
if err := fileutil.WriteFile(envFile, []byte(e+"\n")); err != nil {
return err
}
continue
Expand Down

0 comments on commit 5edb6c0

Please sign in to comment.