Skip to content

Commit e233dcf

Browse files
lengauerinecon
authored andcommitted
feat(templates): change the templates to use platforms notation (canonical#2200)
This updates the templates to use the `platforms` notation rather than `bases`. It keeps them building on Jammy for the timebeing though. CRAFT-4150 Fixes canonical#2167
1 parent 7d9c1ea commit e233dcf

File tree

5 files changed

+68
-116
lines changed

5 files changed

+68
-116
lines changed
Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
11
# This file configures Charmcraft.
2-
# See https://juju.is/docs/sdk/charmcraft-config for guidance.
3-
4-
# (Required)
5-
name: {{ name }}
6-
7-
8-
# (Required)
2+
# See https://canonical-charmcraft.readthedocs-hosted.com/en/stable/reference/files/charmcraft-yaml-file/
93
type: charm
10-
11-
12-
# (Recommended)
4+
name: {{ name }}
135
title: Charm Template
14-
15-
16-
# (Required)
176
summary: A very short one-line summary of the charm.
18-
19-
20-
# (Required)
217
description: |
228
A single sentence that says what the charm is, concisely and memorably.
239

@@ -27,22 +13,26 @@ description: |
2713

2814
Finally, a paragraph that describes whom the charm is useful for.
2915

16+
# Documentation:
17+
# https://canonical-charmcraft.readthedocs-hosted.com/en/stable/howto/build-guides/select-platforms/
18+
19+
platforms:
20+
amd64:
21+
arm64:
3022

31-
# (Required for 'charm' type)
32-
bases:
33-
- build-on:
34-
- name: ubuntu
35-
channel: "22.04"
36-
run-on:
37-
- name: ubuntu
38-
channel: "22.04"
3923

24+
parts:
25+
charm:
26+
plugin: charm
27+
source: .
4028

4129
# (Optional) Configuration options for the charm
4230
# This config section defines charm config options, and populates the Configure
4331
# tab on Charmhub.
44-
# More information on this section at https://juju.is/docs/sdk/charmcraft-yaml#heading--config
45-
# General configuration documentation: https://juju.is/docs/sdk/config
32+
# More information on this section at:
33+
# https://canonical-charmcraft.readthedocs-hosted.com/en/stable/reference/files/charmcraft-yaml-file/#config
34+
# General configuration documentation:
35+
# https://canonical-juju.readthedocs-hosted.com/en/latest/user/reference/configuration/#application-configuration
4636
config:
4737
options:
4838
# An example config option to customise the log level of the workload
@@ -55,23 +45,22 @@ config:
5545
type: string
5646

5747

58-
# The containers and resources metadata apply to Kubernetes charms only.
59-
# See https://juju.is/docs/sdk/metadata-reference for a checklist and guidance.
60-
6148
# Your workload’s containers.
49+
# https://canonical-charmcraft.readthedocs-hosted.com/en/stable/reference/files/charmcraft-yaml-file/#containers
6250
containers:
6351
some-container:
6452
resource: some-container-image
6553

6654

6755
# This field populates the Resources tab on Charmhub.
56+
# https://canonical-charmcraft.readthedocs-hosted.com/en/stable/reference/files/charmcraft-yaml-file/#resources
6857
resources:
6958
# An OCI image resource for each container listed above.
7059
# You may remove this if your charm will run without a workload sidecar container.
7160
some-container-image:
7261
type: oci-image
7362
description: OCI image for the 'some-container' container
74-
# The upstream-source field is ignored by Juju. It is included here as a reference
75-
# so the integration testing suite knows which image to deploy during testing. This field
76-
# is also used by the 'canonical/charming-actions' Github action for automated releasing.
63+
# The upstream-source field is ignored by Charmcraft and Juju, but it can be
64+
# useful to developers in identifying the source of the OCI image. It is also
65+
# used by the 'canonical/charming-actions' Github action for automated releases.
7766
upstream-source: some-repo/some-image:some-tag

charmcraft/templates/init-machine/charmcraft.yaml.j2

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
11
# This file configures Charmcraft.
2-
# See https://juju.is/docs/sdk/charmcraft-config for guidance.
3-
4-
# (Required)
5-
name: {{ name }}
6-
7-
8-
# (Required)
2+
# See https://canonical-charmcraft.readthedocs-hosted.com/en/stable/reference/files/charmcraft-yaml-file/
93
type: charm
10-
11-
12-
# (Recommended)
4+
name: {{ name }}
135
title: Charm Template
14-
15-
16-
# (Required)
176
summary: A very short one-line summary of the charm.
18-
19-
20-
# (Required)
217
description: |
228
A single sentence that says what the charm is, concisely and memorably.
239

@@ -27,22 +13,26 @@ description: |
2713

2814
Finally, a paragraph that describes whom the charm is useful for.
2915

16+
# Documentation:
17+
# https://canonical-charmcraft.readthedocs-hosted.com/en/stable/howto/build-guides/select-platforms/
18+
19+
platforms:
20+
amd64:
21+
arm64:
3022

31-
# (Required for 'charm' type)
32-
bases:
33-
- build-on:
34-
- name: ubuntu
35-
channel: "22.04"
36-
run-on:
37-
- name: ubuntu
38-
channel: "22.04"
3923

24+
parts:
25+
charm:
26+
plugin: charm
27+
source: .
4028

4129
# (Optional) Configuration options for the charm
4230
# This config section defines charm config options, and populates the Configure
4331
# tab on Charmhub.
44-
# More information on this section at https://juju.is/docs/sdk/charmcraft-yaml#heading--config
45-
# General configuration documentation: https://juju.is/docs/sdk/config
32+
# More information on this section at:
33+
# https://canonical-charmcraft.readthedocs-hosted.com/en/stable/reference/files/charmcraft-yaml-file/#config
34+
# General configuration documentation:
35+
# https://canonical-juju.readthedocs-hosted.com/en/latest/user/reference/configuration/#application-configuration
4636
config:
4737
options:
4838
# An example config option to customise the log level of the workload
Lines changed: 26 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
11
# This file configures Charmcraft.
2-
# See https://juju.is/docs/sdk/charmcraft-config for guidance.
3-
4-
# (Required)
5-
# The charm package name, no spaces
6-
# See https://juju.is/docs/sdk/naming#heading--naming-charms for guidance.
7-
name: {{ name }}
8-
9-
10-
# (Required)
11-
# The charm type, either 'charm' or 'bundle'.
2+
# See https://canonical-charmcraft.readthedocs-hosted.com/en/stable/reference/files/charmcraft-yaml-file/
123
type: charm
13-
14-
15-
# (Recommended)
4+
name: {{ name }}
165
title: Charm Template
17-
18-
19-
# (Required)
206
summary: A very short one-line summary of the charm.
21-
22-
23-
# (Required)
247
description: |
258
A single sentence that says what the charm is, concisely and memorably.
269

@@ -30,24 +13,26 @@ description: |
3013

3114
Finally, a paragraph that describes whom the charm is useful for.
3215

16+
# Documentation:
17+
# https://canonical-charmcraft.readthedocs-hosted.com/en/stable/howto/build-guides/select-platforms/
18+
19+
platforms:
20+
amd64:
21+
arm64:
3322

34-
# (Required for 'charm' type)
35-
# A list of environments (OS version and architecture) where charms must be
36-
# built on and run on.
37-
bases:
38-
- build-on:
39-
- name: ubuntu
40-
channel: "22.04"
41-
run-on:
42-
- name: ubuntu
43-
channel: "22.04"
4423

24+
parts:
25+
charm:
26+
plugin: charm
27+
source: .
4528

4629
# (Optional) Configuration options for the charm
4730
# This config section defines charm config options, and populates the Configure
4831
# tab on Charmhub.
49-
# More information on this section at https://juju.is/docs/sdk/charmcraft-yaml#heading--config
50-
# General configuration documentation: https://juju.is/docs/sdk/config
32+
# More information on this section at:
33+
# https://canonical-charmcraft.readthedocs-hosted.com/en/stable/reference/files/charmcraft-yaml-file/#config
34+
# General configuration documentation:
35+
# https://canonical-juju.readthedocs-hosted.com/en/latest/user/reference/configuration/#application-configuration
5136
config:
5237
options:
5338
# An example config option to customise the log level of the workload
@@ -60,26 +45,22 @@ config:
6045
type: string
6146

6247

63-
# The containers and resources metadata apply to Kubernetes charms only.
64-
# See https://juju.is/docs/sdk/metadata-reference for a checklist and guidance.
65-
# Remove them if not required.
66-
67-
6848
# Your workload’s containers.
49+
# https://canonical-charmcraft.readthedocs-hosted.com/en/stable/reference/files/charmcraft-yaml-file/#containers
6950
containers:
70-
httpbin:
71-
resource: httpbin-image
51+
some-container:
52+
resource: some-container-image
7253

7354

7455
# This field populates the Resources tab on Charmhub.
56+
# https://canonical-charmcraft.readthedocs-hosted.com/en/stable/reference/files/charmcraft-yaml-file/#resources
7557
resources:
7658
# An OCI image resource for each container listed above.
7759
# You may remove this if your charm will run without a workload sidecar container.
78-
httpbin-image:
60+
some-container-image:
7961
type: oci-image
80-
description: OCI image for httpbin
81-
# The upstream-source field is ignored by Juju. It is included here as a
82-
# reference so the integration testing suite knows which image to deploy
83-
# during testing. This field is also used by the 'canonical/charming-actions'
84-
# Github action for automated releasing.
85-
upstream-source: kennethreitz/httpbin
62+
description: OCI image for the 'some-container' container
63+
# The upstream-source field is ignored by Charmcraft and Juju, but it can be
64+
# useful to developers in identifying the source of the OCI image. It is also
65+
# used by the 'canonical/charming-actions' Github action for automated releases.
66+
upstream-source: some-repo/some-image:some-tag

tests/spread/smoketests/different-dependencies/task.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@ include:
55

66
prepare: |
77
tests.pkgs install unzip
8+
snap install --devmode --channel=v4/stable yq
89
charmcraft init --project-dir=charm
910
cd charm
1011
echo "bump2version" > req.txt
11-
12-
cat <<- EOF >> charmcraft.yaml
13-
parts:
14-
charm:
15-
charm-binary-python-packages: [pytest]
16-
charm-python-packages: [fades]
17-
charm-requirements: [req.txt]
18-
EOF
12+
yq '.parts.charm = {"charm-binary-python-packages": ["pytest"], "charm-python-packages": ["fades"], "charm-requirements": ["req.txt"]}' \
13+
< charmcraft.yaml > charmcraft-2.yaml
14+
rm charmcraft.yaml
15+
mv charmcraft-2.yaml charmcraft.yaml
1916
2017
restore: |
2118
pushd charm

tests/spread/smoketests/pinned-dependencies/task.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ prepare: |
88
charmcraft init --project-dir=charm
99
cd charm
1010
echo "ops==2.0.0" > requirements.txt
11-
cat <<- EOF >> charmcraft.yaml
12-
parts:
13-
charm:
14-
charm-requirements: [requirements.txt]
15-
EOF
1611
mkdir -p lib/charms/charm/v0/
1712
cat <<- EOF > lib/charms/charm/v0/my_lib.py
1813
PYDEPS = ["ops"]

0 commit comments

Comments
 (0)