Skip to content

Commit 192e179

Browse files
committed
feat(exp-engine): experimental deploy engine v2 with graph
Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
1 parent 73f6cc2 commit 192e179

File tree

10 files changed

+353
-817
lines changed

10 files changed

+353
-817
lines changed

cmd/werf/common/cmd_data.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ type CmdData struct {
6464
Synchronization *string
6565
Parallel *bool
6666
ParallelTasksLimit *int64
67+
NetworkParallelism *int
6768

6869
DockerConfig *string
6970
InsecureRegistry *bool
@@ -103,6 +104,8 @@ type CmdData struct {
103104
UseDeployReport *bool
104105
DeployReportPath *string
105106

107+
DeployGraphPath *string
108+
106109
VirtualMerge *bool
107110

108111
ScanContextNamespaceOnly *bool

cmd/werf/common/common.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,55 @@ func GetUseDeployReport(cmdData *CmdData) bool {
290290
return *cmdData.UseDeployReport
291291
}
292292

293+
func SetupNetworkParallelism(cmdData *CmdData, cmd *cobra.Command) {
294+
cmdData.NetworkParallelism = new(int)
295+
296+
fallbackVal := 30
297+
298+
var defVal int
299+
if val, err := util.GetIntEnvVar("WERF_NETWORK_PARALLELISM"); err != nil {
300+
TerminateWithError(fmt.Sprintf("bad WERF_NETWORK_PARALLELISM value: %s", err), 1)
301+
} else if val != nil {
302+
defVal = int(*val)
303+
} else {
304+
defVal = fallbackVal
305+
}
306+
307+
cmd.Flags().IntVarP(
308+
cmdData.NetworkParallelism,
309+
"network-parallelism",
310+
"",
311+
defVal,
312+
fmt.Sprintf("Parallelize some network operations (default $WERF_NETWORK_PARALLELISM or %d)", fallbackVal),
313+
)
314+
}
315+
316+
func GetNetworkParallelism(cmdData *CmdData) int {
317+
if *cmdData.NetworkParallelism < 1 {
318+
TerminateWithError(fmt.Sprintf("bad network parallelism value: %d (should be >= 1)", *cmdData.NetworkParallelism), 1)
319+
}
320+
321+
return *cmdData.NetworkParallelism
322+
}
323+
324+
func SetupDeployGraphPath(cmdData *CmdData, cmd *cobra.Command) {
325+
cmdData.DeployGraphPath = new(string)
326+
327+
cmd.Flags().StringVarP(cmdData.DeployGraphPath, "deploy-graph-path", "", os.Getenv("WERF_DEPLOY_GRAPH_PATH"), "Save deploy graph path to the specified file (by default $WERF_DEPLOY_GRAPH_PATH). Extension must be .dot or not specified. If extension not specified, then .dot is used")
328+
}
329+
330+
func GetDeployGraphPath(cmdData *CmdData) string {
331+
switch ext := filepath.Ext(*cmdData.DeployGraphPath); ext {
332+
case ".dot":
333+
return *cmdData.DeployGraphPath
334+
case "":
335+
return *cmdData.DeployGraphPath + ".dot"
336+
default:
337+
TerminateWithError(fmt.Sprintf("invalid --deploy-graph-path %q: extension must be either .dot or unspecified", *cmdData.DeployGraphPath), 1)
338+
return ""
339+
}
340+
}
341+
293342
func SetupWithoutKube(cmdData *CmdData, cmd *cobra.Command) {
294343
cmdData.WithoutKube = new(bool)
295344
cmd.Flags().BoolVarP(cmdData.WithoutKube, "without-kube", "", util.GetBoolEnvironmentDefaultFalse("WERF_WITHOUT_KUBE"), "Do not skip deployed Kubernetes images (default $WERF_WITHOUT_KUBE)")

0 commit comments

Comments
 (0)