Skip to content
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

feat: update domain model #6

Merged
merged 4 commits into from
Dec 8, 2023
Merged
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 .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ on:
jobs:
build:
uses: onecx/ci-quarkus/.github/workflows/build.yml@v1
secrets: inherit
secrets: inherit
with:
helmEventTargetRepository: onecx/onecx-product-store
2 changes: 1 addition & 1 deletion src/main/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1
apiVersion: v2
name: onecx-product-store-mfe-operator
version: 0.0.0
appVersion: 0.0.0
Expand Down
136 changes: 73 additions & 63 deletions src/main/helm/crds/microfrontends.io.github.onecx.product.store-v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,66 +11,76 @@ spec:
singular: microfrontend
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
properties:
spec:
properties:
display-name:
type: string
app-id:
type: string
product-name:
type: string
remote-entry:
type: string
wc-tag-name:
type: string
remote-name:
type: string
exposed-module:
type: string
mfe-id:
type: string
note:
type: string
base-path:
type: string
app-version:
type: string
remote-base-url:
type: string
module-type:
enum:
- WEBCOMPONENT
- ANGULAR
type: string
contact:
type: string
type: object
status:
properties:
response-code:
type: integer
status:
enum:
- UPDATED
- ERROR
- CREATED
- UNDEFINED
type: string
product-name:
type: string
mfe-id:
type: string
message:
type: string
observedGeneration:
type: integer
type: object
type: object
served: true
storage: true
subresources:
status: {}
- name: v1
schema:
openAPIV3Schema:
properties:
spec:
properties:
appId:
type: string
appName:
type: string
appVersion:
type: string
classifications:
items:
type: string
type: array
contact:
type: string
description:
type: string
endpoints:
items:
properties:
name:
type: string
path:
type: string
type: object
type: array
exposedModule:
type: string
iconName:
type: string
note:
type: string
productName:
type: string
remoteBaseUrl:
type: string
remoteEntry:
type: string
technology:
type: string
type: object
status:
properties:
appId:
type: string
appName:
type: string
appVersion:
type: string
message:
type: string
observedGeneration:
type: integer
productName:
type: string
responseCode:
type: integer
status:
enum:
- CREATED
- ERROR
- UNDEFINED
- UPDATED
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public class MicrofrontendController implements Reconciler<Microfrontend>, Error
public UpdateControl<Microfrontend> reconcile(Microfrontend microfrontend, Context<Microfrontend> context)
throws Exception {

String mfeId = microfrontend.getSpec().getMfeId();
String appId = microfrontend.getSpec().getAppId();
String productName = microfrontend.getSpec().getProductName();

log.info("Reconcile microfrontend: {} for product: {}", mfeId, productName);
log.info("Reconcile microfrontend: {} for product: {}", appId, productName);

int responseCode = service.updateMicrofrontend(microfrontend);

Expand All @@ -49,8 +49,10 @@ public ErrorStatusUpdateControl<Microfrontend> updateErrorStatus(Microfrontend m

log.error("Error reconcile resource", e);
MicrofrontendStatus status = new MicrofrontendStatus();
status.setProductName(null);
status.setMfeId(null);
status.setRequestProductName(null);
status.setRequestAppId(null);
status.setRequestAppName(null);
status.setRequestAppVersion(null);
status.setResponseCode(responseCode);
status.setStatus(MicrofrontendStatus.Status.ERROR);
status.setMessage(e.getMessage());
Expand All @@ -61,8 +63,10 @@ public ErrorStatusUpdateControl<Microfrontend> updateErrorStatus(Microfrontend m
private void updateStatusPojo(Microfrontend microfrontend, int responseCode) {
MicrofrontendStatus result = new MicrofrontendStatus();
MicrofrontendSpec spec = microfrontend.getSpec();
result.setProductName(spec.getProductName());
result.setMfeId(spec.getMfeId());
result.setRequestProductName(spec.getProductName());
result.setRequestAppId(spec.getAppId());
result.setRequestAppName(spec.getAppName());
result.setRequestAppVersion(spec.getAppVersion());
result.setResponseCode(responseCode);
var status = switch (responseCode) {
case 201:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.github.onecx.product.store.mfe.operator;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class MicrofrontendEndpointSpec {

@JsonProperty("path")
private String path;

@JsonProperty("name")
private String name;

public String getPath() {
return path;
}

public void setPath(String path) {
this.path = path;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}
Loading
Loading