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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ perf/results/

# Generated code
pkg/api/openapi/
pkg/api/core/

# Downloaded from hyperfleet-api during make generate
# Downloaded specs during make generate
openapi/openapi.yaml
openapi/core-openapi.yaml
25 changes: 17 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,24 @@ help: ## Display this help

##@ Code Generation

# Spec versions — bump when consuming new releases
API_SPEC_VERSION ?= v1.0.25
API_SPEC_TEMPLATE_VERSION ?= v1.0.27

.PHONY: generate
generate: $(OAPI_CODEGEN) ## Generate API client code from OpenAPI schema
$(GO) mod download
rm -rf pkg/api/openapi
mkdir -p pkg/api/openapi openapi
@rm -f openapi/openapi.yaml
@cp "$$($(GO) list -m -f '{{.Dir}}' github.com/openshift-hyperfleet/hyperfleet-api-spec)/schemas/core/openapi.yaml" openapi/openapi.yaml
rm -f pkg/api/openapi/openapi.gen.go pkg/api/core/core.gen.go
mkdir -p pkg/api/openapi pkg/api/core openapi
@rm -f openapi/openapi.yaml openapi/core-openapi.yaml
@echo "Downloading template spec ($(API_SPEC_TEMPLATE_VERSION))..."
@curl -sfL -o openapi/openapi.yaml \
"https://github.com/openshift-hyperfleet/hyperfleet-api-spec-template/releases/download/$(API_SPEC_TEMPLATE_VERSION)/template-openapi.yaml"
@echo "Downloading core spec ($(API_SPEC_VERSION))..."
@curl -sfL -o openapi/core-openapi.yaml \
"https://github.com/openshift-hyperfleet/hyperfleet-api-spec/releases/download/$(API_SPEC_VERSION)/core-openapi.yaml"
$(OAPI_CODEGEN) --config openapi/oapi-codegen.yaml openapi/openapi.yaml
@echo "✓ API client code generated in pkg/api/openapi/"
$(OAPI_CODEGEN) --config openapi/oapi-codegen-core.yaml openapi/core-openapi.yaml
@echo "✓ API client code generated in pkg/api/openapi/ and pkg/api/core/"
Comment thread
coderabbitai[bot] marked this conversation as resolved.

##@ Development

Expand All @@ -72,8 +81,8 @@ run: build ## Build and run with help
clean: ## Remove build artifacts
rm -rf $(BIN_DIR)
rm -rf $(OUTPUT_DIR)
rm -f openapi/openapi.yaml
rm -rf pkg/api/openapi
rm -f openapi/openapi.yaml openapi/core-openapi.yaml
rm -f pkg/api/openapi/openapi.gen.go pkg/api/core/core.gen.go
rm -f coverage.out coverage.html

##@ Testing
Expand Down
15 changes: 8 additions & 7 deletions e2e/adapter/adapter_failover.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" //nolint:staticcheck // dot import for test readability

"github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/api/core"
"github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/api/openapi"
"github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/client"
"github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/helper"
Expand Down Expand Up @@ -117,12 +118,12 @@ var _ = ginkgo.Describe("[Suite: adapter-failures][negative] Adapter framework c
g.Expect(cluster.Status).NotTo(BeNil(), "cluster status should be present")

hasReconciledFalse := h.HasResourceCondition(cluster.Status.Conditions,
client.ConditionTypeReconciled, openapi.ResourceConditionStatusFalse)
client.ConditionTypeReconciled, openapi.False)
g.Expect(hasReconciledFalse).To(BeTrue(),
"initial cluster conditions should have Reconciled=False")

hasAvailableFalse := h.HasResourceCondition(cluster.Status.Conditions,
client.ConditionTypeLastKnownReconciled, openapi.ResourceConditionStatusFalse)
client.ConditionTypeLastKnownReconciled, openapi.False)
g.Expect(hasAvailableFalse).To(BeTrue(),
"initial cluster conditions should have LastKnownReconciled=False")
}, h.Cfg.Timeouts.Adapter.Processing, h.Cfg.Polling.Interval).Should(Succeed())
Expand All @@ -135,7 +136,7 @@ var _ = ginkgo.Describe("[Suite: adapter-failures][negative] Adapter framework c
g.Expect(statuses.Items).NotTo(BeEmpty(), "adapter should have reported status")

// Find the test adapter status
var adapterStatus *openapi.AdapterStatus
var adapterStatus *core.AdapterStatus
for i, adapter := range statuses.Items {
if adapter.Adapter == adapterName {
adapterStatus = &statuses.Items[i]
Expand All @@ -155,7 +156,7 @@ var _ = ginkgo.Describe("[Suite: adapter-failures][negative] Adapter framework c
"adapter should have observed_generation=1")

// Find Available condition
var availableCondition *openapi.AdapterCondition
var availableCondition *core.AdapterCondition
for i, condition := range adapterStatus.Conditions {
if condition.Type == client.ConditionTypeAvailable {
availableCondition = &adapterStatus.Conditions[i]
Expand All @@ -167,7 +168,7 @@ var _ = ginkgo.Describe("[Suite: adapter-failures][negative] Adapter framework c
"adapter should have Available condition")

// Verify Available condition reports failure
g.Expect(availableCondition.Status).To(Equal(openapi.AdapterConditionStatusFalse),
g.Expect(availableCondition.Status).To(Equal(core.AdapterConditionStatusFalse),
"adapter Available condition should be False due to invalid K8s resource")

// Verify error details are present in reason and message
Expand Down Expand Up @@ -196,11 +197,11 @@ var _ = ginkgo.Describe("[Suite: adapter-failures][negative] Adapter framework c
g.Expect(cl.Status).NotTo(BeNil(), "cluster status should be present")

g.Expect(h.HasResourceCondition(cl.Status.Conditions,
client.ConditionTypeReconciled, openapi.ResourceConditionStatusTrue)).To(BeTrue(),
client.ConditionTypeReconciled, openapi.True)).To(BeTrue(),
"cluster Reconciled should become True despite non-required adapter failure")

g.Expect(h.HasResourceCondition(cl.Status.Conditions,
client.ConditionTypeLastKnownReconciled, openapi.ResourceConditionStatusTrue)).To(BeTrue(),
client.ConditionTypeLastKnownReconciled, openapi.True)).To(BeTrue(),
"cluster LastKnownReconciled should become True despite non-required adapter failure")
}, h.Cfg.Timeouts.Cluster.Reconciled, h.Cfg.Polling.Interval).Should(Succeed())

Expand Down
60 changes: 30 additions & 30 deletions e2e/adapter/adapter_with_maestro.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
. "github.com/onsi/gomega" //nolint:staticcheck // Gomega matchers are designed to be used with dot import
corev1 "k8s.io/api/core/v1"

"github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/api/openapi"
"github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/api/core"
"github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/client"
"github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/client/maestro"
"github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/helper"
Expand Down Expand Up @@ -110,7 +110,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport] Adapter Framework -
// Verify Go template conditional label: platformType captured from cluster spec ({{ if .platformType }})
Expect(resourceBundle.Metadata.Labels).To(HaveKey("hyperfleet.io/platform-type"),
"ManifestWork should have platform-type label from {{ if .platformType }} Go template")
Expect(resourceBundle.Metadata.Labels["hyperfleet.io/platform-type"]).To(Equal("gcp"),
Expect(resourceBundle.Metadata.Labels["hyperfleet.io/platform-type"]).To(Equal("template"),
"platform-type label should match cluster spec.platform.type")

// Verify annotations
Expand Down Expand Up @@ -195,8 +195,8 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport] Adapter Framework -
g.Expect(cm.Data["cluster_name"]).To(Equal(clusterName))

// Verify Go template {{ if }}/{{ else }} conditional:
// platformType is captured from spec.platform.type via CEL; cluster payload has type="gcp"
// so {{ if eq .platformType "gcp" }} renders platform_tier="cloud", else "onprem"
// platformType is captured from spec.platform.type via CEL; cluster payload has type="template"
// so {{ if eq .platformType "template" }} renders platform_tier="cloud", else "onprem"
g.Expect(cm.Data).To(HaveKeyWithValue("platform_tier", "cloud"),
"ConfigMap should have platform_tier=cloud from {{ if eq .platformType \"gcp\" }} Go template")

Expand Down Expand Up @@ -231,7 +231,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport] Adapter Framework -
g.Expect(err).NotTo(HaveOccurred(), "failed to get cluster statuses")

// Find the adapter status
var adapterStatus *openapi.AdapterStatus
var adapterStatus *core.AdapterStatus
for _, status := range statuses.Items {
if status.Adapter == adapterName {
adapterStatus = &status
Expand All @@ -253,7 +253,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport] Adapter Framework -
hasApplied := h.HasAdapterCondition(
adapterStatus.Conditions,
client.ConditionTypeApplied,
openapi.AdapterConditionStatusTrue,
core.AdapterConditionStatusTrue,
)
g.Expect(hasApplied).To(BeTrue(),
"adapter should have Applied=True")
Expand All @@ -267,7 +267,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport] Adapter Framework -
hasAvailable := h.HasAdapterCondition(
adapterStatus.Conditions,
client.ConditionTypeAvailable,
openapi.AdapterConditionStatusTrue,
core.AdapterConditionStatusTrue,
)
g.Expect(hasAvailable).To(BeTrue(),
"adapter should have Available=True")
Expand All @@ -281,7 +281,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport] Adapter Framework -
hasHealth := h.HasAdapterCondition(
adapterStatus.Conditions,
client.ConditionTypeHealth,
openapi.AdapterConditionStatusTrue,
core.AdapterConditionStatusTrue,
)
g.Expect(hasHealth).To(BeTrue(),
"adapter should have Health=True")
Expand Down Expand Up @@ -365,7 +365,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport] Adapter Framework -
statuses, err := h.Client.GetClusterStatuses(ctx, clusterID)
g.Expect(err).NotTo(HaveOccurred(), "failed to get cluster statuses")

var adapterStatus *openapi.AdapterStatus
var adapterStatus *core.AdapterStatus
for _, status := range statuses.Items {
if status.Adapter == adapterName {
adapterStatus = &status
Expand All @@ -385,7 +385,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport] Adapter Framework -
statuses, err := h.Client.GetClusterStatuses(ctx, clusterID)
g.Expect(err).NotTo(HaveOccurred(), "failed to get cluster statuses")

var adapterStatus *openapi.AdapterStatus
var adapterStatus *core.AdapterStatus
for _, status := range statuses.Items {
if status.Adapter == adapterName {
adapterStatus = &status
Expand Down Expand Up @@ -532,7 +532,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport][negative] Adapter F
g.Expect(statuses.Items).NotTo(BeEmpty(), "adapter should have reported status")

// Find the test adapter status
var adapterStatus *openapi.AdapterStatus
var adapterStatus *core.AdapterStatus
for i, adapter := range statuses.Items {
if adapter.Adapter == adapterName {
adapterStatus = &statuses.Items[i]
Expand All @@ -548,7 +548,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport][negative] Adapter F
"adapter should have observed_generation=1")

// Find Health condition
var healthCondition *openapi.AdapterCondition
var healthCondition *core.AdapterCondition
for i, condition := range adapterStatus.Conditions {
if condition.Type == client.ConditionTypeHealth {
healthCondition = &adapterStatus.Conditions[i]
Expand All @@ -560,7 +560,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport][negative] Adapter F
"adapter should have Health condition")

// Verify Health condition reports failure
g.Expect(healthCondition.Status).To(Equal(openapi.AdapterConditionStatusFalse),
g.Expect(healthCondition.Status).To(Equal(core.AdapterConditionStatusFalse),
"adapter Health condition should be False due to unregistered consumer")

// Verify error details mention consumer not found/registered
Expand All @@ -574,7 +574,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport][negative] Adapter F
), "error message should mention unregistered consumer")

// Find Applied condition - should be False
var appliedCondition *openapi.AdapterCondition
var appliedCondition *core.AdapterCondition
for i, condition := range adapterStatus.Conditions {
if condition.Type == client.ConditionTypeApplied {
appliedCondition = &adapterStatus.Conditions[i]
Expand All @@ -584,7 +584,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport][negative] Adapter F

g.Expect(appliedCondition).NotTo(BeNil(),
"adapter should have Applied condition")
g.Expect(appliedCondition.Status).To(Equal(openapi.AdapterConditionStatusFalse),
g.Expect(appliedCondition.Status).To(Equal(core.AdapterConditionStatusFalse),
"adapter Applied condition should be False since ManifestWork was not created")

ginkgo.GinkgoWriter.Printf("Verified adapter failure for unregistered consumer: Health=%s, Applied=%s\n",
Expand Down Expand Up @@ -713,7 +713,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport][negative] Adapter F
g.Expect(statuses.Items).NotTo(BeEmpty(), "adapter should have reported status")

// Find the test adapter status
var adapterStatus *openapi.AdapterStatus
var adapterStatus *core.AdapterStatus
for i, adapter := range statuses.Items {
if adapter.Adapter == adapterName {
adapterStatus = &statuses.Items[i]
Expand All @@ -729,7 +729,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport][negative] Adapter F
"adapter should have observed_generation=1")

// Find Applied condition - should be False (ManifestWork not discovered)
var appliedCondition *openapi.AdapterCondition
var appliedCondition *core.AdapterCondition
for i, condition := range adapterStatus.Conditions {
if condition.Type == client.ConditionTypeApplied {
appliedCondition = &adapterStatus.Conditions[i]
Expand All @@ -739,14 +739,14 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport][negative] Adapter F

g.Expect(appliedCondition).NotTo(BeNil(),
"adapter should have Applied condition")
g.Expect(appliedCondition.Status).To(Equal(openapi.AdapterConditionStatusFalse),
g.Expect(appliedCondition.Status).To(Equal(core.AdapterConditionStatusFalse),
"Applied should be False - ManifestWork not discovered")
g.Expect(appliedCondition.Reason).NotTo(BeNil())
g.Expect(*appliedCondition.Reason).To(Equal("ManifestWorkNotDiscovered"),
"Applied reason should be ManifestWorkNotDiscovered")

// Find Available condition - should be False
var availableCondition *openapi.AdapterCondition
var availableCondition *core.AdapterCondition
for i, condition := range adapterStatus.Conditions {
if condition.Type == client.ConditionTypeAvailable {
availableCondition = &adapterStatus.Conditions[i]
Expand All @@ -756,14 +756,14 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport][negative] Adapter F

g.Expect(availableCondition).NotTo(BeNil(),
"adapter should have Available condition")
g.Expect(availableCondition.Status).To(Equal(openapi.AdapterConditionStatusFalse),
g.Expect(availableCondition.Status).To(Equal(core.AdapterConditionStatusFalse),
"Available should be False")
g.Expect(availableCondition.Reason).NotTo(BeNil())
g.Expect(*availableCondition.Reason).To(Equal("NamespaceNotDiscovered"),
"Available reason should be NamespaceNotDiscovered")

// Find Health condition - should be False (execution failed)
var healthCondition *openapi.AdapterCondition
var healthCondition *core.AdapterCondition
for i, condition := range adapterStatus.Conditions {
if condition.Type == client.ConditionTypeHealth {
healthCondition = &adapterStatus.Conditions[i]
Expand All @@ -773,7 +773,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport][negative] Adapter F

g.Expect(healthCondition).NotTo(BeNil(),
"adapter should have Health condition")
g.Expect(healthCondition.Status).To(Equal(openapi.AdapterConditionStatusFalse),
g.Expect(healthCondition.Status).To(Equal(core.AdapterConditionStatusFalse),
"Health should be False - discovery failed")
g.Expect(healthCondition.Reason).NotTo(BeNil())
g.Expect(*healthCondition.Reason).To(Equal("ExecutionFailed:resources"),
Expand Down Expand Up @@ -894,7 +894,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport][negative] Adapter F
g.Expect(statuses.Items).NotTo(BeEmpty(), "adapter should have reported status")

// Find the test adapter status
var adapterStatus *openapi.AdapterStatus
var adapterStatus *core.AdapterStatus
for i, adapter := range statuses.Items {
if adapter.Adapter == adapterName {
adapterStatus = &statuses.Items[i]
Expand All @@ -910,7 +910,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport][negative] Adapter F
"adapter should have observed_generation=1")

// Find Applied condition - should be True (ManifestWork created successfully)
var appliedCondition *openapi.AdapterCondition
var appliedCondition *core.AdapterCondition
for i, condition := range adapterStatus.Conditions {
if condition.Type == client.ConditionTypeApplied {
appliedCondition = &adapterStatus.Conditions[i]
Expand All @@ -920,11 +920,11 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport][negative] Adapter F

g.Expect(appliedCondition).NotTo(BeNil(),
"adapter should have Applied condition")
g.Expect(appliedCondition.Status).To(Equal(openapi.AdapterConditionStatusTrue),
g.Expect(appliedCondition.Status).To(Equal(core.AdapterConditionStatusTrue),
"adapter Applied condition should be True since ManifestWork was created")

// Find Available condition - should be False (nested resources not discovered)
var availableCondition *openapi.AdapterCondition
var availableCondition *core.AdapterCondition
for i, condition := range adapterStatus.Conditions {
if condition.Type == client.ConditionTypeAvailable {
availableCondition = &adapterStatus.Conditions[i]
Expand All @@ -934,12 +934,12 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport][negative] Adapter F

g.Expect(availableCondition).NotTo(BeNil(),
"adapter should have Available condition")
g.Expect(availableCondition.Status).To(Equal(openapi.AdapterConditionStatusFalse),
g.Expect(availableCondition.Status).To(Equal(core.AdapterConditionStatusFalse),
"adapter Available condition should be False since nested discovery returned empty")

// Find Health condition - should be True (adapter executed successfully)
// Note: Nested discovery failure doesn't affect Health - the adapter ran successfully
var healthCondition *openapi.AdapterCondition
var healthCondition *core.AdapterCondition
for i, condition := range adapterStatus.Conditions {
if condition.Type == client.ConditionTypeHealth {
healthCondition = &adapterStatus.Conditions[i]
Expand All @@ -949,7 +949,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport][negative] Adapter F

g.Expect(healthCondition).NotTo(BeNil(),
"adapter should have Health condition")
g.Expect(healthCondition.Status).To(Equal(openapi.AdapterConditionStatusTrue),
g.Expect(healthCondition.Status).To(Equal(core.AdapterConditionStatusTrue),
"adapter Health condition should be True - nested discovery failure doesn't affect health")
g.Expect(healthCondition.Reason).NotTo(BeNil(),
"Health condition should have a reason")
Expand Down Expand Up @@ -1065,7 +1065,7 @@ var _ = ginkgo.Describe("[Suite: adapter][maestro-transport][negative] Adapter F
g.Expect(err).NotTo(HaveOccurred(), "failed to get cluster statuses")

// Find the test adapter status
var adapterStatus *openapi.AdapterStatus
var adapterStatus *core.AdapterStatus
for _, adapter := range statuses.Items {
if adapter.Adapter == adapterName {
adapterStatus = &adapter
Expand Down
Loading