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

Change user for container on x systems #87

Merged
merged 5 commits into from
Nov 28, 2023
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
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
Loading