@@ -19,19 +19,13 @@ package sampleapp
19
19
import (
20
20
"fmt"
21
21
"io/ioutil"
22
- "os/exec"
23
- "strings"
24
- "testing"
25
22
26
23
yaml "gopkg.in/yaml.v2"
27
24
)
28
25
29
26
const (
30
27
// using these defaults if not provided, see useDefaultIfNotProvided function below
31
- defaultSrcDir = "../../docs/serving/samples/hello-world/helloworld-%s"
32
- defaultWorkDir = "helloworld-%s_tmp"
33
- defaultAppName = "helloworld-%s"
34
- defaultYamlImagePlaceHolder = "docker.io/{username}/helloworld-%s"
28
+ defaultSrcDir = "../../docs/serving/samples/hello-world/helloworld-%s"
35
29
36
30
// ActionMsg serves as documentation purpose, which will be referenced for
37
31
// clearly displaying error messages.
@@ -51,45 +45,16 @@ type AllConfigs struct {
51
45
52
46
// LanguageConfig contains all information for building/deploying an app
53
47
type LanguageConfig struct {
54
- Language string `yaml:"language"`
55
- ExpectedOutput string `yaml:"expectedOutput"`
56
- SrcDir string `yaml:"srcDir"` // Directory contains sample code
57
- WorkDir string `yaml:"workDir"` // Temp work directory
58
- AppName string `yaml:"appName"`
59
- YamlImagePlaceholder string `yaml:"yamlImagePlaceholder"` // Token to be replaced by real docker image URI
60
- PreCommands []Command `yaml:"preCommands"` // Commands to be ran before copying
61
- Copies []string `yaml:"copies"` // Files to be copied from SrcDir to WorkDir
62
- PostCommands []Command `yaml:"postCommands"` // Commands to be ran after copying
48
+ Language string `yaml:"language"`
49
+ SrcDir string `yaml:"srcDir"` // Directory contains sample code
50
+ Copies []string `yaml:"copies"` // Files to be copied by the user from SrcDir
63
51
}
64
52
65
- // Command contains shell commands
66
- type Command struct {
67
- Exec string `yaml:"exec"`
68
- Args string `yaml:"args"`
69
- }
70
-
71
- // UseDefaultIfNotProvided sets default value to SrcDir, WorkDir, AppName, and YamlImagePlaceholder if not provided
53
+ // UseDefaultIfNotProvided sets default value of SrcDir if not provided
72
54
func (lc * LanguageConfig ) UseDefaultIfNotProvided () {
73
55
if "" == lc .SrcDir {
74
56
lc .SrcDir = fmt .Sprintf (defaultSrcDir , lc .Language )
75
57
}
76
- if "" == lc .WorkDir {
77
- lc .WorkDir = fmt .Sprintf (defaultWorkDir , lc .Language )
78
- }
79
- if "" == lc .AppName {
80
- lc .AppName = fmt .Sprintf (defaultAppName , lc .Language )
81
- }
82
- if "" == lc .YamlImagePlaceholder {
83
- lc .YamlImagePlaceholder = fmt .Sprintf (defaultYamlImagePlaceHolder , lc .Language )
84
- }
85
- }
86
-
87
- // Run runs command and fail if it failed
88
- func (c * Command ) Run (t * testing.T ) {
89
- args := strings .Split (c .Args , " " )
90
- if output , err := exec .Command (c .Exec , args ... ).CombinedOutput (); err != nil {
91
- t .Fatalf ("Error executing: '%s' '%s' -err: '%v'" , c .Exec , c .Args , strings .TrimSpace (string (output )))
92
- }
93
58
}
94
59
95
60
// GetConfigs parses a config yaml file and return AllConfigs struct
0 commit comments