-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: support async preview * feat: support async executions, max concurrent async count, max buffer zones, sets logs and results
- Loading branch information
Showing
41 changed files
with
1,867 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
package constant | ||
|
||
import "time" | ||
|
||
// These constants represent the possible states of a stack. | ||
const ( | ||
DefaultUser = "test.user" | ||
DefaultWorkspace = "default" | ||
DefaultBackend = "default" | ||
DefaultOrgOwner = "kusion" | ||
DefaultSourceType = SourceProviderTypeGit | ||
DefaultSourceDesc = "Default source" | ||
DefaultSystemName = "kusion" | ||
MaxConcurrent = 10 | ||
DefaultLogFilePath = "/home/admin/logs/kusion.log" | ||
DefaultUser = "test.user" | ||
DefaultWorkspace = "default" | ||
DefaultBackend = "default" | ||
DefaultOrgOwner = "kusion" | ||
DefaultSourceType = SourceProviderTypeGit | ||
DefaultSourceDesc = "Default source" | ||
DefaultSystemName = "kusion" | ||
DefaultReleaseNamespace = "server" | ||
MaxConcurrent = 10 | ||
MaxAsyncConcurrent = 1 | ||
MaxAsyncBuffer = 100 | ||
DefaultLogFilePath = "/home/admin/logs/kusion.log" | ||
RepoCacheTTL = 60 * time.Minute | ||
RunTimeOut = 60 * time.Minute | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package constant | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
type ( | ||
RunType string | ||
RunStatus string | ||
) | ||
|
||
const ( | ||
RunTypeGenerate RunType = "Generate" | ||
RunTypePreview RunType = "Preview" | ||
RunTypeApply RunType = "Apply" | ||
RunTypeDestroy RunType = "Destroy" | ||
RunStatusScheduling RunStatus = "Scheduling" | ||
RunStatusInProgress RunStatus = "InProgress" | ||
RunStatusFailed RunStatus = "Failed" | ||
RunStatusSucceeded RunStatus = "Succeeded" | ||
RunStatusCancelled RunStatus = "Cancelled" | ||
RunStatusQueued RunStatus = "Queued" | ||
) | ||
|
||
// ParseRunType parses a string into a RunType. | ||
// If the string is not a valid RunType, it returns an error. | ||
func ParseRunType(s string) (RunType, error) { | ||
switch s { | ||
case string(RunTypeGenerate): | ||
return RunTypeGenerate, nil | ||
case string(RunTypePreview): | ||
return RunTypePreview, nil | ||
case string(RunTypeApply): | ||
return RunTypeApply, nil | ||
case string(RunTypeDestroy): | ||
return RunTypeDestroy, nil | ||
default: | ||
return RunType(""), fmt.Errorf("invalid RunType: %q", s) | ||
} | ||
} | ||
|
||
// ParseRunStatus parses a string into a RunStatus. | ||
// If the string is not a valid RunStatus, it returns an error. | ||
func ParseRunStatus(s string) (RunStatus, error) { | ||
switch s { | ||
case string(RunStatusScheduling): | ||
return RunStatusScheduling, nil | ||
case string(RunStatusInProgress): | ||
return RunStatusInProgress, nil | ||
case string(RunStatusFailed): | ||
return RunStatusFailed, nil | ||
case string(RunStatusSucceeded): | ||
return RunStatusSucceeded, nil | ||
case string(RunStatusCancelled): | ||
return RunStatusCancelled, nil | ||
case string(RunStatusQueued): | ||
return RunStatusQueued, nil | ||
default: | ||
return RunStatus(""), fmt.Errorf("invalid RunType: %q", s) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package entity | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"kusionstack.io/kusion/pkg/domain/constant" | ||
) | ||
|
||
// Run represents the specific run, including type | ||
// which should be a specific instance of the run provider. | ||
type Run struct { | ||
// ID is the id of the run. | ||
ID uint `yaml:"id" json:"id"` | ||
// RunType is the type of the run provider. | ||
Type constant.RunType `yaml:"type" json:"type"` | ||
// Stack is the stack of the run. | ||
Stack *Stack `yaml:"stack" json:"stack"` | ||
// Workspace is the target workspace of the run. | ||
Workspace string `yaml:"workspace" json:"workspace"` | ||
// Status is the status of the run. | ||
Status constant.RunStatus `yaml:"status" json:"status"` | ||
// Result is the result of the run. | ||
Result string `yaml:"result" json:"result"` | ||
// Result RunResult `yaml:"result" json:"result"` | ||
// Logs is the logs of the run. | ||
Logs string `yaml:"logs" json:"logs"` | ||
// CreationTimestamp is the timestamp of the created for the run. | ||
CreationTimestamp time.Time `yaml:"creationTimestamp,omitempty" json:"creationTimestamp,omitempty"` | ||
// UpdateTimestamp is the timestamp of the updated for the run. | ||
UpdateTimestamp time.Time `yaml:"updateTimestamp,omitempty" json:"updateTimestamp,omitempty"` | ||
} | ||
|
||
// RunResult represents the result of the run. | ||
type RunResult struct { | ||
// ExitCode is the exit code of the run. | ||
ExitCode int `yaml:"exitCode" json:"exitCode"` | ||
// Message is the message of the run. | ||
Message string `yaml:"message" json:"message"` | ||
// Old is the old state of the run. | ||
Old string `yaml:"old" json:"old"` | ||
// New is the new state of the run. | ||
New string `yaml:"new" json:"new"` | ||
} | ||
|
||
type RunFilter struct { | ||
ProjectID uint | ||
StackID uint | ||
Workspace string | ||
} | ||
|
||
// Validate checks if the run is valid. | ||
// It returns an error if the run is not valid. | ||
func (r *Run) Validate() error { | ||
if r == nil { | ||
return fmt.Errorf("run is nil") | ||
} | ||
|
||
if r.Type == "" { | ||
return fmt.Errorf("run must have a run type") | ||
} | ||
|
||
if r.Workspace == "" { | ||
return fmt.Errorf("run must have a target workspace") | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (r *Run) Summary() string { | ||
return fmt.Sprintf("[%s][%s]", string(r.Type), string(r.Status)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.