-
Notifications
You must be signed in to change notification settings - Fork 13
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
Ephemeral component versions #642
Changes from 12 commits
2527990
5ae058b
3f7fd60
4809a30
71e9af8
00a1426
9d9d1df
7cb133d
65961b3
24a5bab
04189b1
09047c5
75022d4
79f1f8e
3967cc1
b04b7a2
4e5e4ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import tmp from 'tmp'; | |
import untildify from 'untildify'; | ||
import { ArchitectError, buildSpecFromPath, ComponentSlugUtils, Dictionary, dumpToYml, resourceRefToNodeRef, ResourceSlugUtils, ServiceNode, Slugs, validateInterpolation } from '../'; | ||
import AccountUtils from '../architect/account/account.utils'; | ||
import { EnvironmentUtils } from '../architect/environment/environment.utils'; | ||
import BaseCommand from '../base-command'; | ||
import LocalDependencyManager from '../common/dependency-manager/local-manager'; | ||
import { DockerComposeUtils } from '../common/docker-compose'; | ||
|
@@ -20,6 +21,8 @@ import { IF_EXPRESSION_REGEX } from '../dependency-manager/spec/utils/interpolat | |
|
||
tmp.setGracefulCleanup(); | ||
|
||
export const EPHEMERAL_DELIMITER = 'architect-ephemeral'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we make it targeted to the environment? Not really a delimiter - more a prefix.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I like that |
||
|
||
export default class ComponentRegister extends BaseCommand { | ||
static aliases = ['component:register', 'components:register', 'c:register', 'comp:register']; | ||
static description = 'Register a new Component with Architect Cloud'; | ||
|
@@ -40,6 +43,7 @@ export default class ComponentRegister extends BaseCommand { | |
char: 't', | ||
description: 'Tag to give to the new component', | ||
default: 'latest', | ||
exclusive: ['environment'], | ||
}), | ||
}, | ||
architecture: { | ||
|
@@ -56,6 +60,14 @@ export default class ComponentRegister extends BaseCommand { | |
description: 'Directory to write build cache to. Do not use in Github Actions: https://docs.architect.io/deployments/automated-previews/#caching-between-workflow-runs', | ||
}), | ||
}, | ||
environment: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we make this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had considered that, but I don't see why someone shouldn't be able to create an ephemeral component version directly rather than indirectly thorough the deploy command There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would be the reason for them to do that? My inclination is to make it hidden with the option to unhide in the future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe they just don't want to deploy the component immediately after it's registered? I'll hide it though |
||
non_sensitive: true, | ||
...Flags.string({ | ||
char: 'e', | ||
description: 'The name of an environment to register the component version to. If specified, the component version will be removed when the environment is removed', | ||
exclusive: ['tag'], | ||
}), | ||
}, | ||
}; | ||
|
||
static args = [{ | ||
|
@@ -75,7 +87,7 @@ export default class ComponentRegister extends BaseCommand { | |
throw new ArchitectError(Slugs.ComponentTagDescription); | ||
} | ||
|
||
await this.registerComponent(config_path, flags.tag); | ||
await this.registerComponent(config_path, ComponentRegister.getTagFromFlags(flags)); | ||
} | ||
|
||
private async registerComponent(config_path: string, tag: string) { | ||
|
@@ -89,19 +101,15 @@ export default class ComponentRegister extends BaseCommand { | |
throw new Error('Component Config must have a name'); | ||
} | ||
|
||
const context = { | ||
architect: { | ||
build: { | ||
tag: flags.tag, | ||
}, | ||
}, | ||
}; | ||
|
||
validateInterpolation(component_spec); | ||
|
||
const { component_account_name, component_name } = ComponentSlugUtils.parse(component_spec.name); | ||
const selected_account = await AccountUtils.getAccount(this.app, component_account_name || flags.account); | ||
|
||
if (flags.environment) { // will throw an error if a user specifies an environment that doesn't exist | ||
await EnvironmentUtils.getEnvironment(this.app.api, selected_account, flags.environment); | ||
} | ||
|
||
const dependency_manager = new LocalDependencyManager(this.app.api); | ||
dependency_manager.environment = 'production'; | ||
dependency_manager.account = selected_account.name; | ||
|
@@ -256,6 +264,7 @@ export default class ComponentRegister extends BaseCommand { | |
delete config.metadata; | ||
const component_dto = { | ||
tag, | ||
environment_name: flags.environment, | ||
config, | ||
}; | ||
|
||
|
@@ -313,4 +322,8 @@ export default class ComponentRegister extends BaseCommand { | |
const { headers } = await registry_client.head(`${name}/manifests/${tag}`); | ||
return headers['docker-content-digest']; | ||
} | ||
|
||
public static getTagFromFlags(flags: any): string { | ||
return flags.environment ? `${EPHEMERAL_DELIMITER}-${flags.environment}` : flags.tag; | ||
} | ||
} |
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.
Remove the account name prefix. Since sometimes the account name is part of the name for older customers.