-
Notifications
You must be signed in to change notification settings - Fork 270
feat: add source and package status to package state #5007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7f56d9b
657ec39
1e844d1
a1c7dcf
86bf367
0e9344c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,15 +87,29 @@ func ParseServiceKey(s string) (ServiceKey, error) { | |
| return "", fmt.Errorf("invalid service key %q, valid keys are: %v", s, AllServiceKeys()) | ||
| } | ||
|
|
||
| // PackageStatus defines the overall deployment status of a Zarf package. | ||
| type PackageStatus string | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious what you'd think of splitting out the state of the lifecycle with the health of the package. Something like below, this could also apply to components, though we'd want to keep their current status for some time for backward compatibility
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added this in zarf-dev/proposals#27 |
||
|
|
||
| // All the different status options for a Zarf Package | ||
| const ( | ||
| PackageStatusUnknown PackageStatus = "Unknown" | ||
| PackageStatusSucceeded PackageStatus = "Succeeded" | ||
| PackageStatusFailed PackageStatus = "Failed" | ||
| PackageStatusDeploying PackageStatus = "Deploying" | ||
| PackageStatusRemoving PackageStatus = "Removing" | ||
| PackageStatusRemoveFailed PackageStatus = "RemoveFailed" | ||
| ) | ||
|
|
||
| // ComponentStatus defines the deployment status of a Zarf component within a package. | ||
| type ComponentStatus string | ||
|
|
||
| // All the different status options for a Zarf Component | ||
| const ( | ||
| ComponentStatusSucceeded ComponentStatus = "Succeeded" | ||
| ComponentStatusFailed ComponentStatus = "Failed" | ||
| ComponentStatusDeploying ComponentStatus = "Deploying" | ||
| ComponentStatusRemoving ComponentStatus = "Removing" | ||
| ComponentStatusSucceeded ComponentStatus = "Succeeded" | ||
| ComponentStatusFailed ComponentStatus = "Failed" | ||
| ComponentStatusDeploying ComponentStatus = "Deploying" | ||
| ComponentStatusRemoving ComponentStatus = "Removing" | ||
| ComponentStatusRemoveFailed ComponentStatus = "RemoveFailed" | ||
| ) | ||
|
|
||
| // IPFamily defines the different possible IPfamilies that can be used in Kubernetes clusters | ||
|
|
@@ -627,6 +641,20 @@ func WithPackageConnectivity(connected bool) DeployedPackageOptions { | |
| } | ||
| } | ||
|
|
||
| // WithPackageSource records the source string (e.g. oci:// URL or tarball path) used to deploy the package. | ||
| func WithPackageSource(source string) DeployedPackageOptions { | ||
| return func(o *DeployedPackage) { | ||
| o.Source = source | ||
| } | ||
| } | ||
|
|
||
| // WithPackageStatus sets the overall deployment status of the package. | ||
| func WithPackageStatus(status PackageStatus) DeployedPackageOptions { | ||
| return func(o *DeployedPackage) { | ||
| o.Status = status | ||
| } | ||
| } | ||
|
|
||
| // PackageConnectivity defines the connectivity mode of package deployments | ||
| type PackageConnectivity string | ||
|
|
||
|
|
@@ -640,8 +668,11 @@ const ( | |
| // DeployedPackage contains information about a Zarf Package that has been deployed to a cluster | ||
| // This object is saved as the data of a k8s secret within the 'Zarf' namespace (not as part of the ZarfState secret). | ||
| type DeployedPackage struct { | ||
| Name string `json:"name"` | ||
| Digest string `json:"digest"` | ||
| Name string `json:"name"` | ||
| Digest string `json:"digest"` | ||
| // Source is the original source string used to deploy the package (e.g. oci:// URL, path to tarball). | ||
| Source string `json:"source,omitempty"` | ||
| Status PackageStatus `json:"status,omitempty"` | ||
| Data v1alpha1.ZarfPackage `json:"data"` | ||
| CLIVersion string `json:"cliVersion"` | ||
| Generation int `json:"generation"` | ||
|
|
@@ -674,6 +705,15 @@ func (d *DeployedPackage) GetPackageConnectivity() PackageConnectivity { | |
| return d.PackageConnectivity | ||
| } | ||
|
|
||
| // GetStatus returns the overall deployment status of the package. | ||
| // Defaults to Unknown for packages deployed before status tracking was introduced. | ||
| func (d *DeployedPackage) GetStatus() PackageStatus { | ||
| if d.Status == "" { | ||
| return PackageStatusUnknown | ||
| } | ||
| return d.Status | ||
| } | ||
|
|
||
| // ConnectString contains information about a connection made with Zarf connect. | ||
| type ConnectString struct { | ||
| // Descriptive text that explains what the resource you would be connecting to is used for | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a consumer perspective, will you care about the actual source or only which type of source. If the latter, then an enum here might be better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actual source - tarballs are hard to reconstruct but an
oci://reference for example could be repulled and deployed again if you needed to.