Leakage of apiserver dependencies into api package

Bug #2024361 reported by Mark Laing
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Triaged
Undecided
Unassigned

Bug Description

Importing the `github.com/juju/juju/api` client package adds lots of additional dependencies. Some of which are leaked from the `apiserver` package. Try the reproducer below:

```
#! /bin/sh -e

rm -fr test-juju
mkdir test-juju
cd test-juju

go mod init test-juju

# Add simple main file that instantiates a charm client.
cat <<EOF > main.go
package main

import (
 "github.com/juju/juju/api/client/charms"
 "github.com/juju/juju/api/connector"
)

func main() {
 connector, _ := connector.NewSimple(connector.SimpleConfig{})
 conn, _ := connector.Connect()
 charms.NewClient(conn)
}
EOF

cat <<EOF >> go.mod
// Exclude some modules that cause an ambiguous import failure.
exclude (
 cloud.google.com/go v0.26.0
 cloud.google.com/go v0.65.0
 cloud.google.com/go v0.81.0
)
EOF

go mod tidy

# Some non-API packages used:
go mod why github.com/juju/juju/apiserver
go mod why github.com/juju/juju/state
go mod why github.com/juju/juju/caas

# AWS SDK is imported (I'm not sure this is intentional and should be included in client code).
go mod why github.com/aws/aws-sdk-go-v2
```

Tags: lxd-cloud
Changed in juju:
status: New → Triaged
Simon Déziel (sdeziel)
tags: added: lxd-cloud
Revision history for this message
Ian Booth (wallyworld) wrote (last edit ):

The reason the AWS SDK is imported is because the charm api has a downloader client that used the s3 API to download charm binaries. But I am not sure this is currently used, and if it is, it should be server side I think. We can look to see if this can be removed.

In the Juju main branch (4.0), many of the dependencies on apiserver, state etc have already been removed.
The only thing that currently brings these in are tests, and the affected tests will be updated soon.

The caas dependency is a type alias and will be removed as soon as support for podspec charms is dropped.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.