Skip to content

Commit

Permalink
fix: build
Browse files Browse the repository at this point in the history
  • Loading branch information
m8vago committed Nov 26, 2024
1 parent 839cc1f commit 76bc1de
Show file tree
Hide file tree
Showing 29 changed files with 94 additions and 87 deletions.
4 changes: 2 additions & 2 deletions golang/pkg/dagent/utils/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func DeploySharedSecrets(ctx context.Context,
) error {
cfg := grpc.GetConfigFromContext(ctx).(*config.Configuration)

pf := NewSecretsFile(cfg.InternalMountPath, prefix)
pf := NewSecretsPrefixFile(cfg.InternalMountPath, prefix)
err := pf.WriteVariables(secrets)
if err != nil {
return fmt.Errorf("could not write secrets, aborting: %w", err)
Expand Down Expand Up @@ -728,7 +728,7 @@ func SecretList(ctx context.Context, prefix string, name string) ([]string, erro
if name == "" {
cfg := grpc.GetConfigFromContext(ctx).(*config.Configuration)

pf := NewSecretsFile(cfg.InternalMountPath, prefix)
pf := NewSecretsPrefixFile(cfg.InternalMountPath, prefix)
secrets, err := pf.ReadVariables()
if err != nil {
return []string{}, fmt.Errorf("could not read secrets, aborting: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion golang/pkg/dagent/utils/prefix_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewSharedEnvPrefixFile(dataRoot, prefix string) prefixFile {
}
}

func NewSecretsFile(dataRoot, prefix string) prefixFile {
func NewSecretsPrefixFile(dataRoot, prefix string) prefixFile {
return prefixFile{
DataRoot: dataRoot,
Prefix: prefix,
Expand Down
2 changes: 0 additions & 2 deletions web/crux-ui/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"/[teamSlug]/projects": ["projects"],
"/[teamSlug]/projects/[projectId]": ["projects", "versions", "images", "deployments"],
"/[teamSlug]/projects/[projectId]/versions/[versionId]": ["versions", "images", "deployments"],
"/[teamSlug]/projects/[projectId]/versions/[versionId]/images/[imageId]": ["images", "container"],
"/[teamSlug]/nodes": ["nodes", "tokens"],
"/[teamSlug]/nodes/[nodeId]": ["nodes", "images", "tokens", "deployments"],
"/[teamSlug]/nodes/[nodeId]/log": [],
Expand All @@ -38,7 +37,6 @@
"/[teamSlug]/deployments/[deploymentId]": ["images", "deployments", "nodes", "tokens", "container"],
"/[teamSlug]/deployments/[deploymentId]/deploy": ["deployments"],
"/[teamSlug]/deployments/[deploymentId]/log": [],
"/[teamSlug]/deployments/[deploymentId]/instances/[instanceId]": ["images", "deployments", "container"],
"/status": ["status"],
"/templates": ["templates", "projects"],
"/composer": ["compose", "versions", "container"],
Expand Down
4 changes: 2 additions & 2 deletions web/crux-ui/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ const config: PlaywrightTestConfig = {
createProject('template', 'with-login/template.spec.ts'),
createProject('project', 'with-login/project.spec.ts'),
createProject('version', 'with-login/version.spec.ts'),
createProject('image-config', /with-login\/image-config\/(.*)/, ['registry', 'template', 'version']),
createProject('deployment', /with-login\/deployment(.*)\.spec\.ts/, ['image-config', 'nodes']),
createProject('container-config', /with-login\/container-config\/(.*)/, ['registry', 'template', 'version']),
createProject('deployment', /with-login\/deployment(.*)\.spec\.ts/, ['container-config', 'nodes']),
createProject('dagent-deploy', 'with-login/nodes-deploy.spec.ts', ['deployment']),
createProject('resource-copy', 'with-login/resource-copy.spec.ts', ['template', 'version', 'deployment', 'nodes']),
createProject('dashboard', 'with-login/dashboard.spec.ts'),
Expand Down
33 changes: 15 additions & 18 deletions web/crux-ui/src/components/config-bundles/config-bundle-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import Image from 'next/image'
type ConfigBundleCardProps = {
className?: string
configBundle: ConfigBundle
showConfigIcon?: boolean
}

const ConfigBundleCard = (props: ConfigBundleCardProps) => {
const { configBundle, className, showConfigIcon } = props
const { configBundle, className } = props

const { t } = useTranslation('config-bundles')
const routes = useTeamRoutes()
Expand All @@ -41,22 +40,20 @@ const ConfigBundleCard = (props: ConfigBundleCardProps) => {
modalTitle={configBundle.name}
/>

{showConfigIcon && (
<div className="flex flex-row ml-auto mt-auto">
<DyoButton className="px-2" outlined href={routes.containerConfig.details(configBundle.configId)}>
<div className="flex flex-row items-center gap-2">
<Image
className="aspect-square"
src="/container_config_turquoise.svg"
alt={t('common:config')}
width={24}
height={24}
/>
{t('common:config')}
</div>
</DyoButton>
</div>
)}
<div className="flex flex-row ml-auto mt-auto">
<DyoButton className="px-2" outlined href={routes.containerConfig.details(configBundle.configId)}>
<div className="flex flex-row items-center gap-2">
<Image
className="aspect-square"
src="/container_config_turquoise.svg"
alt={t('common:config')}
width={24}
height={24}
/>
{t('common:config')}
</div>
</DyoButton>
</div>
</DyoCard>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import {
CONTAINER_EXPOSE_STRATEGY_VALUES,
CONTAINER_VOLUME_TYPE_VALUES,
CommonConfigKey,
ConcreteCommonConfigData,
ConcreteContainerConfigData,
ConcreteCraneConfigData,
ContainerConfigData,
ContainerConfigErrors,
ContainerConfigExposeStrategy,
Expand Down Expand Up @@ -105,7 +103,7 @@ const CommonConfigSection = (props: CommonConfigSectionProps) => {
})

const onPortsChanged = (ports: Port[]) => {
let patch: Partial<ConcreteCommonConfigData & Pick<ConcreteCraneConfigData, 'metrics'>> = {
let patch: ConcreteContainerConfigData = {
ports,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const ExtendableItemList = <T extends Item>(props: ExtendableItemListProps<T>) =
onResetSection,
emptyItemFactory,
itemClassName,
error,
error: sectionLabelError,
} = props

const [state, dispatch] = useRepatch<InternalState<T>>({
Expand Down Expand Up @@ -153,7 +153,7 @@ const ExtendableItemList = <T extends Item>(props: ExtendableItemListProps<T>) =
labelClassName="text-bright font-semibold tracking-wide"
disabled={!hasValue || disabled || !onResetSection}
onResetSection={onResetSection}
error={error}
error={sectionLabelError}
>
{label.toUpperCase()}
</ConfigSectionLabel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const DeploymentViewList = (props: DeploymentViewListProps) => {
<div className="inline-block mr-2">
<DyoLink
href={routes.containerConfig.details(it.image.config.id)}
qaLabel="deployment-list-image-config-icon"
qaLabel="deployment-list-container-config-icon"
>
<DyoIcon src="/container_config.svg" alt={t('common:imageConfig')} size="md" />
</DyoLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const VersionViewList = (props: VersionViewListProps) => {
onClick={() => onOpenTagsDialog(it)}
/>
</div>

<div className="inline-block">
<DyoIcon
className="cursor-pointer"
Expand All @@ -113,6 +114,7 @@ const VersionViewList = (props: VersionViewListProps) => {
onClick={() => onDelete(it)}
/>
</div>

<DyoLink href={routes.containerConfig.details(it.config.id)} qaLabel="version-list-image-config-icon">
<DyoIcon src="/container_config.svg" alt={t('common:imageConfig')} size="md" />
</DyoLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ const SecretKeyValueInput = (props: SecretKeyValueInputProps) => {
secretKeys.forEach(item => {
const repeating = result.find(it => it.key === item.key)

console.log('status', item.key, secrets)
result.push({
...item,
encrypted: item.encrypted ?? false,
Expand Down
13 changes: 0 additions & 13 deletions web/crux-ui/src/models/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,19 +295,6 @@ export type CraneConfigKey = (typeof CRANE_CONFIG_KEYS)[number]
export type DagentConfigKey = (typeof DAGENT_CONFIG_KEYS)[number]
export type ContainerConfigKey = (typeof CONTAINER_CONFIG_KEYS)[number]

export type DagentConfigData = Pick<ContainerConfigData, DagentConfigKey>
export type CraneConfigData = Pick<ContainerConfigData, CraneConfigKey>
export type CommonConfigData = Omit<ContainerConfigData, DagentConfigKey | CraneConfigKey>

export type ConcreteDagentConfigData = Pick<ConcreteContainerConfigData, DagentConfigKey>
export type ConcreteCraneConfigData = Pick<ConcreteContainerConfigData, CraneConfigKey>
export type ConcreteCommonConfigData = Omit<
ConcreteContainerConfigData,
DagentConfigKey | CraneConfigKey | 'secrets'
> & {
secrets?: UniqueSecretKeyValue[]
}

export type ConcreteContainerConfigData = Omit<ContainerConfigData, 'secrets'> & {
secrets?: UniqueSecretKeyValue[]
}
Expand Down
1 change: 0 additions & 1 deletion web/crux-ui/src/pages/[teamSlug]/config-bundles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ const ConfigBundles = (props: ConfigBundlesPageProps) => {
className={clsx('max-h-72 w-full p-8 my-2', modulo3Class, modulo2Class)}
key={`bundle-${index}`}
configBundle={it}
showConfigIcon
/>
)
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const ConfigBundleDetailsPage = (props: ConfigBundleDetailsPageProps) => {
{editing ? (
<EditConfigBundleCard submit={submit} configBundle={configBundle} onConfigBundleEdited={setConfigBundle} />
) : (
<ConfigBundleCard configBundle={detailsToConfigBundle(configBundle)} showConfigIcon />
<ConfigBundleCard configBundle={detailsToConfigBundle(configBundle)} />
)}
<span className="text-white">TODO deployment list and config</span>
</Layout>
Expand Down
2 changes: 1 addition & 1 deletion web/crux/src/app/container/container.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ContainerConfigUpdatedEvent } from 'src/domain/domain-events'
import { ImageDetails } from 'src/domain/image'
import { toNullableBoolean, toNullableNumber, toPrismaJson } from 'src/domain/utils'
import { versionIsMutable } from 'src/domain/version'
import { ListSecretsResponse } from 'src/grpc/protobuf/proto/common'
import ConfigBundleMapper from '../config.bundle/config.bundle.mapper'
import DeployMapper from '../deploy/deploy.mapper'
import ImageMapper from '../image/image.mapper'
Expand All @@ -31,7 +32,6 @@ import {
ContainerConfigTypeDto,
ContainerSecretsDto,
} from './container.dto'
import { ListSecretsResponse } from 'src/grpc/protobuf/proto/common'

@Injectable()
export default class ContainerMapper {
Expand Down
2 changes: 1 addition & 1 deletion web/crux/src/app/container/container.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { forwardRef, Module } from '@nestjs/common'
import PrismaService from 'src/services/prisma.service'
import AgentModule from '../agent/agent.module'
import AuditLoggerModule from '../audit.logger/audit.logger.module'
import ConfigBundleModule from '../config.bundle/config.bundle.module'
import DeployModule from '../deploy/deploy.module'
Expand All @@ -12,7 +13,6 @@ import ContainerConfigHttpController from './container-config.http.service'
import ContainerConfigService from './container-config.service'
import ContainerConfigWebSocketGateway from './container-config.ws.gateway'
import ContainerMapper from './container.mapper'
import AgentModule from '../agent/agent.module'

@Module({
imports: [
Expand Down
2 changes: 2 additions & 0 deletions web/crux/src/app/deploy/deploy.mapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,8 @@ describe('DeployMapper', () => {
updatedAt: new Date(),
createdBy: 'created-by',
updatedBy: 'updated-by',
deployedAt: null,
deployedBy: null,
node: {
id: 'deployment-node-id',
name: 'deployment node',
Expand Down
12 changes: 8 additions & 4 deletions web/crux/src/app/node/node.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ describe('NodeService', () => {
await nodeService.deleteContainer('test-node-id', 'test-prefix', 'test-name')

expect(createAgentEventMock).toHaveBeenCalledWith('test-node-id', 'containerCommand', {
container: {
prefix: 'test-prefix',
name: 'test-name',
target: {
container: {
prefix: 'test-prefix',
name: 'test-name',
},
},
operation: 'deleteContainer',
})
Expand All @@ -108,7 +110,9 @@ describe('NodeService', () => {
await nodeService.deleteAllContainers('test-node-id', 'test-prefix')

expect(createAgentEventMock).toHaveBeenCalledWith('test-node-id', 'containerCommand', {
prefix: 'test-prefix',
target: {
prefix: 'test-prefix',
},
operation: 'deleteContainers',
})
})
Expand Down
1 change: 0 additions & 1 deletion web/crux/src/domain/agent-callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export default class AgentCallback<Req, Res> {
}

onError(key: string, error: AgentError) {
console.log('error', key)
const result = this.requests.get(key)
if (!result) {
return
Expand Down
37 changes: 24 additions & 13 deletions web/crux/src/domain/agent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ describe('agent', () => {
const commandChannel = firstValueFrom(agent.onConnected(jest.fn()))

const deleteRequest: DeleteContainersRequest = {
prefix: 'prefix',
target: {
prefix: 'prefix',
},
}

const deleteRes = agent.deleteContainers(deleteRequest)
Expand All @@ -213,7 +215,7 @@ describe('agent', () => {
agent.onCallback(
'deleteContainers',
Agent.containerPrefixNameOf({
prefix: deleteRequest.prefix,
prefix: deleteRequest.target.prefix,
name: '',
}),
Empty,
Expand All @@ -230,7 +232,9 @@ describe('agent', () => {
const commandChannel = firstValueFrom(agent.onConnected(jest.fn()))

const deleteRequest: DeleteContainersRequest = {
prefix: 'prefix',
target: {
prefix: 'prefix',
},
}

const deleteRes = agent.deleteContainers(deleteRequest)
Expand Down Expand Up @@ -306,9 +310,11 @@ describe('agent', () => {
const commandChannel = firstValueFrom(agent.onConnected(jest.fn()))

const req: ListSecretsRequest = {
container: {
prefix: 'prefix',
name: 'name',
target: {
container: {
prefix: 'prefix',
name: 'name',
},
},
}

Expand All @@ -320,14 +326,17 @@ describe('agent', () => {
})

const message: ListSecretsResponse = {
prefix: 'prefix',
name: 'name',
target: {
container: {
prefix: 'prefix',
name: 'name',
},
},
publicKey: 'key',
hasKeys: true,
keys: ['k1', 'k2', 'k3'],
}

agent.onCallback('listSecrets', Agent.containerPrefixNameOf(req.container), message)
agent.onCallback('listSecrets', Agent.containerPrefixNameOf(req.target.container), message)

const secretsActual = await secrets
expect(secretsActual).toEqual(message)
Expand All @@ -339,9 +348,11 @@ describe('agent', () => {
const commandChannel = firstValueFrom(agent.onConnected(jest.fn()))

const req: ListSecretsRequest = {
container: {
prefix: 'prefix',
name: 'name',
target: {
container: {
prefix: 'prefix',
name: 'name',
},
},
}

Expand Down
Loading

0 comments on commit 76bc1de

Please sign in to comment.