Skip to content

Commit

Permalink
Merge pull request #87 from IntershopCommunicationsAG/FB_change-user-…
Browse files Browse the repository at this point in the history
…for-container-on-X-systems

Change user for container on x systems
  • Loading branch information
m-raab authored Nov 28, 2023
2 parents 8ea88c7 + 35ee95e commit 684dbfd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
5 changes: 0 additions & 5 deletions README-signing.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@ gpg --quick-generate-key --batch --pinentry-mode loopback --passphrase=<passphra
which results in an output like
[source,bash]
----
gpg: key CBC0FD16BA0996A4 marked as ultimately trusted
gpg: revocation certificate stored as '/c/Users/skiesewetter/.gnupg/openpgp-revocs.d/E5D6961A381EA1E597F3D3D9CBC0FD16BA0996A4.rev'
----
Remember the last 8 digits of the key id for example
[source,bash]
----
KEY_ID=BA0996A4
----

Export the key into a file
[source,bash]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package com.intershop.gradle.icm.docker.tasks

import com.github.dockerjava.api.exception.ConflictException
import com.github.dockerjava.api.exception.NotFoundException
import org.gradle.api.model.ObjectFactory
import javax.inject.Inject

Expand All @@ -37,8 +39,13 @@ open class RemoveContainerByName
removeContainerCmd.withForce(true)

logger.quiet("Removing container with ID '${it}'('${containerName.get()}').")

removeContainerCmd.exec()
try {
removeContainerCmd.exec()
} catch(ex: ConflictException) {
logger.info("Removal of ${it} is in progress. (${ex.message})")
} catch(ex: NotFoundException) {
logger.info("Can not find ${it}. (${ex.message})")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.TaskProvider
import org.gradle.kotlin.dsl.getByType
import org.gradle.nativeplatform.platform.OperatingSystem
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform

abstract class AbstractTaskPreparer(
protected val project: Project,
Expand Down Expand Up @@ -91,5 +93,11 @@ abstract class AbstractTaskPreparer(
task.hostConfig.autoRemove.set(true)

task.containerName.set(getContainerName())

val os: OperatingSystem = DefaultNativePlatform.getCurrentOperatingSystem()
if(! os.isWindows) {
val uid = com.sun.security.auth.module.UnixSystem().uid
task.user.set(uid.toString())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ class ICMDockerPluginIntegegrationSpec extends AbstractIntegrationGroovySpec {
then:
result1.task(":startSolr").outcome == SUCCESS

/**
when:
sleep(30000)
Expand All @@ -885,7 +886,7 @@ class ICMDockerPluginIntegegrationSpec extends AbstractIntegrationGroovySpec {
then:
resultTest.task(":cleanUpSolr").outcome == SUCCESS

**/
when:
def result2 = getPreparedGradleRunner()
.withArguments("stopZK", "-s", "-i")
Expand Down

0 comments on commit 684dbfd

Please sign in to comment.