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(ingest): remove hardcoded env variable default for cli version #6075

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
timeout-minutes: 60
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const NameSourceStep = ({ state, updateState, prev, submit }: StepProps)
Advanced: Provide a custom CLI version to use for ingestion.
</Typography.Paragraph>
<Input
placeholder="0.8.42"
placeholder="(e.g. 0.8.42)"
value={state.config?.version || ''}
onChange={(event) => setVersion(event.target.value)}
/>
Expand Down
3 changes: 1 addition & 2 deletions docker/datahub-gms/env/docker-without-neo4j.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ MAE_CONSUMER_ENABLED=true
MCE_CONSUMER_ENABLED=true
PE_CONSUMER_ENABLED=true
UI_INGESTION_ENABLED=true
UI_INGESTION_DEFAULT_CLI_VERSION=0.8.42
ENTITY_SERVICE_ENABLE_RETENTION=true

# Uncomment to disable persistence of client-side analytics events
Expand Down Expand Up @@ -46,4 +45,4 @@ ENTITY_SERVICE_ENABLE_RETENTION=true

# Uncomment to run a one-time upgrade to migrate legacy default browse path format to latest format
# More details can be found at https://datahubproject.io/docs/advanced/browse-paths-upgrade
# UPGRADE_DEFAULT_BROWSE_PATHS_ENABLED=true
# UPGRADE_DEFAULT_BROWSE_PATHS_ENABLED=true
1 change: 0 additions & 1 deletion docker/datahub-gms/env/docker.env
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ MAE_CONSUMER_ENABLED=true
MCE_CONSUMER_ENABLED=true
PE_CONSUMER_ENABLED=true
UI_INGESTION_ENABLED=true
UI_INGESTION_DEFAULT_CLI_VERSION=0.8.42

# Uncomment to enable Metadata Service Authentication
# METADATA_SERVICE_AUTH_ENABLED=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ services:
- MCE_CONSUMER_ENABLED=true
- PE_CONSUMER_ENABLED=true
- UI_INGESTION_ENABLED=true
- UI_INGESTION_DEFAULT_CLI_VERSION=0.8.42
- ENTITY_SERVICE_ENABLE_RETENTION=true
hostname: datahub-gms
image: ${DATAHUB_GMS_IMAGE:-linkedin/datahub-gms}:${DATAHUB_VERSION:-head}
Expand Down
1 change: 0 additions & 1 deletion docker/quickstart/docker-compose.quickstart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ services:
- MCE_CONSUMER_ENABLED=true
- PE_CONSUMER_ENABLED=true
- UI_INGESTION_ENABLED=true
- UI_INGESTION_DEFAULT_CLI_VERSION=0.8.42
hostname: datahub-gms
image: ${DATAHUB_GMS_IMAGE:-linkedin/datahub-gms}:${DATAHUB_VERSION:-head}
ports:
Expand Down
86 changes: 86 additions & 0 deletions gradle/versioning/versioning.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
Applies a consistent versioning scheme to all projects using this script

Uses git tags to mint versions by default.
git tags can be of a few forms:
- short sha (typical for a PR or a commit) (e.g. 38960ae)
- versioned tags (typical for a release) (e.g. v0.8.45, v0.8.45.1, v0.8.45rc1, v0.8.45.1rc4)

Produces the following variables and supports token replacement
- version: server version amenable for creating jars
- fullVersion: full version string
- cliMajorVersion: cli version amenable for binding to server as a default
0.8.44 or 0.8.44-1 (for clean tags) or 0.8.45-SNAPSHOT (for unclean repositories)

All inference can be overridden by passing in the releaseVersion property
e.g. -PreleaseVersion=0.2.3.4 will set the jar version to 0.2.3-4

**/


import org.apache.tools.ant.filters.ReplaceTokens

def detailedVersionString = "0.0.0-unknown-SNAPSHOT"
def cliMajorVersion = "0.8.42" // base default cli major version
def snapshotVersion = false
if (project.hasProperty("releaseVersion")) {
version = releaseVersion
detailedVersionString = releaseVersion
} else {
try {
// apply this plugin in a try-catch block so that we can handle cases without .git directory
apply plugin: "com.palantir.git-version"
def details = versionDetails()
detailedVersionString = gitVersion()
version = details.lastTag
version = version.startsWith("v")? version.substring(1): version
def suffix = details.isCleanTag? "": "-SNAPSHOT"
snapshotVersion = ! details.isCleanTag
}
catch (Exception e) {
e.printStackTrace()
// last fall back
version = detailedVersionString
}
}

// trim version if it is of size 4 to size 3
def versionParts = version.tokenize(".")
if (versionParts.size() > 3) {
// at-least 4 part version
// we check if the 4th part is a .0 in which case we want to create a release
if ((versionParts.size() == 4) && (versionParts[3] == '0')) {
versionParts = versionParts[0..2]
}
version = versionParts[0..2].join('.')
if (versionParts.size() > 3) {
version = version + "-" + versionParts[3..versionParts.size()-1].join('-')
}
cliMajorVersion = version
} else if (versionParts.size() == 3) {
cliMajorVersion = version
}

if (snapshotVersion) {
if (versionParts[versionParts.size()-1].isInteger()) {
def base_version = versionParts[0..versionParts.size()-2].join('.')
version = base_version + '.' + (versionParts[versionParts.size()-1].toInteger()+1).toString() + "-SNAPSHOT"
cliMajorVersion = base_version + "." + versionParts[versionParts.size()-1]
shirshanka marked this conversation as resolved.
Show resolved Hide resolved
} else {
// we are unable to part the last token as an integer, so we just append SNAPSHOT to this version
version = versionParts[0..versionParts.size()-1].join('.') + '-SNAPSHOT'
cliMajorVersion = versionParts[0..versionParts.size()-1].join('.')
}
}


processResources {
filter(ReplaceTokens, tokens:[fullVersion: detailedVersionString])
filter(ReplaceTokens, tokens:[cliMajorVersion: cliMajorVersion])
}

task printVersionDetails() {
println("fullVersion=" + detailedVersionString)
println("cliMajorVersion=" + cliMajorVersion)
println("version=" + version)
}
5 changes: 5 additions & 0 deletions metadata-service/factories/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'java'
apply from: "../../gradle/versioning/versioning.gradle"

dependencies {
compile project(':metadata-io')
Expand Down Expand Up @@ -33,3 +34,7 @@ dependencies {
testCompile externalDependency.testng

}

processResources.configure {
finalizedBy printVersionDetails // always print version details
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ authorization:

ingestion:
enabled: ${UI_INGESTION_ENABLED:true}
defaultCliVersion: '${UI_INGESTION_DEFAULT_CLI_VERSION:0.8.42}'
defaultCliVersion: '${UI_INGESTION_DEFAULT_CLI_VERSION:@cliMajorVersion@}'

telemetry:
enabledCli: ${CLI_TELEMETRY_ENABLED:true}
Expand Down