From b89a5a658d398c62d4a8e595e5713373169af21a Mon Sep 17 00:00:00 2001 From: Suneha Bose Date: Fri, 16 Jun 2023 18:35:39 -0700 Subject: [PATCH 1/9] changes for python file entry point detection --- cmd/create_test.go | 39 +++++++++++++++++++++++++- pkg/languages/defaults/python.go | 19 +++++++++++-- pkg/languages/defaults/python_test.go | 33 +++++++++++++++++++++- template/dockerfiles/python/Dockerfile | 2 +- 4 files changed, 88 insertions(+), 5 deletions(-) diff --git a/cmd/create_test.go b/cmd/create_test.go index 58380f2b..7d05e409 100644 --- a/cmd/create_test.go +++ b/cmd/create_test.go @@ -15,6 +15,7 @@ import ( "github.com/Azure/draft/pkg/config" "github.com/Azure/draft/pkg/languages" "github.com/Azure/draft/pkg/linguist" + "github.com/Azure/draft/pkg/reporeader" "github.com/Azure/draft/pkg/templatewriter/writers" "github.com/Azure/draft/template" ) @@ -53,7 +54,6 @@ func TestRun(t *testing.T) { assert.False(t, lowerLang == "") assert.True(t, err == nil) err = mockCC.generateDockerfile(detectedLang, lowerLang) - println(err) assert.True(t, err == nil) //Write back old Dockerfile @@ -105,6 +105,43 @@ func TestRun(t *testing.T) { } } +func TestRunCreateDockerfileWithRepoReader(t *testing.T) { + mockCC := &createCmd{} + mockCC.repoReader = &reporeader.TestRepoReader{Files: map[string][]byte{ + "foo.py": []byte("print('Hello World')"), + "main.py": []byte("print('Hello World')"), + }} + mockCC.createConfig = &CreateConfig{} + mockCC.createConfig.LanguageType = "python" + mockCC.createConfig.LanguageVariables = []UserInputs{} + mockPortInput := UserInputs{Name: "PORT", Value: "8080"} + mockCC.createConfig.LanguageVariables = append(mockCC.createConfig.LanguageVariables, mockPortInput) + mockCC.templateWriter = &writers.LocalFSWriter{} + + detectedLang, lowerLang, err := mockCC.mockDetectLanguage() + assert.False(t, detectedLang == nil) + assert.True(t, lowerLang == "python") + assert.Nil(t, err) + + err = mockCC.generateDockerfile(detectedLang, lowerLang) + assert.True(t, err == nil) + + dockerFileContent, err := ioutil.ReadFile("Dockerfile") + if err != nil { + t.Error(err) + } + assert.Contains(t, string(dockerFileContent), "CMD [\"main.py\"]") + + err = os.Remove("Dockerfile") + if err != nil { + t.Error(err) + } + os.RemoveAll(".dockerignore") + if err != nil { + t.Error(err) + } +} + func TestInitConfig(t *testing.T) { mockCC := &createCmd{} mockCC.createConfig = &CreateConfig{} diff --git a/pkg/languages/defaults/python.go b/pkg/languages/defaults/python.go index 98ac496e..13f8ba41 100644 --- a/pkg/languages/defaults/python.go +++ b/pkg/languages/defaults/python.go @@ -2,6 +2,7 @@ package defaults import ( "fmt" + "strings" "github.com/Azure/draft/pkg/reporeader" ) @@ -16,8 +17,22 @@ func (p PythonExtractor) ReadDefaults(r reporeader.RepoReader) (map[string]strin if err != nil { return nil, fmt.Errorf("error finding python files: %v", err) } - if len(files) > 0 { - extractedValues["ENTRYPOINT"] = files[0] + for index, file := range files { + fileContent, err := r.ReadFile(file) + if err != nil { + return nil, fmt.Errorf(("error reading python files")) + } + fileContentInString := string(fileContent) + if strings.Contains(fileContentInString, `if __name__ == '__main__'`) || file == "main.py" || file == "app.py" { + extractedValues["ENTRYPOINT"] = files[index] + break + } + } + + if _, ok := extractedValues["ENTRYPOINT"]; !ok { + if len(files) > 0 { + extractedValues["ENTRYPOINT"] = files[0] + } } return extractedValues, nil diff --git a/pkg/languages/defaults/python_test.go b/pkg/languages/defaults/python_test.go index 9e636c5b..13518ecd 100644 --- a/pkg/languages/defaults/python_test.go +++ b/pkg/languages/defaults/python_test.go @@ -65,7 +65,38 @@ func TestPythonExtractor_ReadDefaults(t *testing.T) { "ENTRYPOINT": "foo.py", }, wantErr: false, - }, { + }, + { + name: "extract python file containing the string \"__name__=='__main__'\" as the entrypoint", + args: args{ + r: reporeader.TestRepoReader{ + Files: map[string][]byte{ + "foo.py": []byte("print('hello world')"), + "bar.py": []byte("if __name__ == '__main__': print('hello world')"), + }, + }, + }, + want: map[string]string{ + "ENTRYPOINT": "bar.py", + }, + wantErr: false, + }, + { + name: "extract python file named app.py as the entrypoint", + args: args{ + r: reporeader.TestRepoReader{ + Files: map[string][]byte{ + "foo.py": []byte("print('Hello World')"), + "app.py": []byte("print('Hello World')"), + }, + }, + }, + want: map[string]string{ + "ENTRYPOINT": "app.py", + }, + wantErr: false, + }, + { name: "no extraction if no python files", args: args{ r: reporeader.TestRepoReader{ diff --git a/template/dockerfiles/python/Dockerfile b/template/dockerfiles/python/Dockerfile index 985a8640..9516b0c4 100644 --- a/template/dockerfiles/python/Dockerfile +++ b/template/dockerfiles/python/Dockerfile @@ -9,4 +9,4 @@ RUN pip install --no-cache-dir -r requirements.txt COPY . . ENTRYPOINT ["python"] -CMD ["app.py"] \ No newline at end of file +CMD ["{{ENTRYPOINT}}"] \ No newline at end of file From 4889f6ce4aeb2e6879e13b3475eb23f63c5737bb Mon Sep 17 00:00:00 2001 From: Suneha Bose Date: Wed, 21 Jun 2023 13:04:22 -0700 Subject: [PATCH 2/9] added dest to reporeader --- cmd/create.go | 2 +- pkg/languages/defaults/python.go | 19 +++++++++++++------ pkg/languages/defaults/python_test.go | 2 +- pkg/languages/languages.go | 4 ++-- pkg/reporeader/reporeader.go | 2 +- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/cmd/create.go b/cmd/create.go index 53ca7d4f..33db6137 100644 --- a/cmd/create.go +++ b/cmd/create.go @@ -258,7 +258,7 @@ func (cc *createCmd) generateDockerfile(langConfig *config.DraftConfig, lowerLan } // Extract language-specific defaults from repo - extractedDefaults, err := cc.supportedLangs.ExtractDefaults(lowerLang, cc.repoReader) + extractedDefaults, err := cc.supportedLangs.ExtractDefaults(lowerLang, cc.repoReader, cc.dest) if err != nil { return err } diff --git a/pkg/languages/defaults/python.go b/pkg/languages/defaults/python.go index 13f8ba41..32de1a1b 100644 --- a/pkg/languages/defaults/python.go +++ b/pkg/languages/defaults/python.go @@ -2,7 +2,7 @@ package defaults import ( "fmt" - "strings" + "regexp" "github.com/Azure/draft/pkg/reporeader" ) @@ -11,19 +11,26 @@ type PythonExtractor struct { } // ReadDefaults reads the default values for the language from the repo files -func (p PythonExtractor) ReadDefaults(r reporeader.RepoReader) (map[string]string, error) { +func (p PythonExtractor) ReadDefaults(r reporeader.RepoReader, dest string) (map[string]string, error) { extractedValues := make(map[string]string) - files, err := r.FindFiles(".", []string{"*.py"}, 0) + files, err := r.FindFiles(dest, []string{"*.py"}, 0) if err != nil { return nil, fmt.Errorf("error finding python files: %v", err) } - for index, file := range files { - fileContent, err := r.ReadFile(file) + + entryPointPattern := `if\s*__name__\s*==\s*["']__main__["']` + compiledPattern, err := regexp.Compile(entryPointPattern) + if err != nil { + return nil, fmt.Errorf("error compiling regex pattern: %v", err) + } + for index, fileName := range files { + fileContent, err := r.ReadFile(fileName) if err != nil { return nil, fmt.Errorf(("error reading python files")) } fileContentInString := string(fileContent) - if strings.Contains(fileContentInString, `if __name__ == '__main__'`) || file == "main.py" || file == "app.py" { + + if compiledPattern.MatchString(fileContentInString) || fileName == "main.py" || fileName == "app.py" { extractedValues["ENTRYPOINT"] = files[index] break } diff --git a/pkg/languages/defaults/python_test.go b/pkg/languages/defaults/python_test.go index 13518ecd..0165e749 100644 --- a/pkg/languages/defaults/python_test.go +++ b/pkg/languages/defaults/python_test.go @@ -135,7 +135,7 @@ func TestPythonExtractor_ReadDefaults(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { p := PythonExtractor{} - got, err := p.ReadDefaults(tt.args.r) + got, err := p.ReadDefaults(tt.args.r, "./testDir") if (err != nil) != tt.wantErr { t.Errorf("ReadDefaults() error = %v, wantErr %v", err, tt.wantErr) return diff --git a/pkg/languages/languages.go b/pkg/languages/languages.go index c57b9e02..b1bb715a 100644 --- a/pkg/languages/languages.go +++ b/pkg/languages/languages.go @@ -117,7 +117,7 @@ func CreateLanguagesFromEmbedFS(dockerfileTemplates embed.FS, dest string) *Lang return l } -func (l *Languages) ExtractDefaults(lowerLang string, r reporeader.RepoReader) ([]config.BuilderVarDefault, error) { +func (l *Languages) ExtractDefaults(lowerLang string, r reporeader.RepoReader, dest string) ([]config.BuilderVarDefault, error) { extractors := []reporeader.VariableExtractor{ &defaults.PythonExtractor{}, } @@ -129,7 +129,7 @@ func (l *Languages) ExtractDefaults(lowerLang string, r reporeader.RepoReader) ( } for _, extractor := range extractors { if extractor.MatchesLanguage(lowerLang) { - newDefaults, err := extractor.ReadDefaults(r) + newDefaults, err := extractor.ReadDefaults(r, dest) if err != nil { return nil, fmt.Errorf("error reading defaults for language %s: %v", lowerLang, err) } diff --git a/pkg/reporeader/reporeader.go b/pkg/reporeader/reporeader.go index 9c746e28..77190755 100644 --- a/pkg/reporeader/reporeader.go +++ b/pkg/reporeader/reporeader.go @@ -15,7 +15,7 @@ type RepoReader interface { // VariableExtractor is an interface that can be implemented for extracting variables from a repo's files type VariableExtractor interface { - ReadDefaults(r RepoReader) (map[string]string, error) + ReadDefaults(r RepoReader, dest string) (map[string]string, error) MatchesLanguage(lowerlang string) bool GetName() string } From dcdb15dfb8a8244c0a050ea4f9f5317255f5cfa8 Mon Sep 17 00:00:00 2001 From: Suneha Bose Date: Wed, 21 Jun 2023 14:56:14 -0700 Subject: [PATCH 3/9] Revert "added dest to reporeader" This reverts commit 4889f6ce4aeb2e6879e13b3475eb23f63c5737bb. --- cmd/create.go | 2 +- pkg/languages/defaults/python.go | 19 ++++++------------- pkg/languages/defaults/python_test.go | 2 +- pkg/languages/languages.go | 4 ++-- pkg/reporeader/reporeader.go | 2 +- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/cmd/create.go b/cmd/create.go index 33db6137..53ca7d4f 100644 --- a/cmd/create.go +++ b/cmd/create.go @@ -258,7 +258,7 @@ func (cc *createCmd) generateDockerfile(langConfig *config.DraftConfig, lowerLan } // Extract language-specific defaults from repo - extractedDefaults, err := cc.supportedLangs.ExtractDefaults(lowerLang, cc.repoReader, cc.dest) + extractedDefaults, err := cc.supportedLangs.ExtractDefaults(lowerLang, cc.repoReader) if err != nil { return err } diff --git a/pkg/languages/defaults/python.go b/pkg/languages/defaults/python.go index 32de1a1b..13f8ba41 100644 --- a/pkg/languages/defaults/python.go +++ b/pkg/languages/defaults/python.go @@ -2,7 +2,7 @@ package defaults import ( "fmt" - "regexp" + "strings" "github.com/Azure/draft/pkg/reporeader" ) @@ -11,26 +11,19 @@ type PythonExtractor struct { } // ReadDefaults reads the default values for the language from the repo files -func (p PythonExtractor) ReadDefaults(r reporeader.RepoReader, dest string) (map[string]string, error) { +func (p PythonExtractor) ReadDefaults(r reporeader.RepoReader) (map[string]string, error) { extractedValues := make(map[string]string) - files, err := r.FindFiles(dest, []string{"*.py"}, 0) + files, err := r.FindFiles(".", []string{"*.py"}, 0) if err != nil { return nil, fmt.Errorf("error finding python files: %v", err) } - - entryPointPattern := `if\s*__name__\s*==\s*["']__main__["']` - compiledPattern, err := regexp.Compile(entryPointPattern) - if err != nil { - return nil, fmt.Errorf("error compiling regex pattern: %v", err) - } - for index, fileName := range files { - fileContent, err := r.ReadFile(fileName) + for index, file := range files { + fileContent, err := r.ReadFile(file) if err != nil { return nil, fmt.Errorf(("error reading python files")) } fileContentInString := string(fileContent) - - if compiledPattern.MatchString(fileContentInString) || fileName == "main.py" || fileName == "app.py" { + if strings.Contains(fileContentInString, `if __name__ == '__main__'`) || file == "main.py" || file == "app.py" { extractedValues["ENTRYPOINT"] = files[index] break } diff --git a/pkg/languages/defaults/python_test.go b/pkg/languages/defaults/python_test.go index 0165e749..13518ecd 100644 --- a/pkg/languages/defaults/python_test.go +++ b/pkg/languages/defaults/python_test.go @@ -135,7 +135,7 @@ func TestPythonExtractor_ReadDefaults(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { p := PythonExtractor{} - got, err := p.ReadDefaults(tt.args.r, "./testDir") + got, err := p.ReadDefaults(tt.args.r) if (err != nil) != tt.wantErr { t.Errorf("ReadDefaults() error = %v, wantErr %v", err, tt.wantErr) return diff --git a/pkg/languages/languages.go b/pkg/languages/languages.go index b1bb715a..c57b9e02 100644 --- a/pkg/languages/languages.go +++ b/pkg/languages/languages.go @@ -117,7 +117,7 @@ func CreateLanguagesFromEmbedFS(dockerfileTemplates embed.FS, dest string) *Lang return l } -func (l *Languages) ExtractDefaults(lowerLang string, r reporeader.RepoReader, dest string) ([]config.BuilderVarDefault, error) { +func (l *Languages) ExtractDefaults(lowerLang string, r reporeader.RepoReader) ([]config.BuilderVarDefault, error) { extractors := []reporeader.VariableExtractor{ &defaults.PythonExtractor{}, } @@ -129,7 +129,7 @@ func (l *Languages) ExtractDefaults(lowerLang string, r reporeader.RepoReader, d } for _, extractor := range extractors { if extractor.MatchesLanguage(lowerLang) { - newDefaults, err := extractor.ReadDefaults(r, dest) + newDefaults, err := extractor.ReadDefaults(r) if err != nil { return nil, fmt.Errorf("error reading defaults for language %s: %v", lowerLang, err) } diff --git a/pkg/reporeader/reporeader.go b/pkg/reporeader/reporeader.go index 77190755..9c746e28 100644 --- a/pkg/reporeader/reporeader.go +++ b/pkg/reporeader/reporeader.go @@ -15,7 +15,7 @@ type RepoReader interface { // VariableExtractor is an interface that can be implemented for extracting variables from a repo's files type VariableExtractor interface { - ReadDefaults(r RepoReader, dest string) (map[string]string, error) + ReadDefaults(r RepoReader) (map[string]string, error) MatchesLanguage(lowerlang string) bool GetName() string } From 4114f02e938ff52c7cbfb0bf6dbda3b07fa595d3 Mon Sep 17 00:00:00 2001 From: Suneha Bose Date: Wed, 21 Jun 2023 17:13:51 -0700 Subject: [PATCH 4/9] fixed file path --- pkg/languages/defaults/python.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/pkg/languages/defaults/python.go b/pkg/languages/defaults/python.go index 13f8ba41..12f38b15 100644 --- a/pkg/languages/defaults/python.go +++ b/pkg/languages/defaults/python.go @@ -2,9 +2,11 @@ package defaults import ( "fmt" - "strings" + "path/filepath" + "regexp" "github.com/Azure/draft/pkg/reporeader" + log "github.com/sirupsen/logrus" ) type PythonExtractor struct { @@ -17,14 +19,24 @@ func (p PythonExtractor) ReadDefaults(r reporeader.RepoReader) (map[string]strin if err != nil { return nil, fmt.Errorf("error finding python files: %v", err) } - for index, file := range files { - fileContent, err := r.ReadFile(file) + + entryPointPattern := `if\s*__name__\s*==\s*["']__main__["']` + compiledPattern, err := regexp.Compile(entryPointPattern) + if err != nil { + return nil, fmt.Errorf("error compiling regex pattern: %v", err) + } + + for index, filePath := range files { + fileContent, err := r.ReadFile(filePath) + baseFile := filepath.Base(filePath) + if err != nil { return nil, fmt.Errorf(("error reading python files")) } fileContentInString := string(fileContent) - if strings.Contains(fileContentInString, `if __name__ == '__main__'`) || file == "main.py" || file == "app.py" { - extractedValues["ENTRYPOINT"] = files[index] + + if compiledPattern.MatchString(fileContentInString) || baseFile == "main.py" || baseFile == "app.py" { + extractedValues["ENTRYPOINT"] = filepath.Base(files[index]) break } } From e8f7781f6d041422026e05e84fa1a31f3bc07b47 Mon Sep 17 00:00:00 2001 From: Suneha Bose Date: Wed, 21 Jun 2023 17:34:17 -0700 Subject: [PATCH 5/9] removed unused import --- pkg/languages/defaults/python.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/languages/defaults/python.go b/pkg/languages/defaults/python.go index 12f38b15..a2fcd30d 100644 --- a/pkg/languages/defaults/python.go +++ b/pkg/languages/defaults/python.go @@ -6,7 +6,6 @@ import ( "regexp" "github.com/Azure/draft/pkg/reporeader" - log "github.com/sirupsen/logrus" ) type PythonExtractor struct { From 3fc3ed725e48149603a4ec25b844c80db0be6216 Mon Sep 17 00:00:00 2001 From: Suneha Bose Date: Thu, 22 Jun 2023 12:57:13 -0700 Subject: [PATCH 6/9] updated python.go --- pkg/languages/defaults/python.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/languages/defaults/python.go b/pkg/languages/defaults/python.go index a2fcd30d..d611d5fb 100644 --- a/pkg/languages/defaults/python.go +++ b/pkg/languages/defaults/python.go @@ -25,7 +25,7 @@ func (p PythonExtractor) ReadDefaults(r reporeader.RepoReader) (map[string]strin return nil, fmt.Errorf("error compiling regex pattern: %v", err) } - for index, filePath := range files { + for _, filePath := range files { fileContent, err := r.ReadFile(filePath) baseFile := filepath.Base(filePath) @@ -35,7 +35,7 @@ func (p PythonExtractor) ReadDefaults(r reporeader.RepoReader) (map[string]strin fileContentInString := string(fileContent) if compiledPattern.MatchString(fileContentInString) || baseFile == "main.py" || baseFile == "app.py" { - extractedValues["ENTRYPOINT"] = filepath.Base(files[index]) + extractedValues["ENTRYPOINT"] = baseFile break } } From f74f34567d11b107903b96e20d583797f2284021 Mon Sep 17 00:00:00 2001 From: Suneha Bose Date: Thu, 6 Jul 2023 10:21:42 -0700 Subject: [PATCH 7/9] feedback changes --- cmd/create.go | 21 ++++++++++++++++--- cmd/create_test.go | 28 ++++++++------------------ pkg/languages/defaults/python.go | 6 ++++-- pkg/languages/defaults/python_test.go | 19 +++++++++++++++-- pkg/languages/languages.go | 14 +++---------- template/dockerfiles/python/draft.yaml | 6 ++++++ 6 files changed, 56 insertions(+), 38 deletions(-) diff --git a/cmd/create.go b/cmd/create.go index 53ca7d4f..6bba3a9a 100644 --- a/cmd/create.go +++ b/cmd/create.go @@ -258,12 +258,27 @@ func (cc *createCmd) generateDockerfile(langConfig *config.DraftConfig, lowerLan } // Extract language-specific defaults from repo - extractedDefaults, err := cc.supportedLangs.ExtractDefaults(lowerLang, cc.repoReader) + extractedValues, err := cc.supportedLangs.ExtractDefaults(lowerLang, cc.repoReader) if err != nil { return err } - for _, d := range extractedDefaults { - langConfig.VariableDefaults = append(langConfig.VariableDefaults, d) + + // Check for existing duplicate defualts + for k, v := range extractedValues { + variableExists := false + for i, varD := range langConfig.VariableDefaults { + if k == varD.Name { + variableExists = true + langConfig.VariableDefaults[i].Value = v + break + } + } + if !variableExists { + langConfig.VariableDefaults = append(langConfig.VariableDefaults, config.BuilderVarDefault{ + Name: k, + Value: v, + }) + } } var inputs map[string]string diff --git a/cmd/create_test.go b/cmd/create_test.go index 7d05e409..45343ca1 100644 --- a/cmd/create_test.go +++ b/cmd/create_test.go @@ -21,18 +21,9 @@ import ( ) func TestRun(t *testing.T) { - mockCC := &createCmd{} - mockCC.createConfig = &CreateConfig{} - mockCC.dest = "./.." - mockCC.createConfig.DeployType = "" - mockCC.createConfig.LanguageVariables = []UserInputs{} - mockCC.createConfig.DeployVariables = []UserInputs{} - mockPortInput := UserInputs{Name: "PORT", Value: "8080"} - mockAppNameInput := UserInputs{Name: "APPNAME", Value: "testingCreateCommand"} - mockCC.createConfig.DeployVariables = append(mockCC.createConfig.DeployVariables, mockPortInput, mockAppNameInput) - mockCC.createConfig.LanguageVariables = append(mockCC.createConfig.LanguageVariables, mockPortInput) - mockCC.templateWriter = &writers.LocalFSWriter{} + testCreateConfig := CreateConfig{LanguageVariables: []UserInputs{{Name: "PORT", Value: "8080"}}, DeployVariables: []UserInputs{{Name: "PORT", Value: "8080"}, {Name: "APPNAME", Value: "testingCreateCommand"}}} flagVariablesMap = map[string]string{"PORT": "8080", "APPNAME": "testingCreateCommand", "VERSION": "1.18", "SERVICEPORT": "8080", "NAMESPACE": "testNamespace", "IMAGENAME": "testImage", "IMAGETAG": "latest"} + mockCC := createCmd{dest: "./..", createConfig: &testCreateConfig, templateWriter: &writers.LocalFSWriter{}} deployTypes := []string{"helm", "kustomize", "manifests"} oldDockerfile, _ := ioutil.ReadFile("./../Dockerfile") oldDockerignore, _ := ioutil.ReadFile("./../.dockerignore") @@ -106,17 +97,14 @@ func TestRun(t *testing.T) { } func TestRunCreateDockerfileWithRepoReader(t *testing.T) { - mockCC := &createCmd{} - mockCC.repoReader = &reporeader.TestRepoReader{Files: map[string][]byte{ + + testRepoReader := &reporeader.TestRepoReader{Files: map[string][]byte{ "foo.py": []byte("print('Hello World')"), "main.py": []byte("print('Hello World')"), }} - mockCC.createConfig = &CreateConfig{} - mockCC.createConfig.LanguageType = "python" - mockCC.createConfig.LanguageVariables = []UserInputs{} - mockPortInput := UserInputs{Name: "PORT", Value: "8080"} - mockCC.createConfig.LanguageVariables = append(mockCC.createConfig.LanguageVariables, mockPortInput) - mockCC.templateWriter = &writers.LocalFSWriter{} + + testCreateConfig := CreateConfig{LanguageType: "python", LanguageVariables: []UserInputs{{Name: "PORT", Value: "8080"}}} + mockCC := createCmd{createConfig: &testCreateConfig, repoReader: testRepoReader, templateWriter: &writers.LocalFSWriter{}} detectedLang, lowerLang, err := mockCC.mockDetectLanguage() assert.False(t, detectedLang == nil) @@ -136,7 +124,7 @@ func TestRunCreateDockerfileWithRepoReader(t *testing.T) { if err != nil { t.Error(err) } - os.RemoveAll(".dockerignore") + err = os.RemoveAll(".dockerignore") if err != nil { t.Error(err) } diff --git a/pkg/languages/defaults/python.go b/pkg/languages/defaults/python.go index d611d5fb..45fbe64d 100644 --- a/pkg/languages/defaults/python.go +++ b/pkg/languages/defaults/python.go @@ -14,11 +14,12 @@ type PythonExtractor struct { // ReadDefaults reads the default values for the language from the repo files func (p PythonExtractor) ReadDefaults(r reporeader.RepoReader) (map[string]string, error) { extractedValues := make(map[string]string) + // Find files with .py extension in the root of the repository or upto depth 0 files, err := r.FindFiles(".", []string{"*.py"}, 0) if err != nil { return nil, fmt.Errorf("error finding python files: %v", err) } - + // Regex for python entrypoint pattern `if __name__ == '__main__'` entryPointPattern := `if\s*__name__\s*==\s*["']__main__["']` compiledPattern, err := regexp.Compile(entryPointPattern) if err != nil { @@ -33,13 +34,14 @@ func (p PythonExtractor) ReadDefaults(r reporeader.RepoReader) (map[string]strin return nil, fmt.Errorf(("error reading python files")) } fileContentInString := string(fileContent) - + // Check if file contains python entrypoint pattern or name of the file is 'main.py' or 'app.py' if compiledPattern.MatchString(fileContentInString) || baseFile == "main.py" || baseFile == "app.py" { extractedValues["ENTRYPOINT"] = baseFile break } } + // Set entrypoint to the first .py file if other conditions do not match if _, ok := extractedValues["ENTRYPOINT"]; !ok { if len(files) > 0 { extractedValues["ENTRYPOINT"] = files[0] diff --git a/pkg/languages/defaults/python_test.go b/pkg/languages/defaults/python_test.go index 13518ecd..99fd70a9 100644 --- a/pkg/languages/defaults/python_test.go +++ b/pkg/languages/defaults/python_test.go @@ -67,12 +67,27 @@ func TestPythonExtractor_ReadDefaults(t *testing.T) { wantErr: false, }, { - name: "extract python file containing the string \"__name__=='__main__'\" as the entrypoint", + name: "extract python file containing the string \"if __name__ == '__main__'\" as the entrypoint", args: args{ r: reporeader.TestRepoReader{ Files: map[string][]byte{ "foo.py": []byte("print('hello world')"), - "bar.py": []byte("if __name__ == '__main__': print('hello world')"), + "bar.py": []byte("if __name__ == '__main__' : print('hello world')"), + }, + }, + }, + want: map[string]string{ + "ENTRYPOINT": "bar.py", + }, + wantErr: false, + }, + { + name: "extract python file containing the string \"if __name__==\"__main__\"\" as the entrypoint", + args: args{ + r: reporeader.TestRepoReader{ + Files: map[string][]byte{ + "foo.py": []byte("print('hello world')"), + "bar.py": []byte("if __name__==\"__main__\": print('hello world')"), }, }, }, diff --git a/pkg/languages/languages.go b/pkg/languages/languages.go index c57b9e02..41dcdf1b 100644 --- a/pkg/languages/languages.go +++ b/pkg/languages/languages.go @@ -117,15 +117,14 @@ func CreateLanguagesFromEmbedFS(dockerfileTemplates embed.FS, dest string) *Lang return l } -func (l *Languages) ExtractDefaults(lowerLang string, r reporeader.RepoReader) ([]config.BuilderVarDefault, error) { +func (l *Languages) ExtractDefaults(lowerLang string, r reporeader.RepoReader) (map[string]string, error) { extractors := []reporeader.VariableExtractor{ &defaults.PythonExtractor{}, } extractedValues := make(map[string]string) - var extractedDefaults []config.BuilderVarDefault if r == nil { log.Debugf("no repo reader provided, returning empty list of defaults") - return extractedDefaults, nil + return extractedValues, nil } for _, extractor := range extractors { if extractor.MatchesLanguage(lowerLang) { @@ -143,12 +142,5 @@ func (l *Languages) ExtractDefaults(lowerLang string, r reporeader.RepoReader) ( } } - for k, v := range extractedValues { - extractedDefaults = append(extractedDefaults, config.BuilderVarDefault{ - Name: k, - Value: v, - }) - } - - return extractedDefaults, nil + return extractedValues, nil } diff --git a/template/dockerfiles/python/draft.yaml b/template/dockerfiles/python/draft.yaml index 831d9b95..7d361ed1 100644 --- a/template/dockerfiles/python/draft.yaml +++ b/template/dockerfiles/python/draft.yaml @@ -10,8 +10,14 @@ variables: - name: "VERSION" description: "the version of python used by the application" exampleValues: ["3.9", "3.8", "3.7", "3.6"] + - name: "ENTRYPOINT" + description: "the entrypoint file of the repository" + type: string + exampleValues: ["app.py", "main.py"] variableDefaults: - name: "VERSION" value: "3" - name: "PORT" value: "80" + - name: "ENTRYPOINT" + value: "app.py" From 9ba9a281b9bc04cc512d19bd04997f6f2ebe35a6 Mon Sep 17 00:00:00 2001 From: Suneha Bose Date: Thu, 6 Jul 2023 12:24:17 -0700 Subject: [PATCH 8/9] changes for python entrypoint --- test/gen_integration.sh | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/test/gen_integration.sh b/test/gen_integration.sh index 7868ac6e..07665d70 100755 --- a/test/gen_integration.sh +++ b/test/gen_integration.sh @@ -109,6 +109,7 @@ do # addon integration testing vars ingress_test_args="-a webapp_routing --variable ingress-tls-cert-keyvault-uri=test.cert.keyvault.uri --variable ingress-use-osm-mtls=true --variable ingress-host=host1" create_config_args="--variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest" + python_create_config_args="--variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest --variable ENTRYPOINT=testapp.py" echo "Adding $lang with port $port" mkdir ./integration/$lang @@ -204,12 +205,19 @@ languageVariables: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag - run: | + - name: Execute Dry Run with variables passed through flag + $(if [ "$lang" = "python" ] + then echo "run: | + mkdir -p test/temp + ./draft --dry-run --dry-run-file test/temp/dry-run.json \ + create -d ./langtest/ -l $lang --skip-file-detection --deploy-type helm \ + $python_create_config_args" + else echo "run: | mkdir -p test/temp ./draft --dry-run --dry-run-file test/temp/dry-run.json \ create -d ./langtest/ -l $lang --skip-file-detection --deploy-type helm \ - $create_config_args + $create_config_args" + fi) - name: Validate JSON run: | npm install -g ajv-cli@5.0.0 @@ -355,11 +363,18 @@ languageVariables: npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - name: Execute Dry Run with variables passed through flag - run: | + $(if [ "$lang" = "python" ]; + then echo "run: | + mkdir -p test/temp + ./draft --dry-run --dry-run-file test/temp/dry-run.json \ + create -d ./langtest/ -l $lang --skip-file-detection --deploy-type kustomize \ + $python_create_config_args"; + else echo "run: | mkdir -p test/temp ./draft --dry-run --dry-run-file test/temp/dry-run.json \ create -d ./langtest/ -l $lang --skip-file-detection --deploy-type kustomize \ - $create_config_args + $create_config_args"; + fi) - name: Validate JSON run: | npm install -g ajv-cli@5.0.0 @@ -495,12 +510,19 @@ languageVariables: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag - run: | + - name: Execute Dry Run with variables passed through flag + $(if [ "$lang" = "python" ]; + then echo "run: | + mkdir -p test/temp + ./draft --dry-run --dry-run-file test/temp/dry-run.json \ + create -d ./langtest/ -l $lang --skip-file-detection --deploy-type manifests \ + $python_create_config_args"; + else echo "run: | mkdir -p test/temp ./draft --dry-run --dry-run-file test/temp/dry-run.json \ create -d ./langtest/ -l $lang --skip-file-detection --deploy-type manifests \ - $create_config_args + $create_config_args"; + fi) - name: Validate JSON run: | npm install -g ajv-cli@5.0.0 From f64a37b02eee87d32af0375651efb691ff86714a Mon Sep 17 00:00:00 2001 From: Suneha Bose Date: Thu, 6 Jul 2023 12:34:22 -0700 Subject: [PATCH 9/9] intg test changes for python entrypoint variable --- .github/workflows/integration-linux.yml | 76 ++++++++++++------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/.github/workflows/integration-linux.yml b/.github/workflows/integration-linux.yml index a66b797e..643f1c83 100644 --- a/.github/workflows/integration-linux.yml +++ b/.github/workflows/integration-linux.yml @@ -48,7 +48,7 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l gomodule --skip-file-detection --deploy-type helm --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest @@ -321,10 +321,10 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp - ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l gomodule --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest + ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l gomodule --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest - name: Validate JSON run: | npm install -g ajv-cli@5.0.0 @@ -486,7 +486,7 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l go --skip-file-detection --deploy-type helm --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest @@ -759,10 +759,10 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp - ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l go --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest + ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l go --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest - name: Validate JSON run: | npm install -g ajv-cli@5.0.0 @@ -924,10 +924,10 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp - ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l python --skip-file-detection --deploy-type helm --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest + ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l python --skip-file-detection --deploy-type helm --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest --variable ENTRYPOINT=testapp.py - name: Validate JSON run: | npm install -g ajv-cli@5.0.0 @@ -1068,7 +1068,7 @@ jobs: - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp - ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l python --skip-file-detection --deploy-type kustomize --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest + ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l python --skip-file-detection --deploy-type kustomize --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest --variable ENTRYPOINT=testapp.py - name: Validate JSON run: | npm install -g ajv-cli@5.0.0 @@ -1197,10 +1197,10 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp - ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l python --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest + ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l python --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest --variable ENTRYPOINT=testapp.py - name: Validate JSON run: | npm install -g ajv-cli@5.0.0 @@ -1362,7 +1362,7 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l rust --skip-file-detection --deploy-type helm --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest @@ -1635,10 +1635,10 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp - ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l rust --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest + ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l rust --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest - name: Validate JSON run: | npm install -g ajv-cli@5.0.0 @@ -1800,7 +1800,7 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l javascript --skip-file-detection --deploy-type helm --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest @@ -2073,10 +2073,10 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp - ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l javascript --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest + ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l javascript --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest - name: Validate JSON run: | npm install -g ajv-cli@5.0.0 @@ -2238,7 +2238,7 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l ruby --skip-file-detection --deploy-type helm --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest @@ -2511,10 +2511,10 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp - ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l ruby --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest + ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l ruby --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest - name: Validate JSON run: | npm install -g ajv-cli@5.0.0 @@ -2676,7 +2676,7 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l csharp --skip-file-detection --deploy-type helm --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest @@ -2949,10 +2949,10 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp - ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l csharp --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest + ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l csharp --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest - name: Validate JSON run: | npm install -g ajv-cli@5.0.0 @@ -3114,7 +3114,7 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l java --skip-file-detection --deploy-type helm --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest @@ -3387,10 +3387,10 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp - ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l java --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest + ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l java --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest - name: Validate JSON run: | npm install -g ajv-cli@5.0.0 @@ -3552,7 +3552,7 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l gradle --skip-file-detection --deploy-type helm --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest @@ -3825,10 +3825,10 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp - ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l gradle --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest + ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l gradle --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest - name: Validate JSON run: | npm install -g ajv-cli@5.0.0 @@ -3990,7 +3990,7 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l swift --skip-file-detection --deploy-type helm --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest @@ -4263,10 +4263,10 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp - ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l swift --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest + ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l swift --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest - name: Validate JSON run: | npm install -g ajv-cli@5.0.0 @@ -4428,7 +4428,7 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l erlang --skip-file-detection --deploy-type helm --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest @@ -4701,10 +4701,10 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp - ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l erlang --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest + ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l erlang --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest - name: Validate JSON run: | npm install -g ajv-cli@5.0.0 @@ -4866,7 +4866,7 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l clojure --skip-file-detection --deploy-type helm --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest @@ -5139,10 +5139,10 @@ jobs: run: | npm install -g ajv-cli@5.0.0 ajv validate -s test/dry_run_schema.json -d test/temp/dry-run.json - - name: Execute Dry Run with variables passed through flag + - name: Execute Dry Run with variables passed through flag run: | mkdir -p test/temp - ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l clojure --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest + ./draft --dry-run --dry-run-file test/temp/dry-run.json create -d ./langtest/ -l clojure --skip-file-detection --deploy-type manifests --variable PORT=8080 --variable APPNAME=testingCreateCommand --variable VERSION=1.11 --variable BUILDERVERSION=1.11 --variable SERVICEPORT=8080 --variable NAMESPACE=testNamespace --variable IMAGENAME=testImage --variable IMAGETAG=latest - name: Validate JSON run: | npm install -g ajv-cli@5.0.0