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

Plugin simple connector #1437

Draft
wants to merge 12 commits into
base: v3
Choose a base branch
from
Draft

Conversation

ale8k
Copy link
Contributor

@ale8k ale8k commented Nov 15, 2024

Description

This is a WIP and example of how we may want to structure a jujuclient wrapper. We need a way to mock the clients and I tried my best thinking of sensible solution such as... NewClient(...options) or Client.WithController(a).WithController(b).

In the end, it felt almost inevitable to return the interfaces.

Next, I thought about generating the interfaces, and had a lot of success

output_package="jujuclient2"
path_to_pacake="./internal"

for dir in modelmanager cloud controller applicationoffers; do
    find ./vendor/github.com/juju/juju/api/client/$dir -type f -name '*.go' | while read -r file; do
        base_name=$(basename "$file" .go)
        
        interface_name="${base_name^}Client"
        
        output_file="$path_to_pacake/$output_package/${interface_name}.go"
        
        echo "Processing: $file -> Interface: $interface_name -> Output: $output_file"
        
        ifacemaker -f "$file" -s Client -i "$interface_name" -p "$output_package" -o "$output_file"
    done
done

But then it occured to me this may appear confusing in the long run as to what methods are actually used within JIMM. I ultimately thought having the interfaces split, but only contain what JIMM actively requires was best.

Overall, let me know what you think on this approach and if good enough - let's try replace the Dialer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant