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

🐛 Fix parsing of compose file configs with compose v2.24.7 #563

Merged
merged 1 commit into from
Mar 10, 2024
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
7 changes: 4 additions & 3 deletions python_on_whales/components/compose/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@ class ComposeConfigService(BaseModel):
cap_add: Annotated[Optional[List[str]], Field(default_factory=list)]
cap_drop: Annotated[Optional[List[str]], Field(default_factory=list)]
cgroup_parent: Optional[str] = None
command: Optional[List[str]] = None
command: Union[List[str], str, None] = None
configs: Any = None
container_name: Optional[str] = None
depends_on: Annotated[Dict[str, DependencyCondition], Field(default_factory=dict)]
device_cgroup_rules: Annotated[List[str], Field(default_factory=list)]
devices: Any = None
environment: Optional[Dict[str, Optional[str]]] = None
entrypoint: Optional[List[str]] = None
environment: Union[Dict[str, Union[str, int, None]], List[str], None] = None
expose: Annotated[Union[List[int], List[str]], Field(default_factory=list)]
entrypoint: Union[List[str], str, None] = None
image: Optional[str] = None
labels: Annotated[Optional[Dict[str, str]], Field(default_factory=dict)]
ports: Optional[List[ComposeServicePort]] = None
Expand Down
147 changes: 147 additions & 0 deletions tests/python_on_whales/components/jsons/compose/1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
{
"name": "python-on-whales",
"networks": {
"factory-net": {
"name": "factory-net",
"ipam": {},
"external": true
}
},
"services": {
"broker": {
"command": null,
"container_name": "broker",
"depends_on": {
"zookeeper": {
"condition": "service_started",
"required": true
}
},
"entrypoint": null,
"environment": {
"KAFKA_ADVERTISED_LISTENERS": "PLAINTEXT://localhost:9092,PLAINTEXT_INTERNAL://broker:29092",
"KAFKA_BROKER_ID": "1",
"KAFKA_LISTENER_SECURITY_PROTOCOL_MAP": "PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT",
"KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR": "1",
"KAFKA_TRANSACTION_STATE_LOG_MIN_ISR": "1",
"KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR": "1",
"KAFKA_ZOOKEEPER_CONNECT": "zookeeper:2181"
},
"expose": [
"29092"
],
"healthcheck": {
"test": [
"CMD-SHELL",
"nc -z localhost 9092 || exit -1"
],
"timeout": "10s",
"interval": "5s",
"retries": 10,
"start_period": "15s"
},
"image": "confluentinc/cp-kafka:7.4.0",
"networks": {
"factory-net": null
},
"ports": [
{
"mode": "ingress",
"target": 9092,
"published": "9092",
"protocol": "tcp"
}
]
},
"ksqldb-cli": {
"command": null,
"container_name": "ksqldb-cli",
"depends_on": {
"broker": {
"condition": "service_healthy",
"required": true
},
"ksqldb-server": {
"condition": "service_healthy",
"required": true
}
},
"entrypoint": [
"bash",
"-c",
"source ./scripts/start_ksql.sh; tail -F anything"
],
"environment": {
"KSQL_START_SCRIPTS": "mtcdevices.sql"
},
"image": "confluentinc/ksqldb-cli:0.29.0",
"networks": {
"factory-net": null
},
"tty": true,
"volumes": [
{
"type": "bind",
"source": "/projects/open_source/python-on-whales/scripts",
"target": "/home/appuser/scripts",
"bind": {
"create_host_path": true
}
}
]
},
"ksqldb-server": {
"command": null,
"container_name": "ksqldb-server",
"depends_on": {
"broker": {
"condition": "service_healthy",
"required": true
}
},
"entrypoint": null,
"environment": {
"KSQL_BOOTSTRAP_SERVERS": "broker:29092",
"KSQL_KSQL_LOGGING_PROCESSING_STREAM_AUTO_CREATE": "true",
"KSQL_KSQL_LOGGING_PROCESSING_TOPIC_AUTO_CREATE": "true",
"KSQL_LISTENERS": "http://0.0.0.0:8088"
},
"hostname": "ksqldb-server",
"healthcheck": {
"test": [
"CMD-SHELL",
"nc -z localhost 8088 || exit -1"
],
"timeout": "10s",
"interval": "5s",
"retries": 10,
"start_period": "15s"
},
"image": "confluentinc/ksqldb-server:0.29.0",
"networks": {
"factory-net": null
},
"ports": [
{
"mode": "ingress",
"target": 8088,
"published": "8088",
"protocol": "tcp"
}
]
},
"zookeeper": {
"command": null,
"container_name": "zookeeper",
"entrypoint": null,
"environment": {
"ZOOKEEPER_CLIENT_PORT": "2181",
"ZOOKEEPER_TICK_TIME": "2000"
},
"image": "confluentinc/cp-zookeeper:7.4.0",
"networks": {
"factory-net": null
}
}
}
}
138 changes: 138 additions & 0 deletions tests/python_on_whales/components/jsons/compose/2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
"name": "test",
"networks": {
"default": {
"name": "test_default"
},
"factory-net": {
"external": true,
"name": "factory-net"
}
},
"services": {
"broker": {
"container_name": "broker",
"depends_on": {
"zookeeper": {
"condition": "service_started",
"required": true
}
},
"environment": {
"KAFKA_ADVERTISED_LISTENERS": "PLAINTEXT://localhost:9092,PLAINTEXT_INTERNAL://broker:29092",
"KAFKA_BROKER_ID": 1,
"KAFKA_LISTENER_SECURITY_PROTOCOL_MAP": "PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT",
"KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR": 1,
"KAFKA_TRANSACTION_STATE_LOG_MIN_ISR": 1,
"KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR": 1,
"KAFKA_ZOOKEEPER_CONNECT": "zookeeper:2181"
},
"expose": [
29092
],
"healthcheck": {
"interval": "5s",
"retries": 10,
"start_period": "15s",
"test": "nc -z localhost 9092 || exit -1",
"timeout": "10s"
},
"image": "confluentinc/cp-kafka:7.4.0",
"networks": {
"factory-net": null
},
"ports": [
{
"mode": "ingress",
"protocol": "tcp",
"published": "9092",
"target": 9092
}
]
},
"ksqldb-cli": {
"container_name": "ksqldb-cli",
"depends_on": {
"broker": {
"condition": "service_healthy",
"required": true
},
"ksqldb-server": {
"condition": "service_healthy",
"required": true
}
},
"entrypoint": "bash -c \"source ./scripts/start_ksql.sh; tail -F anything\"",
"environment": [
"KSQL_START_SCRIPTS=mtcdevices.sql"
],
"image": "confluentinc/ksqldb-cli:0.29.0",
"networks": {
"factory-net": null
},
"tty": true,
"volumes": [
{
"bind": {
"create_host_path": true
},
"source": "/tmp/test/scripts",
"target": "/home/appuser/scripts",
"type": "bind"
}
]
},
"ksqldb-server": {
"command": [
"hello",
"world"
],
"container_name": "ksqldb-server",
"depends_on": {
"broker": {
"condition": "service_healthy",
"required": true
}
},
"environment": {
"KSQL_BOOTSTRAP_SERVERS": "broker:29092",
"KSQL_KSQL_LOGGING_PROCESSING_STREAM_AUTO_CREATE": "true",
"KSQL_KSQL_LOGGING_PROCESSING_TOPIC_AUTO_CREATE": "true",
"KSQL_LISTENERS": "http://0.0.0.0:8088"
},
"healthcheck": {
"interval": "5s",
"retries": 10,
"start_period": "15s",
"test": "nc -z localhost 8088 || exit -1",
"timeout": "10s"
},
"hostname": "ksqldb-server",
"image": "confluentinc/ksqldb-server:0.29.0",
"networks": {
"factory-net": null
},
"ports": [
{
"mode": "ingress",
"protocol": "tcp",
"published": "8088",
"target": 8088
}
]
},
"zookeeper": {
"command": "hello world",
"container_name": "zookeeper",
"environment": {
"ZOOKEEPER_CLIENT_PORT": 2181,
"ZOOKEEPER_TICK_TIME": 2000
},
"image": "confluentinc/cp-zookeeper:7.4.0",
"networks": {
"factory-net": null
}
}
},
"version": "3.9"
}