-
Notifications
You must be signed in to change notification settings - Fork 3
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/chore: Add App Delete Functionality and Refactor Code #36
Conversation
Introduces the app delete feature, following the same process as application distribution upload. For deleting an app the dist zip file will include only the spaship.yaml file with the target application name and mandatory details. Also, exclude from environment is set to 'true'.
EventManager eventManager, @Named("deNamespace") String ns) { | ||
this.ocClient = ocClient; | ||
this.eventManager = eventManager; | ||
domain = ConfigProvider.getConfig().getValue("operator.domain.name", String.class); |
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.
@arkaprovob can you use a variable instead of directly using the string?
private static final String OPERATOR_DOMAIN_NAME = "operator.domain.name";
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.
Great observation, Soumya! I've created a GitHub issue for this. Instead of modifying just this file, let's consider refactoring other classes to ensure that these changes are applied consistently throughout, Let's handle it separately.
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.
Sure @arkaprovob
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.
@arkaprovob I've added a few comments in this PR. Please check
this.ocClient = ocClient; | ||
this.eventManager = eventManager; | ||
domain = ConfigProvider.getConfig().getValue("operator.domain.name", String.class); | ||
routerDomain = ConfigProvider.getConfig().getValue("operator.router.domain.name", String.class); |
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.
private static final String OPERATOR_DOMAIN_NAME = "operator.domain.name";
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.
Great observation, Soumya! I've created a GitHub issue for this. Instead of modifying just this file, let's consider refactoring other classes to ensure that these changes are applied consistently throughout, Let's handle it separately.
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.
Sure @arkaprovob
|
||
ReUsableItems.releaseLock(environment.getIdentification()); | ||
LOG.debug("\n"); | ||
// todo change the status code type to enum instead of int for better readability |
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.
Optional : As you are following // TODO:
format in the entire code, you can format // todo
with // TODO:
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.
created an issue for the same #38
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.
ack
if (!envExists) | ||
createNewEnvironment(environment); | ||
String sideCarSvcUrl = environmentSidecarUrl(environment); | ||
// todo mutability is not good, we should not change the state of the object |
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.
Optional : As you are following // TODO:
format in the entire code, you can format // todo
with // TODO:
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.
created an issue for the same #38
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.
ack
private void createNewTenantNamespace(Environment environment, Map<String, String> templateParameters) { | ||
var k8sNSList = ocClient | ||
.templates() | ||
.load(Operations.class.getResourceAsStream("/openshift/mpp-namespace-template.yaml")) |
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.
could you please add this path to a variable ? (also if possible you can provide an option to read this path from the env variable if you think it's feasible)
private final String OPENSHIFT_NAMESPACE_PATH = "/openshift/mpp-namespace-template.yaml";
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.
Good observation I have created a GitHub issue for the same.
} | ||
if (item instanceof PersistentVolumeClaim pvc) { | ||
LOG.debug("creating new pvc in K8s, tracing = {}", tracing); | ||
ocClient.persistentVolumeClaims().inNamespace(nameSpace).createOrReplace(pvc); |
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.
Note : There might be a potential issue of exception, can we handle it here ! (Optional)
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.
As long as the parameter of the function KubernetesList result not null, there should be no other issues, thanks to Fabric8 library handling the rest.
I have created #45 to add a null check for the 'KubernetesList result' parameter.
} | ||
if (item instanceof Route route) { | ||
LOG.debug("creating new Route in K8s, tracing = {}", tracing); | ||
ocClient.routes().inNamespace(nameSpace).createOrReplace(route); |
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.
Note : There might be a potential issue of exception, can we handle it here ! (Optional)
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.
As long as the parameter of the function KubernetesList result
not null, there should be no other issues, thanks to Fabric8 library handling the rest.
I have created this issue to add a null check for the 'KubernetesList result' parameter.
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.
Okay @arkaprovob
} | ||
if (item instanceof ConfigMap cm) { | ||
LOG.debug("creating new ConfigMap in K8s, tracing = {}", tracing); | ||
ocClient.configMaps().inNamespace(nameSpace).createOrReplace(cm); |
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.
Note : There might be a potential issue of exception, can we handle it here ! (Optional)
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.
As long as the parameter of the function KubernetesList result not null, there should be no other issues, thanks to Fabric8 library handling the rest.
I have created #45 to add a null check for the 'KubernetesList result' parameter.
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.
Okay @arkaprovob
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.
Hi @arkaprovob , I've gone through you comments. Thanks for creating the respected issues against the comments. We'll go through it and resolve these as a separate issue.
EventManager eventManager, @Named("deNamespace") String ns) { | ||
this.ocClient = ocClient; | ||
this.eventManager = eventManager; | ||
domain = ConfigProvider.getConfig().getValue("operator.domain.name", String.class); |
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.
Sure @arkaprovob
this.ocClient = ocClient; | ||
this.eventManager = eventManager; | ||
domain = ConfigProvider.getConfig().getValue("operator.domain.name", String.class); | ||
routerDomain = ConfigProvider.getConfig().getValue("operator.router.domain.name", String.class); |
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.
Sure @arkaprovob
|
||
ReUsableItems.releaseLock(environment.getIdentification()); | ||
LOG.debug("\n"); | ||
// todo change the status code type to enum instead of int for better readability |
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.
ack
if (!envExists) | ||
createNewEnvironment(environment); | ||
String sideCarSvcUrl = environmentSidecarUrl(environment); | ||
// todo mutability is not good, we should not change the state of the object |
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.
ack
String type = (String) rule.get("type"); | ||
Map<String, Object> to = (Map<String, Object>) rule.get("to"); | ||
String cidrSelectorName = (String) to.get("cidrSelector"); | ||
return "0.0.0.0/0".equals(cidrSelectorName) && type.equalsIgnoreCase("Deny"); |
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.
Okay make sense
} | ||
if (item instanceof Route route) { | ||
LOG.debug("creating new Route in K8s, tracing = {}", tracing); | ||
ocClient.routes().inNamespace(nameSpace).createOrReplace(route); |
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.
Okay @arkaprovob
} | ||
if (item instanceof ConfigMap cm) { | ||
LOG.debug("creating new ConfigMap in K8s, tracing = {}", tracing); | ||
ocClient.configMaps().inNamespace(nameSpace).createOrReplace(cm); |
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.
Okay @arkaprovob
This pull request is for the following changes:
Add App Delete Functionality:
splaship.yaml
file with the target application name and mandatory details related to the application.exclude
flag totrue
for deleted apps.**Refactor Code Following App Delete Functionality Addition: **