Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN mkdir -p $GOPATH/src $GOPATH/bin && chmod -R 777 $GOPATH
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH

# Download Go.
ARG GO_VERSION=1.18
ARG GO_VERSION=1.19
ARG TARGETARCH
ARG TARGETOS
ENV TARGETARCH_ENV=${TARGETARCH:-amd64}
Expand Down
20 changes: 20 additions & 0 deletions assets/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,26 @@
"schema": {
"type": "boolean"
}
},
{
"name": "disable-qa-category",
"in": "query",
"description": "String to disable QA categories. (comma-separated values)",
"required": false,
"example": "transformers,network",
"schema": {
"type": "string"
}
},
{
"name": "enable-qa-category",
"in": "query",
"description": "String to enable QA categories. (comma-separated values)",
"required": false,
"example": "imageregistry,cicd",
"schema": {
"type": "string"
}
}
],
"requestBody": {
Expand Down
36 changes: 26 additions & 10 deletions internal/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -1515,18 +1515,19 @@ func (fs *FileSystem) deletePlan(t *bolt.Tx, workspaceId, projectId string) erro
}

// ResumeTransformation resumes a transformation that did not finish
func (fs *FileSystem) ResumeTransformation(workspaceId, projectId, projOutputId string, debugMode, skipQA bool) error {
func (fs *FileSystem) ResumeTransformation(workspaceId, projectId, projOutputId string, debugMode, skipQA bool, enableQACategories, disableQACategories []string) error {
db, err := fs.GetDatabase(false)
if err != nil {
return err
}

defer db.Close()
return db.Update(func(t *bolt.Tx) error {
return fs.resumeTransformation(t, workspaceId, projectId, projOutputId, debugMode, skipQA)
return fs.resumeTransformation(t, workspaceId, projectId, projOutputId, debugMode, skipQA, enableQACategories, disableQACategories)
})
}

func (fs *FileSystem) resumeTransformation(t *bolt.Tx, workspaceId, projectId, projOutputId string, debugMode, skipQA bool) error {
func (fs *FileSystem) resumeTransformation(t *bolt.Tx, workspaceId, projectId, projOutputId string, debugMode, skipQA bool, enableQACategories, disableQACategories []string) error {
// check conditions
project, err := fs.readProject(t, workspaceId, projectId)
if err != nil {
Expand Down Expand Up @@ -1617,23 +1618,23 @@ func (fs *FileSystem) resumeTransformation(t *bolt.Tx, workspaceId, projectId, p
currentRunConfigPaths = append(commonConfigPaths, currentRunConfigPaths...)
}
// resume the transformation
go fs.runTransform(currentRunDir, currentRunConfigPaths, currentRunSrcDir, currentRunCustDir, currentRunOutDir, message, qaServerMeta.Port, transformCh, workspaceId, projectId, projOutput, debugMode, skipQA, true)
go fs.runTransform(currentRunDir, currentRunConfigPaths, currentRunSrcDir, currentRunCustDir, currentRunOutDir, message, qaServerMeta.Port, transformCh, workspaceId, projectId, projOutput, debugMode, skipQA, true, enableQACategories, disableQACategories)
return nil
}

// StartTransformation starts the transformation for a project.
func (fs *FileSystem) StartTransformation(workspaceId, projectId string, projOutput types.ProjectOutput, plan io.Reader, debugMode, skipQA bool) error {
func (fs *FileSystem) StartTransformation(workspaceId, projectId string, projOutput types.ProjectOutput, plan io.Reader, debugMode, skipQA bool, enableQACategories, disableQACategories []string) error {
db, err := fs.GetDatabase(false)
if err != nil {
return err
}
defer db.Close()
return db.Update(func(t *bolt.Tx) error {
return fs.startTransformation(t, workspaceId, projectId, projOutput, plan, debugMode, skipQA)
return fs.startTransformation(t, workspaceId, projectId, projOutput, plan, debugMode, skipQA, enableQACategories, disableQACategories)
})
}

func (fs *FileSystem) startTransformation(t *bolt.Tx, workspaceId, projectId string, projOutput types.ProjectOutput, plan io.Reader, debugMode, skipQA bool) error {
func (fs *FileSystem) startTransformation(t *bolt.Tx, workspaceId, projectId string, projOutput types.ProjectOutput, plan io.Reader, debugMode, skipQA bool, enableQACategories, disableQACategories []string) error {
// check conditions
project, err := fs.readProject(t, workspaceId, projectId)
if err != nil {
Expand Down Expand Up @@ -1811,7 +1812,7 @@ func (fs *FileSystem) startTransformation(t *bolt.Tx, workspaceId, projectId str
currentRunConfigPaths = append(commonConfigPaths, currentRunConfigPaths...)
}
// start the transformation
go fs.runTransform(currentRunDir, currentRunConfigPaths, currentRunSrcDir, currentRunCustDir, currentRunOutDir, message, qaServerMeta.Port, transformCh, workspaceId, projectId, projOutput, debugMode, skipQA, false)
go fs.runTransform(currentRunDir, currentRunConfigPaths, currentRunSrcDir, currentRunCustDir, currentRunOutDir, message, qaServerMeta.Port, transformCh, workspaceId, projectId, projOutput, debugMode, skipQA, false, enableQACategories, disableQACategories)
logrus.Infof("Waiting for QA engine to start for the output '%s' of the project '%s'", projOutput.Id, projectId)
if err := <-transformCh; err != nil {
return fmt.Errorf("failed to start the transformation and qa engine. Error: %w", err)
Expand Down Expand Up @@ -2156,7 +2157,7 @@ func NewFileSystem() (*FileSystem, error) {
}
for _, project := range projects {
for _, projOutput := range project.Outputs {
if err := fileSystem.ResumeTransformation(workspace.Id, project.Id, projOutput.Id, false, false); err != nil {
if err := fileSystem.ResumeTransformation(workspace.Id, project.Id, projOutput.Id, false, false, []string{}, []string{}); err != nil {
logrus.Debugf("failed to resume the transformation for output with id: %s of project id: %s . Error: %q", projOutput.Id, project.Id, err)
}
}
Expand Down Expand Up @@ -2375,7 +2376,7 @@ func (fs *FileSystem) runPlan(currentRunDir string, currentRunConfigPaths []stri
return err
}

func (fs *FileSystem) runTransform(currentRunDir string, currentRunConfigPaths []string, currentRunSrcDir, currentRunCustDir, currentRunOutDir, message string, port int, transformCh chan error, workspaceId, projectId string, projOutput types.ProjectOutput, debugMode bool, skipQA bool, overwriteOutDir bool) error {
func (fs *FileSystem) runTransform(currentRunDir string, currentRunConfigPaths []string, currentRunSrcDir, currentRunCustDir, currentRunOutDir, message string, port int, transformCh chan error, workspaceId, projectId string, projOutput types.ProjectOutput, debugMode bool, skipQA bool, overwriteOutDir bool, enableQACategories, disableQACategories []string) error {
logrus.Infof("Starting transformation in %s with configs from %+v and source from %s , customizations from %s and output to %s", currentRunDir, currentRunConfigPaths, currentRunSrcDir, currentRunCustDir, currentRunOutDir)
portStr, err := cast.ToStringE(port)
if err != nil {
Expand All @@ -2395,6 +2396,21 @@ func (fs *FileSystem) runTransform(currentRunDir string, currentRunConfigPaths [
if skipQA {
cmdArgs = append(cmdArgs, "--qa-skip")
}
if len(enableQACategories) > 0 && len(disableQACategories) > 0 {
logrus.Errorf("--qa-enable and --qa-disable cannot be used together.Proceeding with only --qa-disable flag\n")
enableQACategories = []string{}
}
if len(disableQACategories) > 0 {
for _, disableQACategory := range disableQACategories {
cmdArgs = append(cmdArgs, "--qa-disable", disableQACategory)
}
logrus.Infof("disable QA Categories: %v", disableQACategories)
} else if len(enableQACategories) > 0 {
for _, enableQACategory := range enableQACategories {
cmdArgs = append(cmdArgs, "--qa-enable", enableQACategory)
}
logrus.Infof("enable QA Categories: %v", enableQACategories)
}
if !common.Config.EnableLocalExecution {
cmdArgs = append(cmdArgs, "--disable-local-execution")
}
Expand Down
4 changes: 2 additions & 2 deletions internal/filesystem/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ type IFileSystem interface {
ReadPlan(workspaceId, projectId string) (plan io.Reader, err error)
UpdatePlan(workspaceId, projectId string, plan io.Reader) error
DeletePlan(workspaceId, projectId string) error
StartTransformation(workspaceId, projectId string, projOutput types.ProjectOutput, plan io.Reader, debugMode, skipQA bool) error
ResumeTransformation(workspaceId, projectId, projOutputId string, debugMode, skipQA bool) error
StartTransformation(workspaceId, projectId string, projOutput types.ProjectOutput, plan io.Reader, debugMode, skipQA bool, enableQACategories, disableQACategories []string) error
ResumeTransformation(workspaceId, projectId, projOutputId string, debugMode, skipQA bool, enableQACategories, disableQACategories []string) error
ReadProjectOutput(workspaceId, projectId, projOutputId string) (projOutput types.ProjectOutput, file io.Reader, err error)
ReadProjectOutputGraph(workspaceId, projectId, projOutputId string) (projOutput types.ProjectOutput, file io.Reader, err error)
DeleteProjectOutput(workspaceId, projectId, projOutputId string) error
Expand Down
4 changes: 4 additions & 0 deletions internal/move2kubeapi/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import (
const (
// SKIP_QA_QUERY_PARAM is the name of the query parameter used for skipping QA
SKIP_QA_QUERY_PARAM = "skip-qa"
// DISABLE_QA_CATEGORY is the name of the query parameter used for disabling QA category
DISABLE_QA_CATEGORY = "disable-qa-category"
// ENABLE_QA_CATEGORY is the name of the query parameter used for enabling QA category
ENABLE_QA_CATEGORY = "enable-qa-category"
// REMOTE_SOURCE_QUERY_PARAM is the URL of the git remote to be used as source
REMOTE_SOURCE_QUERY_PARAM = "remote-source"
// DEBUG_QUERY_PARAM is the name of the query parameter used for debug mode
Expand Down
16 changes: 15 additions & 1 deletion internal/move2kubeapi/handlers/outputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,22 @@ func HandleStartTransformation(w http.ResponseWriter, r *http.Request) {
// empty body
planReader = nil
}

debugMode := r.URL.Query().Get(DEBUG_QUERY_PARAM) == "true"
skipQA := r.URL.Query().Get(SKIP_QA_QUERY_PARAM) == "true"
var enableQACategories []string
var disableQACategories []string
if val, ok := r.URL.Query()[DISABLE_QA_CATEGORY]; ok {
disableQACategories = val
}
if val, ok := r.URL.Query()[ENABLE_QA_CATEGORY]; ok {
enableQACategories = val
}
// qa-disable and qa-enable flags are mutually exclusive
if len(enableQACategories) > 0 && len(disableQACategories) > 0 {
logrus.Errorf("--qa-enable and --qa-disable cannot be used together.Proceeding with only --qa-disable flag\n")
enableQACategories = []string{}
}
timestamp, _, err := common.GetTimestamp()
if err != nil {
logrus.Errorf("failed to get the timestamp. Error: %q", err)
Expand All @@ -66,7 +80,7 @@ func HandleStartTransformation(w http.ResponseWriter, r *http.Request) {
projOutput.Timestamp = timestamp
projOutput.Name = projOutput.Id // This isn't really used anywhere
projOutput.Status = types.ProjectOutputStatusInProgress
if err := m2kFS.StartTransformation(workspaceId, projectId, projOutput, planReader, debugMode, skipQA); err != nil {
if err := m2kFS.StartTransformation(workspaceId, projectId, projOutput, planReader, debugMode, skipQA, enableQACategories, disableQACategories); err != nil {
logrus.Errorf("failed to start the transformation. Error: %q", err)
if notExErr, ok := err.(types.ErrorDoesNotExist); ok {
if notExErr.Id == "plan" {
Expand Down