-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
155 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...ng-setup-impl/src/main/groovy/org/pongasoft/glu/packaging/setup/ConsoleCliPackager.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (c) 2013 Yan Pujante | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package org.pongasoft.glu.packaging.setup | ||
|
||
import org.linkedin.util.io.resource.Resource | ||
import org.pongasoft.glu.provisioner.core.metamodel.GluMetaModel | ||
|
||
/** | ||
* @author yan@pongasoft.com */ | ||
public class ConsoleCliPackager extends BasePackager | ||
{ | ||
GluMetaModel metaModel | ||
|
||
PackagedArtifact createPackage() | ||
{ | ||
String packageName = inputPackage.filename | ||
|
||
def tokens = [ | ||
gluMetaModel: metaModel, | ||
] | ||
tokens[PACKAGER_CONTEXT_KEY] = packagerContext | ||
|
||
Resource packagePath = outputFolder.createRelative(packageName) | ||
|
||
if(!dryMode) | ||
{ | ||
copyInputPackage(packagePath) | ||
configure(packagePath, tokens) | ||
} | ||
|
||
return new PackagedArtifact(location: packagePath) | ||
} | ||
|
||
Resource configure(Resource packagePath, Map tokens) | ||
{ | ||
processConfigs('console-cli', tokens, packagePath) | ||
return packagePath | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...ngasoft.glu.packaging-setup-impl/src/test/groovy/test/setup/TestConsoleCliPackager.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2013 Yan Pujante | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package test.setup | ||
|
||
import org.linkedin.glu.groovy.utils.shell.Shell | ||
import org.linkedin.glu.groovy.utils.shell.ShellImpl | ||
import org.pongasoft.glu.packaging.setup.ConsoleCliPackager | ||
import org.pongasoft.glu.packaging.setup.PackagedArtifact | ||
|
||
/** | ||
* @author yan@pongasoft.com */ | ||
public class TestConsoleCliPackager extends BasePackagerTest | ||
{ | ||
public void testTutorialModel() | ||
{ | ||
ShellImpl.createTempShell { Shell shell -> | ||
|
||
def inputPackage = shell.mkdirs("/dist/org.linkedin.glu.console-cli-${GLU_VERSION}") | ||
shell.saveContent(inputPackage.createRelative('README.md'), "this is the readme") | ||
shell.saveContent(inputPackage.createRelative('lib/acme.py'), "this is the python") | ||
|
||
def packager = new ConsoleCliPackager(packagerContext: createPackagerContext(shell), | ||
outputFolder: shell.mkdirs('/out'), | ||
inputPackage: inputPackage, | ||
configsRoots: copyConfigs(shell.toResource('/configs')), | ||
metaModel: testModel) | ||
|
||
PackagedArtifact artifact = packager.createPackage() | ||
|
||
assertEquals(shell.toResource("/out/org.linkedin.glu.console-cli-${GLU_VERSION}"), artifact.location) | ||
assertNull(artifact.host) | ||
assertEquals(0, artifact.port) | ||
|
||
def expectedResources = | ||
[ | ||
"/README.md": 'this is the readme', | ||
"/lib": DIRECTORY, | ||
"/lib/acme.py": 'this is the python', | ||
] | ||
|
||
checkPackageContent(expectedResources, artifact.location) | ||
} | ||
} | ||
} |