From 65e294c296d3ccdd27f26938f75fc334d97b48bb Mon Sep 17 00:00:00 2001 From: gmpassos Date: Sat, 18 May 2024 20:27:52 -0300 Subject: [PATCH 1/3] v2.1.6 - swiss_knife: ^3.2.0 - mercury_client: ^2.2.2 - apollovm: ^0.0.53 - test: ^1.25.5 - path: ^1.9.0 --- CHANGELOG.md | 8 ++++++++ lib/src/docker_commander_base.dart | 2 +- pubspec.yaml | 12 ++++++------ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69b3d28..c997cca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 2.1.6 + +- swiss_knife: ^3.2.0 +- mercury_client: ^2.2.2 +- apollovm: ^0.0.53 +- test: ^1.25.5 +- path: ^1.9.0 + ## 2.1.5 - apollovm: ^0.0.45 diff --git a/lib/src/docker_commander_base.dart b/lib/src/docker_commander_base.dart index 46a11dc..cad71a9 100644 --- a/lib/src/docker_commander_base.dart +++ b/lib/src/docker_commander_base.dart @@ -7,7 +7,7 @@ import 'docker_commander_host.dart'; class DockerCommander extends DockerCMDExecutor { /// The current version of `docker_commander` package. // ignore: non_constant_identifier_names - static final String VERSION = '2.1.5'; + static final String VERSION = '2.1.6'; /// Docker machine host. final DockerHost dockerHost; diff --git a/pubspec.yaml b/pubspec.yaml index 184210b..e351657 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: docker_commander description: A Docker manager for local and remote host machines. Works with personalized containers and pre-configured popular containers, like PostgreSQL, Apache HTTPD and NGINX. -version: 2.1.5 +version: 2.1.6 homepage: https://github.com/gmpassos/docker_commander environment: @@ -11,18 +11,18 @@ executables: docker_commander_console: dependencies: - swiss_knife: ^3.1.5 - mercury_client: ^2.2.0 + swiss_knife: ^3.2.0 + mercury_client: ^2.2.2 logging: ^1.2.0 collection: ^1.18.0 - apollovm: ^0.0.45 + apollovm: ^0.0.53 dev_dependencies: lints: ^2.1.1 - test: ^1.24.6 + test: ^1.25.5 dependency_validator: ^3.2.3 pubspec: ^2.3.0 - path: ^1.8.3 + path: ^1.9.0 #dependency_overrides: # swiss_knife: From 87046774e1a57c17c78e161b0f2fb974230064c8 Mon Sep 17 00:00:00 2001 From: gmpassos Date: Sat, 18 May 2024 20:43:22 -0300 Subject: [PATCH 2/3] v2.1.6 - `PostgreSQLContainerConfig`, `MySQLContainerConfig`, `ApacheHttpdContainerConfig`, `NginxContainerConfig`: - Constructor: expose `version` parameter. - `MySQLContainerConfig`: - Fix `_buildImageArgs` for version `8.4.0`+. - swiss_knife: ^3.2.0 - mercury_client: ^2.2.2 - apollovm: ^0.0.53 - version: ^3.0.2 - test: ^1.25.5 - path: ^1.9.0 --- CHANGELOG.md | 7 +++++ lib/src/docker_commander_containers.dart | 37 +++++++++++++++++++----- lib/src/docker_commander_nginx.dart | 4 +-- pubspec.yaml | 1 + 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c997cca..f9262c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,15 @@ ## 2.1.6 +- `PostgreSQLContainerConfig`, `MySQLContainerConfig`, `ApacheHttpdContainerConfig`, `NginxContainerConfig`: + - Constructor: expose `version` parameter. + +- `MySQLContainerConfig`: + - Fix `_buildImageArgs` for version `8.4.0`+. + - swiss_knife: ^3.2.0 - mercury_client: ^2.2.2 - apollovm: ^0.0.53 +- version: ^3.0.2 - test: ^1.25.5 - path: ^1.9.0 diff --git a/lib/src/docker_commander_containers.dart b/lib/src/docker_commander_containers.dart index 9836b20..b876b7c 100644 --- a/lib/src/docker_commander_containers.dart +++ b/lib/src/docker_commander_containers.dart @@ -1,4 +1,5 @@ import 'package:swiss_knife/swiss_knife.dart'; +import 'package:version/version.dart'; import 'docker_commander_base.dart'; import 'docker_commander_host.dart'; @@ -147,13 +148,13 @@ class PostgreSQLContainerConfig String pgDatabase; PostgreSQLContainerConfig( - {this.pgUser = 'postgres', + {super.version = 'latest', + this.pgUser = 'postgres', this.pgPassword = 'postgres', this.pgDatabase = 'postgres', int? hostPort}) : super( 'postgres', - version: 'latest', hostPorts: hostPort != null ? [hostPort] : null, containerPorts: [5432], environment: { @@ -271,6 +272,7 @@ class MySQLContainerConfig extends DockerContainerConfig { String dbName; MySQLContainerConfig({ + super.version = 'latest', this.dbUser = 'myuser', this.dbPassword = 'mypass', this.dbName = 'mydb', @@ -279,11 +281,10 @@ class MySQLContainerConfig extends DockerContainerConfig { List? daemonArguments, }) : super( 'mysql', - version: 'latest', hostPorts: hostPort != null ? [hostPort] : null, containerPorts: [3306], imageArgs: _buildImageArgs( - forceNativePasswordAuthentication, daemonArguments), + version, forceNativePasswordAuthentication, daemonArguments), environment: { 'MYSQL_USER': dbUser, 'MYSQL_PASSWORD': dbPassword, @@ -312,12 +313,16 @@ class MySQLContainerConfig extends DockerContainerConfig { } } - static List? _buildImageArgs( + static List? _buildImageArgs(String? version, bool forceNativePasswordAuthentication, List? daemonArguments) { var args = []; if (forceNativePasswordAuthentication) { - args.add('--default-authentication-plugin=mysql_native_password'); + if (_isVersionGreaterThan_8_4_0(version)) { + args.add('--mysql-native-password=ON'); + } else { + args.add('--default-authentication-plugin=mysql_native_password'); + } } if (daemonArguments != null) { @@ -327,6 +332,23 @@ class MySQLContainerConfig extends DockerContainerConfig { return args.isNotEmpty ? args : null; } + static bool _isVersionGreaterThan_8_4_0(String? version) { + version = version?.trim(); + + if (version == null || + version.isEmpty || + version.toLowerCase() == 'latest') { + return true; + } + + try { + var ver = Version.parse(version); + return ver >= Version(8, 4, 0); + } catch (_) { + return false; + } + } + @override MySQLContainer? instantiateDockerContainer(DockerRunner runner) => MySQLContainer(this, runner); @@ -398,10 +420,9 @@ class MySQLContainer extends DockerContainer { /// Apache HTTPD pre-configured container. class ApacheHttpdContainerConfig extends DockerContainerConfig { - ApacheHttpdContainerConfig({int? hostPort}) + ApacheHttpdContainerConfig({super.version = 'latest', int? hostPort}) : super( 'httpd', - version: 'latest', hostPorts: hostPort != null ? [hostPort] : null, containerPorts: [80], outputAsLines: true, diff --git a/lib/src/docker_commander_nginx.dart b/lib/src/docker_commander_nginx.dart index 7fec7f2..47c3a73 100644 --- a/lib/src/docker_commander_nginx.dart +++ b/lib/src/docker_commander_nginx.dart @@ -37,11 +37,11 @@ class NginxContainerConfig extends DockerContainerConfig { final String configPath; - NginxContainerConfig(this.config, {int? hostPort, String? configPath}) + NginxContainerConfig(this.config, + {super.version = 'latest', int? hostPort, String? configPath}) : configPath = configPath ?? '/etc/nginx/nginx.conf', super( 'nginx', - version: 'latest', hostPorts: hostPort != null ? [hostPort] : null, containerPorts: [80], outputAsLines: true, diff --git a/pubspec.yaml b/pubspec.yaml index e351657..623c8b8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,6 +16,7 @@ dependencies: logging: ^1.2.0 collection: ^1.18.0 apollovm: ^0.0.53 + version: ^3.0.2 dev_dependencies: lints: ^2.1.1 From d632230e5a3cf77a14462b80e3c8e3976ed29f03 Mon Sep 17 00:00:00 2001 From: gmpassos Date: Sat, 18 May 2024 20:49:52 -0300 Subject: [PATCH 3/3] docker_commander_containers_test.dart --- test/docker_commander_containers_test.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/docker_commander_containers_test.dart b/test/docker_commander_containers_test.dart index b3f8c9b..c24db73 100644 --- a/test/docker_commander_containers_test.dart +++ b/test/docker_commander_containers_test.dart @@ -116,11 +116,13 @@ Future main() async { expect(exitCode == 0 || exitCode == 137, isTrue); }); - test('MySQL', () async { + testMySQL({bool forceNativePasswordAuthentication = false}) async { var freeListenPort = await getFreeListenPort(startPort: 3106, endPort: 3206); - var config = MySQLContainerConfig(hostPort: freeListenPort); + var config = MySQLContainerConfig( + hostPort: freeListenPort, + forceNativePasswordAuthentication: forceNativePasswordAuthentication); var dockerContainer = await config.run(dockerCommander); _log.info(dockerContainer); @@ -184,7 +186,12 @@ Future main() async { _log.info('exitCode: $exitCode'); expect(exitCode == 0, isTrue); - }); + } + + test('MySQL', () async => testMySQL()); + + test('MySQL', + () async => testMySQL(forceNativePasswordAuthentication: true)); test('Apache Httpd', () async { var freeListenPort =