Skip to content

Commit 1a1f950

Browse files
committed
Merge branch '3.1' into merge-3.1-3.2-20230825
2 parents 2daae19 + cb7a99e commit 1a1f950

File tree

4 files changed

+49
-25
lines changed

4 files changed

+49
-25
lines changed

acceptancetests/jujupy/k8s_provider/eks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def log_remaining(remaining, msg=''):
152152
o = self.eksctl(
153153
'create', 'cluster',
154154
'--name', self.cluster_name,
155-
'--version', '1.19',
155+
'--version', '1.27',
156156
'--region', self.location,
157157
'--nodes', 3,
158158
'--nodes-min', 1,

cmd/juju/cloud/show.go

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func (c *showCloudCommand) Run(ctxt *cmd.Context) error {
152152
displayErr = cmd.ErrSilent
153153
} else if remoteCloud != nil {
154154
outputs = append(outputs, c.displayCloud(
155-
remoteCloud,
155+
*remoteCloud,
156156
c.CloudName,
157157
fmt.Sprintf("Cloud %q from controller %q", c.CloudName, c.ControllerName),
158158
showRemoteConfig,
@@ -167,7 +167,7 @@ func (c *showCloudCommand) Run(ctxt *cmd.Context) error {
167167
displayErr = cmd.ErrSilent
168168
} else if localCloud != nil {
169169
outputs = append(outputs, c.displayCloud(
170-
localCloud,
170+
*localCloud,
171171
c.CloudName,
172172
fmt.Sprintf("Client cloud %q", c.CloudName),
173173
c.includeConfig,
@@ -195,7 +195,7 @@ func (c *showCloudCommand) Run(ctxt *cmd.Context) error {
195195
case "display":
196196
for _, output := range outputs {
197197
var written bool
198-
if output.CloudDetails != nil {
198+
if !output.CloudDetails.Empty() {
199199
fmt.Fprintf(ctxt.Stdout, "%s:\n\n", output.Summary)
200200

201201
if err := c.out.Write(ctxt, output.CloudDetails); err != nil {
@@ -235,7 +235,7 @@ func (c *showCloudCommand) Run(ctxt *cmd.Context) error {
235235
return displayErr
236236
}
237237

238-
func (c *showCloudCommand) displayCloud(aCloud *CloudDetails, name, summary string, includeConfig bool) CloudOutput {
238+
func (c *showCloudCommand) displayCloud(aCloud CloudDetails, name, summary string, includeConfig bool) CloudOutput {
239239
aCloud.CloudType = displayCloudType(aCloud.CloudType)
240240
var config map[string]any
241241
if includeConfig {
@@ -286,10 +286,10 @@ func (c *showCloudCommand) getLocalCloud() (*CloudDetails, error) {
286286
}
287287

288288
type CloudOutput struct {
289-
Name string `yaml:"name,omitempty" json:"name,omitempty"`
290-
Summary string `yaml:"summary,omitempty" json:"summary,omitempty"`
291-
*CloudDetails `yaml:",inline" json:",inline"`
292-
Config map[string]any `yaml:"cloud-config,omitempty" json:"cloud-config,omitempty"`
289+
Name string `yaml:"name,omitempty" json:"name,omitempty"`
290+
Summary string `yaml:"summary,omitempty" json:"summary,omitempty"`
291+
CloudDetails `yaml:",inline" json:",inline"`
292+
Config map[string]any `yaml:"cloud-config,omitempty" json:"cloud-config,omitempty"`
293293
}
294294

295295
// RegionDetails holds region details.
@@ -330,6 +330,25 @@ type CloudDetails struct {
330330
SkipTLSVerify bool `yaml:"skip-tls-verify,omitempty" json:"skip-tls-verify,omitempty"`
331331
}
332332

333+
func (d *CloudDetails) Empty() bool {
334+
return d.Source == "" &&
335+
d.CloudType == "" &&
336+
d.CloudDescription == "" &&
337+
len(d.AuthTypes) == 0 &&
338+
d.Endpoint == "" &&
339+
d.IdentityEndpoint == "" &&
340+
d.StorageEndpoint == "" &&
341+
d.DefaultRegion == "" &&
342+
d.CredentialCount == 0 &&
343+
len(d.Regions) == 0 &&
344+
len(d.RegionsMap) == 0 &&
345+
len(d.Config) == 0 &&
346+
len(d.RegionConfig) == 0 &&
347+
len(d.CACredentials) == 0 &&
348+
len(d.Users) == 0 &&
349+
!d.SkipTLSVerify
350+
}
351+
333352
func makeCloudDetails(store jujuclient.CredentialGetter, cloud jujucloud.Cloud) *CloudDetails {
334353
return makeCloudDetailsForUser(store, cloudapi.CloudInfo{Cloud: cloud})
335354
}

tests/suites/cli/display_clouds.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ run_show_clouds() {
55
echo "" >>"${TEST_DIR}/juju/public-clouds.yaml"
66
echo "" >>"${TEST_DIR}/juju/credentials.yaml"
77

8-
OUT=$(JUJU_DATA="${TEST_DIR}/juju" juju clouds --client --format=json 2>/dev/null | jq '.[] | select(.defined != "built-in")')
8+
OUT=$(JUJU_DATA="${TEST_DIR}/juju" juju clouds --client --format=json | jq '.[] | select(.defined != "built-in")')
99
if [ -n "${OUT}" ]; then
1010
echo "expected empty, got ${OUT}"
1111
exit 1
1212
fi
1313

1414
cp ./tests/suites/cli/clouds/public-clouds.yaml "${TEST_DIR}"/juju/public-clouds.yaml
15-
OUT=$(JUJU_DATA="${TEST_DIR}/juju" juju clouds --client --format=json 2>/dev/null | jq '.[] | select(.defined != "built-in")')
15+
OUT=$(JUJU_DATA="${TEST_DIR}/juju" juju clouds --client --format=json | jq '.[] | select(.defined != "built-in")')
1616
if [ -n "${OUT}" ]; then
1717
echo "expected empty, got ${OUT}"
1818
exit 1
@@ -38,7 +38,7 @@ run_show_clouds() {
3838
EOF
3939
)
4040

41-
OUT=$(JUJU_DATA="${TEST_DIR}/juju" juju clouds --all --format=json 2>/dev/null | jq '.[] | select(.defined != "built-in")')
41+
OUT=$(JUJU_DATA="${TEST_DIR}/juju" juju clouds --all --format=json | jq '.[] | select(.defined != "built-in")')
4242
if [ "${OUT}" != "${EXPECTED}" ]; then
4343
echo "expected ${EXPECTED}, got ${OUT}"
4444
exit 1
@@ -52,7 +52,7 @@ run_assess_clouds() {
5252
echo "" >>"${TEST_DIR}/juju/public-clouds.yaml"
5353
echo "" >>"${TEST_DIR}/juju/credentials.yaml"
5454

55-
CLOUD_LIST=$(JUJU_DATA="${TEST_DIR}/juju" juju clouds --client --format=json 2>/dev/null | jq 'with_entries(select(.value.defined != "built-in"))')
55+
CLOUD_LIST=$(JUJU_DATA="${TEST_DIR}/juju" juju clouds --client --format=json | jq 'with_entries(select(.value.defined != "built-in"))')
5656
EXPECTED={}
5757
if [ "${CLOUD_LIST}" != "${EXPECTED}" ]; then
5858
echo "expected ${EXPECTED}, got ${CLOUD_LIST}"
@@ -79,7 +79,7 @@ EOF
7979
)
8080

8181
echo "${CLOUDS}" >>"${TEST_DIR}/juju/clouds.yaml"
82-
CLOUD_LIST=$(JUJU_DATA="${TEST_DIR}/juju" juju clouds --client --format=json 2>/dev/null | jq -S 'with_entries(select(
82+
CLOUD_LIST=$(JUJU_DATA="${TEST_DIR}/juju" juju clouds --client --format=json | jq -S 'with_entries(select(
8383
.value.defined != "built-in")) | with_entries((select(.value.defined == "local")
8484
| del(.value.defined) | del(.value.description)))')
8585
EXPECTED=$(echo "${CLOUDS}" | yq -o=j | jq -S '.[] | del(.clouds) | .[] |= ({endpoint} as $endpoint | .[] |= walk(
@@ -90,7 +90,7 @@ EOF
9090
exit 1
9191
fi
9292

93-
CLOUD_LIST=$(JUJU_DATA="${TEST_DIR}/juju" juju show-cloud finfolk-vmaas --format yaml --client 2>/dev/null | yq -o=j | jq -S 'with_entries((select(.value!= null)))')
93+
CLOUD_LIST=$(JUJU_DATA="${TEST_DIR}/juju" juju show-cloud finfolk-vmaas --format yaml --client | yq -o=j | jq -S 'with_entries((select(.value!= null)))')
9494
EXPECTED=$(
9595
cat <<'EOF' | jq -S
9696
{
@@ -100,6 +100,8 @@ EOF
100100
"defined": "local",
101101
"description": "Metal As A Service",
102102
"endpoint": "http://10.125.0.10:5240/MAAS/",
103+
"name": "finfolk-vmaas",
104+
"summary": "Client cloud \"finfolk-vmaas\"",
103105
"type": "maas"
104106
}
105107
EOF
@@ -115,7 +117,7 @@ run_controller_clouds() {
115117
echo
116118

117119
juju add-cloud my-ec2 -f "./tests/suites/cli/clouds/myclouds.yaml" --force --controller ${BOOTSTRAPPED_JUJU_CTRL_NAME}
118-
OUT=$(juju clouds --controller ${BOOTSTRAPPED_JUJU_CTRL_NAME} --format=json 2>/dev/null | jq '.[]')
120+
OUT=$(juju clouds --controller ${BOOTSTRAPPED_JUJU_CTRL_NAME} --format=json | jq '.[]')
119121

120122
EXPECTED=$(
121123
cat <<'EOF'

tests/suites/secrets_k8s/k8s.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@ run_secrets() {
66
juju --show-log add-model "model-secrets-k8s" --config secret-backend=auto
77

88
juju --show-log deploy hello-kubecon hello
9+
juju --show-log deploy nginx-ingress-integrator nginx
10+
juju --show-log integrate nginx hello
11+
juju --show-log trust nginx --scope=cluster
12+
913
wait_for "active" '.applications["hello"] | ."application-status".current'
1014
wait_for "hello" "$(idle_condition "hello" 0)"
15+
wait_for "active" '.applications["nginx"] | ."application-status".current' 900
16+
wait_for "nginx" "$(idle_condition "nginx" 1 0)"
17+
wait_for "active" "$(workload_status "nginx" 0).current"
18+
wait_for "hello" '.applications["nginx"] | .relations.ingress[0]'
1119

1220
echo "Apps deployed, creating secrets"
1321
unit_owned_full_uri=$(juju exec --unit hello/0 -- secret-add --owner unit owned-by=hello/0)
@@ -39,15 +47,6 @@ run_secrets() {
3947
echo "Checking: secret-get by label - metadata"
4048
check_contains "$(juju exec --unit hello/0 -- secret-info-get --label=hello_0 --format json | jq ".${unit_owned_short_uri}.label")" hello_0
4149

42-
juju --show-log deploy nginx-ingress-integrator nginx
43-
juju --show-log integrate nginx hello
44-
juju --show-log trust nginx --scope=cluster
45-
46-
wait_for "active" '.applications["nginx"] | ."application-status".current' 900
47-
wait_for "nginx" "$(idle_condition "nginx" 1 0)"
48-
wait_for "active" "$(workload_status "nginx" 0).current"
49-
wait_for "hello" '.applications["nginx"] | .relations.ingress[0]'
50-
5150
relation_id=$(juju --show-log show-unit hello/0 --format json | jq '."hello/0"."relation-info"[0]."relation-id"')
5251
juju exec --unit hello/0 -- secret-grant "$unit_owned_full_uri" -r "$relation_id"
5352
juju exec --unit hello/0 -- secret-grant "$app_owned_full_uri" -r "$relation_id"
@@ -87,6 +86,10 @@ run_secrets() {
8786
juju exec --unit hello/0 -- secret-remove "$app_owned_full_uri"
8887
check_contains "$(juju exec --unit hello/0 -- secret-get "$app_owned_full_uri" 2>&1)" 'not found'
8988

89+
# TODO: no need to remove-relation before destroying model once we fixed(lp:1952221).
90+
juju --show-log remove-relation nginx hello
91+
# wait for relation removed.
92+
wait_for null '.applications["nginx"] | .relations.source[0]'
9093
destroy_model "model-secrets-k8s"
9194
}
9295

0 commit comments

Comments
 (0)