Skip to content

Commit d8c928f

Browse files
committed
fix: added package generation to RecordPackageDeployment
Signed-off-by: Steven Gettys <[email protected]>
1 parent 61d54aa commit d8c928f

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/internal/packager2/load_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func TestPackageFromSourceOrCluster(t *testing.T) {
150150
c := &cluster.Cluster{
151151
Clientset: fake.NewClientset(),
152152
}
153-
_, err = c.RecordPackageDeployment(ctx, pkg, nil)
153+
_, err = c.RecordPackageDeployment(ctx, pkg, nil, 1)
154154
require.NoError(t, err)
155155
pkg, err = GetPackageFromSourceOrCluster(ctx, c, "test", false, "")
156156
require.NoError(t, err)

src/pkg/cluster/zarf.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (c *Cluster) StripZarfLabelsAndSecretsFromNamespaces(ctx context.Context) {
156156
}
157157

158158
// RecordPackageDeployment saves metadata about a package that has been deployed to the cluster.
159-
func (c *Cluster) RecordPackageDeployment(ctx context.Context, pkg v1alpha1.ZarfPackage, components []types.DeployedComponent) (*types.DeployedPackage, error) {
159+
func (c *Cluster) RecordPackageDeployment(ctx context.Context, pkg v1alpha1.ZarfPackage, components []types.DeployedComponent, generation int) (*types.DeployedPackage, error) {
160160
packageName := pkg.Metadata.Name
161161

162162
// TODO: This is done for backwards compatibility and could be removed in the future.
@@ -175,6 +175,7 @@ func (c *Cluster) RecordPackageDeployment(ctx context.Context, pkg v1alpha1.Zarf
175175
Data: pkg,
176176
DeployedComponents: components,
177177
ConnectStrings: connectStrings,
178+
Generation: generation,
178179
}
179180

180181
packageData, err := json.Marshal(deployedPackage)

src/pkg/packager/deploy.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func (p *Packager) deployComponents(ctx context.Context) ([]types.DeployedCompon
188188
deployedComponents = append(deployedComponents, deployedComponent)
189189
idx := len(deployedComponents) - 1
190190
if p.isConnectedToCluster() {
191-
if _, err := p.cluster.RecordPackageDeployment(ctx, p.cfg.Pkg, deployedComponents); err != nil {
191+
if _, err := p.cluster.RecordPackageDeployment(ctx, p.cfg.Pkg, deployedComponents, packageGeneration); err != nil {
192192
message.Debugf("Unable to record package deployment for component %q: this will affect features like `zarf package remove`: %s", component.Name, err.Error())
193193
l.Debug("unable to record package deployment", "component", component.Name, "error", err.Error())
194194
}
@@ -215,7 +215,7 @@ func (p *Packager) deployComponents(ctx context.Context) ([]types.DeployedCompon
215215
onFailure()
216216
deployedComponents[idx].Status = types.ComponentStatusFailed
217217
if p.isConnectedToCluster() {
218-
if _, err := p.cluster.RecordPackageDeployment(ctx, p.cfg.Pkg, deployedComponents); err != nil {
218+
if _, err := p.cluster.RecordPackageDeployment(ctx, p.cfg.Pkg, deployedComponents, packageGeneration); err != nil {
219219
message.Debugf("Unable to record package deployment for component %q: this will affect features like `zarf package remove`: %s", component.Name, err.Error())
220220
l.Debug("unable to record package deployment", "component", component.Name, "error", err.Error())
221221
}
@@ -227,7 +227,7 @@ func (p *Packager) deployComponents(ctx context.Context) ([]types.DeployedCompon
227227
deployedComponents[idx].InstalledCharts = charts
228228
deployedComponents[idx].Status = types.ComponentStatusSucceeded
229229
if p.isConnectedToCluster() {
230-
if _, err := p.cluster.RecordPackageDeployment(ctx, p.cfg.Pkg, deployedComponents); err != nil {
230+
if _, err := p.cluster.RecordPackageDeployment(ctx, p.cfg.Pkg, deployedComponents, packageGeneration); err != nil {
231231
message.Debugf("Unable to record package deployment for component %q: this will affect features like `zarf package remove`: %s", component.Name, err.Error())
232232
l.Debug("unable to record package deployment", "component", component.Name, "error", err.Error())
233233
}

0 commit comments

Comments
 (0)