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
9 changes: 9 additions & 0 deletions internal/controller/styra/system_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ func (r *SystemReconciler) reconcileSystemBundle(
Name: uniqueName,
ObjectStorage: objectStorage,
Requirements: requirements,
Revision: bundleRevision(),
}
err := r.OCP.PutBundle(ctx, bundle)

Expand All @@ -830,6 +831,14 @@ func (r *SystemReconciler) reconcileSystemBundle(
return ctrl.Result{}, nil
}

// bundleRevision produces a string containing the commit sha for each git requirement
// and the sha256 hash of the concatenated hashes of all datasources,
// for example "data:sha256,gitsource1:commitsha1,requirement1:commitsha2"
func bundleRevision() string {
return `$"data:{crypto.sha256(concat("", {x | x := input.sources[_].sql.hash}))},` +
`{concat(",", {sprintf("%s:%s", [y, x]) | some y; x := input.sources[y].git.commit})}"`
}

func (r *SystemReconciler) reconcileSystemSource(
ctx context.Context,
log logr.Logger,
Expand Down
10 changes: 1 addition & 9 deletions pkg/ocp/bundles.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ const (
endpointV1Bundles = "/v1/bundles"
)

// BundleConfig represents the configuration of a bundle in the OCP APIs.
type BundleConfig struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not used

Name string `json:"-" yaml:"-"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
ObjectStorage ObjectStorage `json:"object_storage,omitempty" yaml:"object_storage,omitempty"`
Requirements []Requirement `json:"requirements,omitempty" yaml:"requirements,omitempty"`
ExcludedFiles []string `json:"excluded_files,omitempty" yaml:"excluded_files,omitempty"`
}

// ObjectStorage represents the object storage configuration for a bundle.
type ObjectStorage struct {
AmazonS3 *AmazonS3 `json:"aws,omitempty" yaml:"aws,omitempty"`
Expand Down Expand Up @@ -84,6 +75,7 @@ type PutBundleRequest struct {
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
ObjectStorage ObjectStorage `json:"object_storage,omitempty" yaml:"object_storage,omitempty"`
Requirements []Requirement `json:"requirements,omitempty" yaml:"requirements,omitempty"`
Revision string `json:"revision,omitempty" yaml:"revision,omitempty"`
ExcludedFiles []string `json:"excluded_files,omitempty" yaml:"excluded_files,omitempty"`
}

Expand Down
6 changes: 6 additions & 0 deletions test/integration/controller/system_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2629,6 +2629,8 @@ var _ = ginkgo.Describe("SystemReconciler.ReconcileOCPSystem", ginkgo.Label("int
Source: "default-ocp-system",
},
},
Revision: `$"data:{crypto.sha256(concat("", {x | x := input.sources[_].sql.hash}))},` +
`{concat(",", {sprintf("%s:%s", [y, x]) | some y; x := input.sources[y].git.commit})}"`,
}).Return(nil).Once()

// Called in reconcileS3Credentials
Expand Down Expand Up @@ -2688,6 +2690,8 @@ var _ = ginkgo.Describe("SystemReconciler.ReconcileOCPSystem", ginkgo.Label("int
Source: "default-ocp-system",
},
},
Revision: `$"data:{crypto.sha256(concat("", {x | x := input.sources[_].sql.hash}))},` +
`{concat(",", {sprintf("%s:%s", [y, x]) | some y; x := input.sources[y].git.commit})}"`,
}).Return(nil).Once()

// Called in reconcileS3Credentials
Expand Down Expand Up @@ -2741,6 +2745,8 @@ var _ = ginkgo.Describe("SystemReconciler.ReconcileOCPSystem", ginkgo.Label("int
Source: "default-ocp-system",
},
},
Revision: `$"data:{crypto.sha256(concat("", {x | x := input.sources[_].sql.hash}))},` +
`{concat(",", {sprintf("%s:%s", [y, x]) | some y; x := input.sources[y].git.commit})}"`,
}).Return(nil).Once()

// Called in reconcileS3Credentials
Expand Down
Loading