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

Bug 1933017: Fix to avoid overriding of d/dc pod template container values #8322

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -165,7 +165,10 @@ export const getDeploymentData = (resource: K8sResourceKind) => {
replicas: 1,
triggers: { image: true, config: true },
};
const container = resource.spec?.template?.spec?.containers?.[0];
const container = _.find(
resource.spec?.template?.spec?.containers,
(c) => c.name === resource.metadata.name,
);
const env = container?.env ?? [];
switch (getResourcesType(resource)) {
case Resources.KnativeService:
Expand Down
@@ -1,5 +1,4 @@
import * as React from 'react';
import * as _ from 'lodash';
import { CheckboxField, EnvironmentField } from '@console/shared';
import { K8sResourceKind } from '@console/internal/module/k8s';
import FormSection from '../section/FormSection';
Expand All @@ -16,15 +15,18 @@ const DeploymentConfigSection: React.FC<DeploymentConfigSectionProps> = ({
resource,
}) => {
const {
values: { resources },
values: {
resources,
deployment: { env },
},
} = useFormikContext<FormikValues>();
const deploymentConfigObj = resource || {
kind: 'DeploymentConfig',
metadata: {
namespace,
},
};
const envs = _.get(deploymentConfigObj, 'spec.template.spec.containers[0].env', []);

return (
<FormSection title="Deployment" fullWidth>
<CheckboxField
Expand All @@ -40,7 +42,7 @@ const DeploymentConfigSection: React.FC<DeploymentConfigSectionProps> = ({
<EnvironmentField
name="deployment.env"
label="Environment Variables (Runtime only)"
envs={envs}
envs={env}
obj={deploymentConfigObj}
envPath={['spec', 'template', 'spec', 'containers']}
/>
Expand Down
Expand Up @@ -161,6 +161,7 @@ export const createOrUpdateDeployment = (
...annotations,
'alpha.image.policy.openshift.io/resolve-names': '*',
...getTriggerAnnotation(
name,
imgName || name,
imgNamespace || namespace,
imageChange,
Expand Down Expand Up @@ -440,6 +441,7 @@ export const createOrUpdateDeployImageResources = async (
}
const originalAnnotations = appResources?.editAppResource?.data?.metadata?.annotations || {};
const triggerAnnotations = getTriggerAnnotation(
name,
internalImageStreamName || name,
internalImageStreamNamespace || namespace,
imageChange,
Expand Down
Expand Up @@ -249,11 +249,12 @@ export const createOrUpdateDeployment = (

const imageStreamName = imageStream && imageStream.metadata.name;
const defaultLabels = getAppLabels({ name, applicationName, imageStreamName, selectedTag });
const imageName = name;
const annotations = {
...getGitAnnotations(repository, ref),
...getCommonAnnotations(),
'alpha.image.policy.openshift.io/resolve-names': '*',
...getTriggerAnnotation(name, namespace, imageChange),
...getTriggerAnnotation(name, imageName, namespace, imageChange),
};
const podLabels = getPodLabels(name);
const templateLabels = getTemplateLabels(originalDeployment);
Expand Down Expand Up @@ -479,6 +480,7 @@ export const createOrUpdateResources = async (

const originalAnnotations = appResources?.editAppResource?.data?.metadata?.annotations || {};
const triggerAnnotations = getTriggerAnnotation(
name,
generatedImageStreamName || name,
namespace,
imageChange,
Expand Down