diff --git a/go.mod b/go.mod index ade08dba0..a4c537469 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/juju/cmd/v3 v3.0.14 github.com/juju/errors v1.0.0 github.com/juju/gnuflag v1.0.0 - github.com/juju/juju v0.0.0-20240304110523-55fb5d03683b + github.com/juju/juju v0.0.0-20240423234833-93553287462a github.com/juju/loggo v1.0.0 github.com/juju/mgomonitor v0.0.0-20181029151116-52206bb0cd31 github.com/juju/names/v4 v4.0.0 @@ -104,7 +104,10 @@ require ( github.com/aws/smithy-go v1.19.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bmizerany/pat v0.0.0-20210406213842-e4b6760bdd6f // indirect + github.com/canonical/go-flags v0.0.0-20230403090104-105d09a091b8 // indirect github.com/canonical/lxd v0.0.0-20231214113525-e676fc63c50a // indirect + github.com/canonical/pebble v1.10.2 // indirect + github.com/canonical/x-go v0.0.0-20230522092633-7947a7587f5b // indirect github.com/cenkalti/backoff/v3 v3.2.2 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cjlapao/common-go v0.0.39 // indirect @@ -144,6 +147,7 @@ require ( github.com/google/s2a-go v0.1.7 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect github.com/googleapis/gax-go/v2 v2.12.0 // indirect + github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/schema v1.2.1 // indirect github.com/gorilla/securecookie v1.1.2 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect @@ -173,7 +177,7 @@ require ( github.com/juju/blobstore/v3 v3.0.2 // indirect github.com/juju/clock v1.0.3 // indirect github.com/juju/collections v1.0.4 // indirect - github.com/juju/description/v5 v5.0.0 // indirect + github.com/juju/description/v5 v5.0.4 // indirect github.com/juju/featureflag v1.0.0 // indirect github.com/juju/go4 v0.0.0-20160222163258-40d72ab9641a // indirect github.com/juju/gojsonpointer v0.0.0-20150204194629-afe8b77aa08f // indirect @@ -190,7 +194,7 @@ require ( github.com/juju/mutex/v2 v2.0.0 // indirect github.com/juju/naturalsort v1.0.0 // indirect github.com/juju/os/v2 v2.2.3 // indirect - github.com/juju/packaging/v2 v2.0.1 // indirect + github.com/juju/packaging/v3 v3.0.0 // indirect github.com/juju/persistent-cookiejar v1.0.0 // indirect github.com/juju/proxy v1.0.0 // indirect github.com/juju/pubsub/v2 v2.0.0 // indirect @@ -202,7 +206,7 @@ require ( github.com/juju/schema v1.2.0 // indirect github.com/juju/txn/v3 v3.0.2 // indirect github.com/juju/usso v1.0.1 // indirect - github.com/juju/utils/v3 v3.1.0 // indirect + github.com/juju/utils/v3 v3.1.1 // indirect github.com/juju/viddy v0.0.0-beta5 // indirect github.com/juju/webbrowser v1.0.0 // indirect github.com/juju/worker/v3 v3.5.0 // indirect @@ -260,6 +264,7 @@ require ( github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pkg/sftp v1.13.6 // indirect + github.com/pkg/term v1.1.0 // indirect github.com/pkg/xattr v0.4.9 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_model v0.5.0 // indirect @@ -299,15 +304,17 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.22.0 // indirect golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect + golang.org/x/mod v0.14.0 // indirect golang.org/x/sys v0.19.0 // indirect golang.org/x/term v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect + golang.org/x/tools v0.16.1 // indirect google.golang.org/api v0.154.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect google.golang.org/grpc v1.59.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/gobwas/glob.v0 v0.2.3 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index 375f90f37..878eda19b 100644 --- a/go.sum +++ b/go.sum @@ -145,12 +145,18 @@ github.com/bmizerany/pat v0.0.0-20210406213842-e4b6760bdd6f h1:gOO/tNZMjjvTKZWpY github.com/bmizerany/pat v0.0.0-20210406213842-e4b6760bdd6f/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= github.com/canonical/go-dqlite v1.21.0 h1:4gLDdV2GF+vg0yv9Ff+mfZZNQ1JGhnQ3GnS2GeZPHfA= github.com/canonical/go-dqlite v1.21.0/go.mod h1:Uvy943N8R4CFUAs59A1NVaziWY9nJ686lScY7ywurfg= +github.com/canonical/go-flags v0.0.0-20230403090104-105d09a091b8 h1:zGaJEJI9qPVyM+QKFJagiyrM91Ke5S9htoL1D470g6E= +github.com/canonical/go-flags v0.0.0-20230403090104-105d09a091b8/go.mod h1:ZZFeR9K9iGgpwOaLYF9PdT44/+lfSJ9sQz3B+SsGsYU= github.com/canonical/go-service v1.0.0 h1:TF6TsEp04xAoI5pPoWjTYmEwLjbPATSnHEyeJCvzElg= github.com/canonical/go-service v1.0.0/go.mod h1:GzNLXpkGdglL0kjREXoLXj2rB2Qx+EvAGncRDqCENYQ= github.com/canonical/lxd v0.0.0-20231214113525-e676fc63c50a h1:Tfo/MzXK5GeG7gzSHqxGeY/669Mhh5ea43dn1mRDnk8= github.com/canonical/lxd v0.0.0-20231214113525-e676fc63c50a/go.mod h1:UxfHGKFoRjgu1NUA9EFiR++dKvyAiT0h9HT0ffMlzjc= github.com/canonical/ofga v0.10.0 h1:DHXhG/DAXWWQT/I+2jzr4qm0uTIYrILmtMxd6ZqmEzE= github.com/canonical/ofga v0.10.0/go.mod h1:u4Ou8dbIhO7FmVlT7W3rX2roD9AOGz/CqmGh7AdF0Lo= +github.com/canonical/pebble v1.10.2 h1:TG0RYLqH+WEjnxsTB1JbaW0wzeygG0/dPHEEFQKn2JE= +github.com/canonical/pebble v1.10.2/go.mod h1:BXpt85cFqrBgACeVRrTQ7JxZIdnGILv32V7mAfDcGFc= +github.com/canonical/x-go v0.0.0-20230522092633-7947a7587f5b h1:Da2fardddn+JDlVEYtrzBLTtyzoyU3nIS0Cf0GvjmwU= +github.com/canonical/x-go v0.0.0-20230522092633-7947a7587f5b/go.mod h1:upTK9n6rlqITN9rCN69hdreI37dRDFUk2thlGGD5Cg8= github.com/cenkalti/backoff/v3 v3.0.0/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs= github.com/cenkalti/backoff/v3 v3.2.2 h1:cfUAAO3yvKMYKPrvhDuHSwQnhZNk/RMHKdZqKTxfm6M= github.com/cenkalti/backoff/v3 v3.2.2/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs= @@ -588,8 +594,8 @@ github.com/juju/collections v0.0.0-20220203020748-febd7cad8a7a/go.mod h1:JWeZdyt github.com/juju/collections v1.0.0/go.mod h1:JWeZdyttIEbkR51z2S13+J+aCuHVe0F6meRy+P0YGDo= github.com/juju/collections v1.0.4 h1:GjL+aN512m2rVDqhPII7P6qB0e+iYFubz8sqBhZaZtk= github.com/juju/collections v1.0.4/go.mod h1:hVrdB0Zwq9wIU1Fl6ItD2+UETeNeOEs+nGvJufVe+0c= -github.com/juju/description/v5 v5.0.0 h1:koySpaGHVTvoHlr+siRLxVKS/Jzilud5iGzjE7tldks= -github.com/juju/description/v5 v5.0.0/go.mod h1:TQsp2Z56EVab7onQY2/O6tLHznovAcckyLz/DgDfVPY= +github.com/juju/description/v5 v5.0.4 h1:qA35hRglZ47j1mmo9zUM9R+2WSDCH5dvL5ik7gA2aVE= +github.com/juju/description/v5 v5.0.4/go.mod h1:TQsp2Z56EVab7onQY2/O6tLHznovAcckyLz/DgDfVPY= github.com/juju/errors v0.0.0-20150916125642-1b5e39b83d18/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= github.com/juju/errors v0.0.0-20200330140219-3fe23663418f/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= github.com/juju/errors v0.0.0-20210818161939-5560c4c073ff/go.mod h1:i1eL7XREII6aHpQ2gApI/v6FkVUDEBremNkcBCKYAcY= @@ -618,8 +624,8 @@ github.com/juju/idmclient/v2 v2.0.0 h1:PsGa092JGy6iFNHZCcao+bigVsTyz1C+tHNRdYmKv github.com/juju/idmclient/v2 v2.0.0/go.mod h1:EOiFbPmnkqKvCUS/DHpDRWhL7eKF0AJaTvMjIYlIUak= github.com/juju/jsonschema v1.0.0 h1:2ScR9hhVdHxft+Te3fnclVx61MmlikHNEOirTGi+hV4= github.com/juju/jsonschema v1.0.0/go.mod h1:SlFW+jFtpWX0P4Tb+zTTPR4ufttLrnJIdQPePxVEfkM= -github.com/juju/juju v0.0.0-20240304110523-55fb5d03683b h1:rowVYnJXJQup9dFBNLx3PCa9NWZ63jgewlwHB2HDBEk= -github.com/juju/juju v0.0.0-20240304110523-55fb5d03683b/go.mod h1:lG1192+QZsfFbVI+3Vg9KDv+F2tGc+8marXD9E1Vnuc= +github.com/juju/juju v0.0.0-20240423234833-93553287462a h1:ElPIIOVZ50QJjwXukV1mRRdW9kGXxvK8MZz6iP72su8= +github.com/juju/juju v0.0.0-20240423234833-93553287462a/go.mod h1:LN4FXgbHGi5VsBjy0gs+xXDWM0eiOHaAyl6QDF7bCjY= github.com/juju/loggo v0.0.0-20170605014607-8232ab8918d9/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= github.com/juju/loggo v0.0.0-20190212223446-d976af380377/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= github.com/juju/loggo v0.0.0-20200526014432-9ce3a2e09b5e/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= @@ -652,8 +658,8 @@ github.com/juju/naturalsort v1.0.0 h1:kGmUUy3h8mJ5/SJYaqKOBR3f3owEd5R52Lh+Tjg/dN github.com/juju/naturalsort v1.0.0/go.mod h1:Zqa/vGkXr78k47zM6tFmU9phhxKz/PIdqBzpLhJ86zc= github.com/juju/os/v2 v2.2.3 h1:5SnGWfzFTXcFwu/sd9qEEf/No3UZxivOjJuWmsHI4N4= github.com/juju/os/v2 v2.2.3/go.mod h1:xGfP9I+Xb/A03NcGBsoJgwr084hPckkQHecaHuV3wBQ= -github.com/juju/packaging/v2 v2.0.1 h1:KeTfqx3Z0c6RcM053GJH7mplroXoRSuh/dK5vqDQLn8= -github.com/juju/packaging/v2 v2.0.1/go.mod h1:JC+FIRTJXGLt9wA+iP3ltkzv+aWVMMojB/R47uIAK0Y= +github.com/juju/packaging/v3 v3.0.0 h1:ZzuHhR8Ql9z2oeQ0m73x6k58PW65Cgk5wR9Yc1exoOI= +github.com/juju/packaging/v3 v3.0.0/go.mod h1:WXh/SXqh1du8SFzwb1KC+yZuV4Qc4alWP3MEPqFX9Lw= github.com/juju/persistent-cookiejar v1.0.0 h1:Ag7+QLzqC2m+OYXy2QQnRjb3gTkEBSZagZ6QozwT3EQ= github.com/juju/persistent-cookiejar v1.0.0/go.mod h1:zrbmo4nBKaiP/Ez3F67ewkMbzGYfXyMvRtbOfuAwG0w= github.com/juju/postgrestest v1.1.0/go.mod h1:/n17Y2T6iFozzXwSCO0JYJ5gSiz2caEtSwAjh/uLXDM= @@ -705,8 +711,8 @@ github.com/juju/utils/v3 v3.0.0-20220130232349-cd7ecef0e94a/go.mod h1:LzwbbEN7bu github.com/juju/utils/v3 v3.0.0-20220202114721-338bb0530e89/go.mod h1:wf5w+8jyTh2IYnSX0sHnMJo4ZPwwuiBWn+xN3DkQg4k= github.com/juju/utils/v3 v3.0.0-20220203023959-c3fbc78a33b0/go.mod h1:8csUcj1VRkfjNIRzBFWzLFCMLwLqsRWvkmhfVAUwbC4= github.com/juju/utils/v3 v3.0.0/go.mod h1:8csUcj1VRkfjNIRzBFWzLFCMLwLqsRWvkmhfVAUwbC4= -github.com/juju/utils/v3 v3.1.0 h1:NrNo73oVtfr7kLP17/BDpubXwa7YEW16+Ult6z9kpHI= -github.com/juju/utils/v3 v3.1.0/go.mod h1:nAj3sHtdYfAkvnkqttTy3Xzm2HzkD9Hfgnc+upOW2Z8= +github.com/juju/utils/v3 v3.1.1 h1:shEMr/4Wkw0YCOPz5IFOYkLv1ec50pzRi59TRl0qQ/0= +github.com/juju/utils/v3 v3.1.1/go.mod h1:nAj3sHtdYfAkvnkqttTy3Xzm2HzkD9Hfgnc+upOW2Z8= github.com/juju/version v0.0.0-20161031051906-1f41e27e54f2/go.mod h1:kE8gK5X0CImdr7qpSKl3xB2PmpySSmfj7zVbkZFs81U= github.com/juju/version v0.0.0-20180108022336-b64dbd566305/go.mod h1:kE8gK5X0CImdr7qpSKl3xB2PmpySSmfj7zVbkZFs81U= github.com/juju/version v0.0.0-20191219164919-81c1be00b9a6/go.mod h1:kE8gK5X0CImdr7qpSKl3xB2PmpySSmfj7zVbkZFs81U= @@ -928,6 +934,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pkg/sftp v1.13.6 h1:JFZT4XbOU7l77xGSpOdW+pwIMqP044IyjXX6FGyEKFo= github.com/pkg/sftp v1.13.6/go.mod h1:tz1ryNURKu77RL+GuCzmoJYxQczL3wLNNpPWagdg4Qk= +github.com/pkg/term v1.1.0 h1:xIAAdCMh3QIAy+5FrE8Ad8XoDhEU4ufwbaSozViP9kk= +github.com/pkg/term v1.1.0/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw= github.com/pkg/xattr v0.4.9 h1:5883YPCtkSd8LFbs13nXplj9g9tlrwoJRjgpgMu1/fE= github.com/pkg/xattr v0.4.9/go.mod h1:di8WF84zAKk8jzR1UBTEWh9AUlIZZ7M/JNt8e9B6ktU= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -1178,6 +1186,8 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20150829230318-ea47fc708ee3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180406214816-61147c48b25b/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1300,6 +1310,7 @@ golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1552,8 +1563,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20160105164936-4f90aeace3a2/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/db/model.go b/internal/db/model.go index c4e1c6448..68dcd5bab 100644 --- a/internal/db/model.go +++ b/internal/db/model.go @@ -177,7 +177,7 @@ func preloadModel(prefix string, db *gorm.DB) *gorm.DB { // loading a model, as we just use the credential to deploy // applications. db = db.Preload(prefix + "CloudCredential") - db = db.Preload(prefix + "Offers").Preload(prefix + "Offers.Connections").Preload(prefix + "Offers.Endpoints").Preload(prefix + "Offers.Spaces") + db = db.Preload(prefix + "Offers").Preload(prefix + "Offers.Connections").Preload(prefix + "Offers.Endpoints") return db } diff --git a/internal/dbmodel/applicationoffer.go b/internal/dbmodel/applicationoffer.go index 60f29dcdf..555e71c70 100644 --- a/internal/dbmodel/applicationoffer.go +++ b/internal/dbmodel/applicationoffer.go @@ -69,96 +69,39 @@ func (o *ApplicationOffer) SetTag(t names.ApplicationOfferTag) { o.UUID = t.Id() } -// FromJujuApplicationOfferAdminDetails fills in the information from jujuparams ApplicationOfferAdminDetails. -func (o *ApplicationOffer) FromJujuApplicationOfferAdminDetails(offerDetails jujuparams.ApplicationOfferAdminDetails) { +// FromJujuApplicationOfferAdminDetails maps the Juju ApplicationOfferDetails struct type to a JIMM type +// such that it can be persisted. +func (o *ApplicationOffer) FromJujuApplicationOfferAdminDetailsV5(offerDetails jujuparams.ApplicationOfferAdminDetailsV5) { o.ApplicationName = offerDetails.ApplicationName o.ApplicationDescription = offerDetails.ApplicationDescription o.Name = offerDetails.OfferName o.UUID = offerDetails.OfferUUID o.URL = offerDetails.OfferURL - o.Bindings = offerDetails.Bindings o.CharmURL = offerDetails.CharmURL - - o.Endpoints = make([]ApplicationOfferRemoteEndpoint, len(offerDetails.Endpoints)) - for i, endpoint := range offerDetails.Endpoints { - o.Endpoints[i] = ApplicationOfferRemoteEndpoint{ - Name: endpoint.Name, - Role: string(endpoint.Role), - Interface: endpoint.Interface, - Limit: endpoint.Limit, - } - } - - o.Spaces = make([]ApplicationOfferRemoteSpace, len(offerDetails.Spaces)) - for i, space := range offerDetails.Spaces { - o.Spaces[i] = ApplicationOfferRemoteSpace{ - CloudType: space.CloudType, - Name: space.Name, - ProviderID: space.ProviderId, - ProviderAttributes: space.ProviderAttributes, - } - } - - o.Connections = make([]ApplicationOfferConnection, len(offerDetails.Connections)) - for i, connection := range offerDetails.Connections { - o.Connections[i] = ApplicationOfferConnection{ - SourceModelTag: connection.SourceModelTag, - RelationID: connection.RelationId, - IdentityName: connection.Username, - Endpoint: connection.Endpoint, - IngressSubnets: connection.IngressSubnets, - } - } + o.Endpoints = mapJujuRemoteEndpointsToJIMMRemoteEndpoints(offerDetails.Endpoints) + o.Connections = mapJujuConnectionsToJIMMConnections(offerDetails.Connections) } -// ToJujuApplicationOfferDetails returns a jujuparams ApplicationOfferAdminDetails based on the application offer. -func (o *ApplicationOffer) ToJujuApplicationOfferDetails() jujuparams.ApplicationOfferAdminDetails { - endpoints := make([]jujuparams.RemoteEndpoint, len(o.Endpoints)) - for i, endpoint := range o.Endpoints { - endpoints[i] = jujuparams.RemoteEndpoint{ - Name: endpoint.Name, - Role: charm.RelationRole(endpoint.Role), - Interface: endpoint.Interface, - Limit: endpoint.Limit, - } - } - spaces := make([]jujuparams.RemoteSpace, len(o.Spaces)) - for i, space := range o.Spaces { - spaces[i] = jujuparams.RemoteSpace{ - CloudType: space.CloudType, - Name: space.Name, - ProviderId: space.ProviderID, - ProviderAttributes: space.ProviderAttributes, - } +// ToJujuApplicationOfferDetails maps the JIMM ApplicationOfferDetails struct type to a jujuparams type +// such that it can be sent over the wire. +func (o *ApplicationOffer) ToJujuApplicationOfferDetailsV5() jujuparams.ApplicationOfferAdminDetailsV5 { + v5Details := jujuparams.ApplicationOfferDetailsV5{ + SourceModelTag: o.Model.Tag().String(), + OfferUUID: o.UUID, + OfferURL: o.URL, + OfferName: o.Name, + ApplicationDescription: o.ApplicationDescription, + Endpoints: mapJIMMRemoteEndpointsToJujuRemoteEndpoints(o.Endpoints), } - connections := make([]jujuparams.OfferConnection, len(o.Connections)) - for i, connection := range o.Connections { - connections[i] = jujuparams.OfferConnection{ - SourceModelTag: connection.SourceModelTag, - RelationId: connection.RelationID, - Username: connection.IdentityName, - Endpoint: connection.Endpoint, - IngressSubnets: connection.IngressSubnets, - } - } - return jujuparams.ApplicationOfferAdminDetails{ - ApplicationOfferDetails: jujuparams.ApplicationOfferDetails{ - SourceModelTag: o.Model.Tag().String(), - OfferUUID: o.UUID, - OfferURL: o.URL, - OfferName: o.Name, - ApplicationDescription: o.ApplicationDescription, - Endpoints: endpoints, - Spaces: spaces, - Bindings: o.Bindings, - //TODO(Kian) CSS-6040 Refactor the below to use a better abstraction for Postgres/OpenFGA to Juju types - Users: nil, - }, - ApplicationName: o.ApplicationName, - CharmURL: o.CharmURL, - Connections: connections, + v5AdminDetails := jujuparams.ApplicationOfferAdminDetailsV5{ + ApplicationOfferDetailsV5: v5Details, + ApplicationName: o.ApplicationName, + CharmURL: o.CharmURL, + Connections: mapJIMMConnectionsToJujuConnections(o.Connections), } + + return v5AdminDetails } // ApplicationOfferRemoteEndpoint represents a remote application endpoint. @@ -203,3 +146,68 @@ type ApplicationOfferConnection struct { Endpoint string IngressSubnets Strings } + +// mapJIMMRemoteEndpointsToJujuRemoteEndpoints maps the types between JIMM's +// remote endpoints type (with gorm embedded for persistence) to a jujuparams +// remote endpoint, such that it can be sent over the wire and contains the correct +// json tags. +func mapJIMMRemoteEndpointsToJujuRemoteEndpoints(endpoints []ApplicationOfferRemoteEndpoint) []jujuparams.RemoteEndpoint { + mappedEndpoints := make([]jujuparams.RemoteEndpoint, len(endpoints)) + for i, endpoint := range endpoints { + mappedEndpoints[i] = jujuparams.RemoteEndpoint{ + Name: endpoint.Name, + Role: charm.RelationRole(endpoint.Role), + Interface: endpoint.Interface, + Limit: endpoint.Limit, + } + } + return mappedEndpoints +} + +// mapJujuRemoteEndpointsToJIMMRemoteEndpoints - See above for details, this does the opposite. +func mapJujuRemoteEndpointsToJIMMRemoteEndpoints(endpoints []jujuparams.RemoteEndpoint) []ApplicationOfferRemoteEndpoint { + mappedEndpoints := make([]ApplicationOfferRemoteEndpoint, len(endpoints)) + for i, endpoint := range endpoints { + mappedEndpoints[i] = ApplicationOfferRemoteEndpoint{ + Name: endpoint.Name, + Role: string(endpoint.Role), + Interface: endpoint.Interface, + Limit: endpoint.Limit, + } + } + return mappedEndpoints +} + +// mapJIMMConnectionsToJujuConnections maps the types between JIMM's +// offer connection type (with gorm embedded for persistence) to a jujuparams +// offer connection, such that it can be sent over the wire and contains the correct +// json tags. +func mapJIMMConnectionsToJujuConnections(connections []ApplicationOfferConnection) []jujuparams.OfferConnection { + mappedConnections := make([]jujuparams.OfferConnection, len(connections)) + for i, connection := range connections { + mappedConnections[i] = jujuparams.OfferConnection{ + SourceModelTag: connection.SourceModelTag, + RelationId: connection.RelationID, + Username: connection.IdentityName, + Endpoint: connection.Endpoint, + IngressSubnets: connection.IngressSubnets, + // TODO(ale8k): Status is missing, do we need it?? + } + } + return mappedConnections +} + +// mapJujuConnectionsToJIMMConnections - See above for details, this does the opposite. +func mapJujuConnectionsToJIMMConnections(connections []jujuparams.OfferConnection) []ApplicationOfferConnection { + mappedConnections := make([]ApplicationOfferConnection, len(connections)) + for i, connection := range connections { + mappedConnections[i] = ApplicationOfferConnection{ + SourceModelTag: connection.SourceModelTag, + RelationID: connection.RelationId, + IdentityName: connection.Username, + Endpoint: connection.Endpoint, + IngressSubnets: connection.IngressSubnets, + } + } + return mappedConnections +} diff --git a/internal/jimm/applicationoffer.go b/internal/jimm/applicationoffer.go index 2cb7f59b1..d9189b824 100644 --- a/internal/jimm/applicationoffer.go +++ b/internal/jimm/applicationoffer.go @@ -95,8 +95,8 @@ func (j *JIMM) Offer(ctx context.Context, user *openfga.User, offer AddApplicati return errors.E(op, err) } - offerDetails := jujuparams.ApplicationOfferAdminDetails{ - ApplicationOfferDetails: jujuparams.ApplicationOfferDetails{ + offerDetails := jujuparams.ApplicationOfferAdminDetailsV5{ + ApplicationOfferDetailsV5: jujuparams.ApplicationOfferDetailsV5{ OfferURL: offerURL.String(), }, } @@ -107,7 +107,7 @@ func (j *JIMM) Offer(ctx context.Context, user *openfga.User, offer AddApplicati } var doc dbmodel.ApplicationOffer - doc.FromJujuApplicationOfferAdminDetails(offerDetails) + doc.FromJujuApplicationOfferAdminDetailsV5(offerDetails) if err != nil { zapctx.Error(ctx, "failed to convert application offer details", zaputil.Error(err)) return errors.E(op, err) @@ -299,7 +299,7 @@ func (j *JIMM) listApplicationOfferUsers(ctx context.Context, offer names.Applic } // GetApplicationOffer returns details of the offer with the specified URL. -func (j *JIMM) GetApplicationOffer(ctx context.Context, user *openfga.User, offerURL string) (*jujuparams.ApplicationOfferAdminDetails, error) { +func (j *JIMM) GetApplicationOffer(ctx context.Context, user *openfga.User, offerURL string) (*jujuparams.ApplicationOfferAdminDetailsV5, error) { const op = errors.Op("jimm.GetApplicationOffer") offer := dbmodel.ApplicationOffer{ @@ -342,7 +342,7 @@ func (j *JIMM) GetApplicationOffer(ctx context.Context, user *openfga.User, offe } defer api.Close() - var offerDetails jujuparams.ApplicationOfferAdminDetails + var offerDetails jujuparams.ApplicationOfferAdminDetailsV5 offerDetails.OfferURL = offerURL if err := api.GetApplicationOffer(ctx, &offerDetails); err != nil { return nil, errors.E(op, err) @@ -546,8 +546,8 @@ func (j *JIMM) UpdateApplicationOffer(ctx context.Context, controller *dbmodel.C } defer api.Close() - offerDetails := jujuparams.ApplicationOfferAdminDetails{ - ApplicationOfferDetails: jujuparams.ApplicationOfferDetails{ + offerDetails := jujuparams.ApplicationOfferAdminDetailsV5{ + ApplicationOfferDetailsV5: jujuparams.ApplicationOfferDetailsV5{ OfferURL: offer.URL, }, } @@ -556,7 +556,7 @@ func (j *JIMM) UpdateApplicationOffer(ctx context.Context, controller *dbmodel.C return errors.E(op, err) } - offer.FromJujuApplicationOfferAdminDetails(offerDetails) + offer.FromJujuApplicationOfferAdminDetailsV5(offerDetails) err = j.Database.UpdateApplicationOffer(ctx, &offer) if err != nil { return errors.E(op, err) @@ -595,7 +595,7 @@ func (j *JIMM) getUserOfferAccess(ctx context.Context, user *openfga.User, offer } // FindApplicationOffers returns details of offers matching the specified filter. -func (j *JIMM) FindApplicationOffers(ctx context.Context, user *openfga.User, filters ...jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) { +func (j *JIMM) FindApplicationOffers(ctx context.Context, user *openfga.User, filters ...jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) { const op = errors.Op("jimm.FindApplicationOffers") if len(filters) == 0 { @@ -615,7 +615,7 @@ func (j *JIMM) FindApplicationOffers(ctx context.Context, user *openfga.User, fi if err != nil { return nil, errors.E(op, err) } - offerDetails := make([]jujuparams.ApplicationOfferAdminDetails, len(offers)) + offerDetails := make([]jujuparams.ApplicationOfferAdminDetailsV5, len(offers)) for i, offer := range offers { // TODO (alesstimec) Optimize this: currently check all possible // permission levels for an offer, this is suboptimal. @@ -624,7 +624,7 @@ func (j *JIMM) FindApplicationOffers(ctx context.Context, user *openfga.User, fi return nil, errors.E(op, err) } - offerDetails[i] = offer.ToJujuApplicationOfferDetails() + offerDetails[i] = offer.ToJujuApplicationOfferDetailsV5() // non-admin users should not see connections of an application // offer. @@ -703,7 +703,7 @@ func (j *JIMM) applicationOfferFilters(ctx context.Context, jujuFilters ...jujup } // ListApplicationOffers returns details of offers matching the specified filter. -func (j *JIMM) ListApplicationOffers(ctx context.Context, user *openfga.User, filters ...jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) { +func (j *JIMM) ListApplicationOffers(ctx context.Context, user *openfga.User, filters ...jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) { const op = errors.Op("jimm.ListApplicationOffers") type modelKey struct { @@ -730,7 +730,7 @@ func (j *JIMM) ListApplicationOffers(ctx context.Context, user *openfga.User, fi modelFilters[m] = append(modelFilters[m], f) } - var offers []jujuparams.ApplicationOfferAdminDetails + var offers []jujuparams.ApplicationOfferAdminDetailsV5 var keys []modelKey for k := range modelFilters { @@ -764,7 +764,7 @@ func (j *JIMM) ListApplicationOffers(ctx context.Context, user *openfga.User, fi return offers, nil } -func (j *JIMM) listApplicationOffersForModel(ctx context.Context, user *openfga.User, m *dbmodel.Model, filters []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) { +func (j *JIMM) listApplicationOffersForModel(ctx context.Context, user *openfga.User, m *dbmodel.Model, filters []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) { const op = errors.Op("jimm.listApplicationOffersForModel") if err := j.Database.GetModel(ctx, m); err != nil { diff --git a/internal/jimm/applicationoffer_test.go b/internal/jimm/applicationoffer_test.go index 3f995450f..553596754 100644 --- a/internal/jimm/applicationoffer_test.go +++ b/internal/jimm/applicationoffer_test.go @@ -20,7 +20,6 @@ import ( "gopkg.in/macaroon.v2" "gorm.io/gorm" - "github.com/canonical/jimm/internal/constants" "github.com/canonical/jimm/internal/db" "github.com/canonical/jimm/internal/dbmodel" "github.com/canonical/jimm/internal/errors" @@ -664,7 +663,7 @@ func TestGetApplicationOfferConsumeDetails(t *testing.T) { UUID: "00000000-0000-0000-0000-0000-0000000000001", API: &jimmtest.API{ GetApplicationOfferConsumeDetails_: func(ctx context.Context, user names.UserTag, details *jujuparams.ConsumeOfferDetails, v bakery.Version) error { - details.Offer = &jujuparams.ApplicationOfferDetails{ + details.Offer = &jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: names.NewModelTag(model.UUID.String).String(), OfferUUID: offer.UUID, OfferURL: offer.URL, @@ -676,10 +675,6 @@ func TestGetApplicationOfferConsumeDetails(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Bindings: map[string]string{ - "key1": "value1", - "key2": "value2", - }, Users: []jujuparams.OfferUserDetails{{ UserName: "alice@canonical.com", Access: "admin", @@ -690,15 +685,6 @@ func TestGetApplicationOfferConsumeDetails(t *testing.T) { UserName: "bob@canonical.com", Access: "consume", }}, - Spaces: []jujuparams.RemoteSpace{{ - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderId: "test-provider-id", - ProviderAttributes: map[string]interface{}{ - "attr1": "value1", - "attr2": "value2", - }, - }}, } details.Macaroon = &macaroon.Macaroon{} details.ControllerInfo = &jujuparams.ExternalControllerInfo{ @@ -720,7 +706,7 @@ func TestGetApplicationOfferConsumeDetails(t *testing.T) { about: "admin can get the application offer consume details ", user: u, details: jujuparams.ConsumeOfferDetails{ - Offer: &jujuparams.ApplicationOfferDetails{ + Offer: &jujuparams.ApplicationOfferDetailsV5{ OfferURL: "test-offer-url", }, }, @@ -731,7 +717,7 @@ func TestGetApplicationOfferConsumeDetails(t *testing.T) { Addrs: []string{"test-public-address"}, }, Macaroon: &macaroon.Macaroon{}, - Offer: &jujuparams.ApplicationOfferDetails{ + Offer: &jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: names.NewModelTag(model.UUID.String).String(), OfferUUID: offer.UUID, OfferURL: offer.URL, @@ -743,10 +729,6 @@ func TestGetApplicationOfferConsumeDetails(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Bindings: map[string]string{ - "key1": "value1", - "key2": "value2", - }, Users: []jujuparams.OfferUserDetails{{ UserName: "alice@canonical.com", Access: "admin", @@ -760,22 +742,13 @@ func TestGetApplicationOfferConsumeDetails(t *testing.T) { UserName: "everyone@external", Access: "read", }}, - Spaces: []jujuparams.RemoteSpace{{ - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderId: "test-provider-id", - ProviderAttributes: map[string]interface{}{ - "attr1": "value1", - "attr2": "value2", - }, - }}, }, }, }, { about: "users with consume access can get the application offer consume details with filtered users", user: u2, details: jujuparams.ConsumeOfferDetails{ - Offer: &jujuparams.ApplicationOfferDetails{ + Offer: &jujuparams.ApplicationOfferDetailsV5{ OfferURL: "test-offer-url", }, }, @@ -786,7 +759,7 @@ func TestGetApplicationOfferConsumeDetails(t *testing.T) { Addrs: []string{"test-public-address"}, }, Macaroon: &macaroon.Macaroon{}, - Offer: &jujuparams.ApplicationOfferDetails{ + Offer: &jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: names.NewModelTag(model.UUID.String).String(), OfferUUID: offer.UUID, OfferURL: offer.URL, @@ -798,10 +771,6 @@ func TestGetApplicationOfferConsumeDetails(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Bindings: map[string]string{ - "key1": "value1", - "key2": "value2", - }, Users: []jujuparams.OfferUserDetails{{ UserName: "bob@canonical.com", Access: "consume", @@ -809,22 +778,13 @@ func TestGetApplicationOfferConsumeDetails(t *testing.T) { UserName: "everyone@external", Access: "read", }}, - Spaces: []jujuparams.RemoteSpace{{ - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderId: "test-provider-id", - ProviderAttributes: map[string]interface{}{ - "attr1": "value1", - "attr2": "value2", - }, - }}, }, }, }, { about: "user with read access cannot get application offer consume details", user: u1, details: jujuparams.ConsumeOfferDetails{ - Offer: &jujuparams.ApplicationOfferDetails{ + Offer: &jujuparams.ApplicationOfferDetailsV5{ OfferURL: "test-offer-url", }, }, @@ -833,7 +793,7 @@ func TestGetApplicationOfferConsumeDetails(t *testing.T) { about: "no such offer", user: u, details: jujuparams.ConsumeOfferDetails{ - Offer: &jujuparams.ApplicationOfferDetails{ + Offer: &jujuparams.ApplicationOfferDetailsV5{ OfferURL: "no-such-offer", }, }, @@ -873,7 +833,7 @@ func TestGetApplicationOffer(t *testing.T) { }, Dialer: &jimmtest.Dialer{ API: &jimmtest.API{ - GetApplicationOffer_: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetails) error { + GetApplicationOffer_: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetailsV5) error { details.ApplicationName = "test-app" details.CharmURL = "cs:test-app:17" details.Connections = []jujuparams.OfferConnection{{ @@ -882,7 +842,7 @@ func TestGetApplicationOffer(t *testing.T) { Username: "unknown", Endpoint: "test-endpoint", }} - details.ApplicationOfferDetails = jujuparams.ApplicationOfferDetails{ + details.ApplicationOfferDetailsV5 = jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: names.NewModelTag("00000000-0000-0000-0000-0000-0000000000003").String(), OfferUUID: "00000000-0000-0000-0000-0000-0000000000011", OfferURL: "test-offer-url", @@ -893,24 +853,6 @@ func TestGetApplicationOffer(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Spaces: []jujuparams.RemoteSpace{{ - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderId: "test-provider-id", - ProviderAttributes: map[string]interface{}{ - "attr1": "value1", - "attr2": "value2", - }, - Subnets: []jujuparams.Subnet{{ - SpaceTag: "test-remote-space", - VLANTag: 1024, - Status: constants.DEAD.String(), - }}, - }}, - Bindings: map[string]string{ - "key1": "value4", - "key2": "value5", - }, Users: []jujuparams.OfferUserDetails{{ UserName: "alice@canonical.com", Access: string(jujuparams.OfferAdminAccess), @@ -1004,20 +946,6 @@ func TestGetApplicationOffer(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Spaces: []dbmodel.ApplicationOfferRemoteSpace{{ - ApplicationOfferID: 1, - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderID: "test-provider-id", - ProviderAttributes: dbmodel.Map{ - "attr1": "value1", - "attr2": "value2", - }, - }}, - Bindings: dbmodel.StringMap{ - "key1": "value1", - "key2": "value2", - }, Connections: []dbmodel.ApplicationOfferConnection{{ ApplicationOfferID: 1, SourceModelTag: "test-model-src", @@ -1041,14 +969,14 @@ func TestGetApplicationOffer(t *testing.T) { about string user *dbmodel.Identity offerURL string - expectedOfferDetails jujuparams.ApplicationOfferAdminDetails + expectedOfferDetails jujuparams.ApplicationOfferAdminDetailsV5 expectedError string }{{ about: "admin can get the application offer", user: u, offerURL: "test-offer-url", - expectedOfferDetails: jujuparams.ApplicationOfferAdminDetails{ - ApplicationOfferDetails: jujuparams.ApplicationOfferDetails{ + expectedOfferDetails: jujuparams.ApplicationOfferAdminDetailsV5{ + ApplicationOfferDetailsV5: jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: names.NewModelTag(model.UUID.String).String(), OfferUUID: "00000000-0000-0000-0000-0000-0000000000011", OfferURL: "test-offer-url", @@ -1059,10 +987,6 @@ func TestGetApplicationOffer(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Bindings: map[string]string{ - "key1": "value4", - "key2": "value5", - }, Users: []jujuparams.OfferUserDetails{{ UserName: "alice@canonical.com", Access: "admin", @@ -1070,20 +994,6 @@ func TestGetApplicationOffer(t *testing.T) { UserName: "eve@canonical.com", Access: "read", }}, - Spaces: []jujuparams.RemoteSpace{{ - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderId: "test-provider-id", - ProviderAttributes: map[string]interface{}{ - "attr1": "value1", - "attr2": "value2", - }, - Subnets: []jujuparams.Subnet{{ - SpaceTag: "test-remote-space", - VLANTag: 1024, - Status: constants.DEAD.String(), - }}, - }}, }, ApplicationName: "test-app", CharmURL: "cs:test-app:17", @@ -1098,8 +1008,8 @@ func TestGetApplicationOffer(t *testing.T) { about: "user with read access can get the application offer, but users and connections are filtered", user: u1, offerURL: "test-offer-url", - expectedOfferDetails: jujuparams.ApplicationOfferAdminDetails{ - ApplicationOfferDetails: jujuparams.ApplicationOfferDetails{ + expectedOfferDetails: jujuparams.ApplicationOfferAdminDetailsV5{ + ApplicationOfferDetailsV5: jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: names.NewModelTag(model.UUID.String).String(), OfferUUID: "00000000-0000-0000-0000-0000-0000000000011", OfferURL: "test-offer-url", @@ -1110,28 +1020,10 @@ func TestGetApplicationOffer(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Bindings: map[string]string{ - "key1": "value4", - "key2": "value5", - }, Users: []jujuparams.OfferUserDetails{{ UserName: "eve@canonical.com", Access: "read", }}, - Spaces: []jujuparams.RemoteSpace{{ - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderId: "test-provider-id", - ProviderAttributes: map[string]interface{}{ - "attr1": "value1", - "attr2": "value2", - }, - Subnets: []jujuparams.Subnet{{ - SpaceTag: "test-remote-space", - VLANTag: 1024, - Status: constants.DEAD.String(), - }}, - }}, }, ApplicationName: "test-app", CharmURL: "cs:test-app:17", @@ -1170,13 +1062,13 @@ func TestOffer(t *testing.T) { now := time.Now().UTC().Round(time.Millisecond) tests := []struct { about string - getApplicationOffer func(context.Context, *jujuparams.ApplicationOfferAdminDetails) error + getApplicationOffer func(context.Context, *jujuparams.ApplicationOfferAdminDetailsV5) error grantApplicationOfferAccess func(context.Context, string, names.UserTag, jujuparams.OfferAccessPermission) error offer func(context.Context, crossmodel.OfferURL, jujuparams.AddApplicationOffer) error createEnv func(*qt.C, db.Database, *openfga.OFGAClient) (dbmodel.Identity, jimm.AddApplicationOfferParams, dbmodel.ApplicationOffer, func(*qt.C, error)) }{{ about: "all ok", - getApplicationOffer: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetails) error { + getApplicationOffer: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetailsV5) error { details.ApplicationName = "test-app" details.CharmURL = "cs:test-app:17" details.Connections = []jujuparams.OfferConnection{{ @@ -1185,7 +1077,7 @@ func TestOffer(t *testing.T) { Username: "unknown", Endpoint: "test-endpoint", }} - details.ApplicationOfferDetails = jujuparams.ApplicationOfferDetails{ + details.ApplicationOfferDetailsV5 = jujuparams.ApplicationOfferDetailsV5{ OfferUUID: "00000000-0000-0000-0000-0000-0000000000004", OfferURL: "test-offer-url", ApplicationDescription: "a test app offering", @@ -1195,24 +1087,6 @@ func TestOffer(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Spaces: []jujuparams.RemoteSpace{{ - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderId: "test-provider-id", - ProviderAttributes: map[string]interface{}{ - "attr1": "value1", - "attr2": "value2", - }, - Subnets: []jujuparams.Subnet{{ - SpaceTag: "test-remote-space", - VLANTag: 1024, - Status: constants.ALIVE.String(), - }}, - }}, - Bindings: map[string]string{ - "key1": "value1", - "key2": "value2", - }, Users: []jujuparams.OfferUserDetails{{ UserName: "alice", DisplayName: "alice, sister of eve", @@ -1312,20 +1186,6 @@ func TestOffer(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Spaces: []dbmodel.ApplicationOfferRemoteSpace{{ - ApplicationOfferID: 1, - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderID: "test-provider-id", - ProviderAttributes: dbmodel.Map{ - "attr1": "value1", - "attr2": "value2", - }, - }}, - Bindings: dbmodel.StringMap{ - "key1": "value1", - "key2": "value2", - }, Connections: []dbmodel.ApplicationOfferConnection{{ ApplicationOfferID: 1, SourceModelTag: "test-model-src", @@ -1339,7 +1199,7 @@ func TestOffer(t *testing.T) { }, }, { about: "controller returns an error when creating an offer", - getApplicationOffer: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetails) error { + getApplicationOffer: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetailsV5) error { return nil }, grantApplicationOfferAccess: func(context.Context, string, names.UserTag, jujuparams.OfferAccessPermission) error { @@ -1426,7 +1286,7 @@ func TestOffer(t *testing.T) { }, }, { about: "model not found", - getApplicationOffer: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetails) error { + getApplicationOffer: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetailsV5) error { return nil }, grantApplicationOfferAccess: func(context.Context, string, names.UserTag, jujuparams.OfferAccessPermission) error { @@ -1458,7 +1318,7 @@ func TestOffer(t *testing.T) { }, }, { about: "application not found", - getApplicationOffer: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetails) error { + getApplicationOffer: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetailsV5) error { return nil }, grantApplicationOfferAccess: func(context.Context, string, names.UserTag, jujuparams.OfferAccessPermission) error { @@ -1547,7 +1407,7 @@ func TestOffer(t *testing.T) { }, }, { about: "user not model admin", - getApplicationOffer: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetails) error { + getApplicationOffer: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetailsV5) error { return nil }, grantApplicationOfferAccess: func(context.Context, string, names.UserTag, jujuparams.OfferAccessPermission) error { @@ -1638,7 +1498,7 @@ func TestOffer(t *testing.T) { }, }, { about: "fail to fetch application offer details", - getApplicationOffer: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetails) error { + getApplicationOffer: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetailsV5) error { return errors.E("a silly error") }, grantApplicationOfferAccess: func(context.Context, string, names.UserTag, jujuparams.OfferAccessPermission) error { @@ -1725,7 +1585,7 @@ func TestOffer(t *testing.T) { }, }, { about: "controller returns `application offer already exists`", - getApplicationOffer: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetails) error { + getApplicationOffer: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetailsV5) error { return nil }, grantApplicationOfferAccess: func(context.Context, string, names.UserTag, jujuparams.OfferAccessPermission) error { @@ -1948,20 +1808,6 @@ func TestOfferAssertOpenFGARelationsExist(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Spaces: []dbmodel.ApplicationOfferRemoteSpace{{ - ApplicationOfferID: 1, - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderID: "test-provider-id", - ProviderAttributes: dbmodel.Map{ - "attr1": "value1", - "attr2": "value2", - }, - }}, - Bindings: dbmodel.StringMap{ - "key1": "value1", - "key2": "value2", - }, Connections: []dbmodel.ApplicationOfferConnection{{ ApplicationOfferID: 1, SourceModelTag: "test-model-src", @@ -1975,7 +1821,7 @@ func TestOfferAssertOpenFGARelationsExist(t *testing.T) { } api := &jimmtest.API{ - GetApplicationOffer_: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetails) error { + GetApplicationOffer_: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetailsV5) error { details.ApplicationName = "test-app" details.CharmURL = "cs:test-app:17" details.Connections = []jujuparams.OfferConnection{{ @@ -1984,7 +1830,7 @@ func TestOfferAssertOpenFGARelationsExist(t *testing.T) { Username: "unknown", Endpoint: "test-endpoint", }} - details.ApplicationOfferDetails = jujuparams.ApplicationOfferDetails{ + details.ApplicationOfferDetailsV5 = jujuparams.ApplicationOfferDetailsV5{ OfferUUID: "00000000-0000-0000-0000-0000-0000000000004", OfferURL: "test-offer-url", ApplicationDescription: "a test app offering", @@ -1994,24 +1840,6 @@ func TestOfferAssertOpenFGARelationsExist(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Spaces: []jujuparams.RemoteSpace{{ - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderId: "test-provider-id", - ProviderAttributes: map[string]interface{}{ - "attr1": "value1", - "attr2": "value2", - }, - Subnets: []jujuparams.Subnet{{ - SpaceTag: "test-remote-space", - VLANTag: 1024, - Status: constants.ALIVE.String(), - }}, - }}, - Bindings: map[string]string{ - "key1": "value1", - "key2": "value2", - }, Users: []jujuparams.OfferUserDetails{{ UserName: "alice", DisplayName: "alice, sister of eve", @@ -2295,19 +2123,6 @@ func TestUpdateOffer(t *testing.T) { ApplicationName: "test-app", CharmURL: "cs:test-app:17", ApplicationDescription: "changed offer description", - Spaces: []dbmodel.ApplicationOfferRemoteSpace{{ - ApplicationOfferID: 1, - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderID: "test-provider-id", - ProviderAttributes: dbmodel.Map{ - "attr1": "value3", - "attr2": "value4"}, - }}, - Bindings: dbmodel.StringMap{ - "key1": "value4", - "key2": "value5", - }, Connections: []dbmodel.ApplicationOfferConnection{{ ApplicationOfferID: 1, SourceModelTag: "test-model-src", @@ -2359,7 +2174,7 @@ func TestUpdateOffer(t *testing.T) { Database: db, Dialer: &jimmtest.Dialer{ API: &jimmtest.API{ - GetApplicationOffer_: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetails) error { + GetApplicationOffer_: func(_ context.Context, details *jujuparams.ApplicationOfferAdminDetailsV5) error { details.ApplicationName = "test-app" details.CharmURL = "cs:test-app:17" details.Connections = []jujuparams.OfferConnection{{ @@ -2368,7 +2183,7 @@ func TestUpdateOffer(t *testing.T) { Username: "unknown", Endpoint: "test-endpoint", }} - details.ApplicationOfferDetails = jujuparams.ApplicationOfferDetails{ + details.ApplicationOfferDetailsV5 = jujuparams.ApplicationOfferDetailsV5{ OfferUUID: "00000000-0000-0000-0000-0000-0000000000011", OfferURL: "test-offer-url", ApplicationDescription: "changed offer description", @@ -2378,24 +2193,6 @@ func TestUpdateOffer(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Spaces: []jujuparams.RemoteSpace{{ - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderId: "test-provider-id", - ProviderAttributes: map[string]interface{}{ - "attr1": "value3", - "attr2": "value4", - }, - Subnets: []jujuparams.Subnet{{ - SpaceTag: "test-remote-space", - VLANTag: 1024, - Status: constants.DEAD.String(), - }}, - }}, - Bindings: map[string]string{ - "key1": "value4", - "key2": "value5", - }, Users: []jujuparams.OfferUserDetails{{ UserName: "alice", DisplayName: "alice, sister of eve", @@ -2543,7 +2340,7 @@ func TestFindApplicationOffers(t *testing.T) { if test.expectedError == "" { c.Assert(err, qt.IsNil) if test.expectedOffer != nil { - details := test.expectedOffer.ToJujuApplicationOfferDetails() + details := test.expectedOffer.ToJujuApplicationOfferDetailsV5() if accessLevel != string(jujuparams.OfferAdminAccess) { details.Users = []jujuparams.OfferUserDetails{{ UserName: user.Name, @@ -2587,7 +2384,7 @@ func TestFindApplicationOffers(t *testing.T) { cmpopts.IgnoreTypes(gorm.Model{}), cmpopts.IgnoreTypes(dbmodel.Model{}), ), - []jujuparams.ApplicationOfferAdminDetails{details}, + []jujuparams.ApplicationOfferAdminDetailsV5{details}, ) } else { c.Assert(offers, qt.HasLen, 0) @@ -2686,11 +2483,11 @@ func TestListApplicationOffers(t *testing.T) { Database: db, Dialer: &jimmtest.Dialer{ API: &jimmtest.API{ - ListApplicationOffers_: func(_ context.Context, filters []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) { + ListApplicationOffers_: func(_ context.Context, filters []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) { switch filters[0].ModelName { case "model-1": - return []jujuparams.ApplicationOfferAdminDetails{{ - ApplicationOfferDetails: jujuparams.ApplicationOfferDetails{ + return []jujuparams.ApplicationOfferAdminDetailsV5{{ + ApplicationOfferDetailsV5: jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: "00000011-0000-0000-0000-000000000001", OfferUUID: "00000012-0000-0000-0000-000000000001", OfferURL: "test-offer-url", @@ -2702,10 +2499,6 @@ func TestListApplicationOffers(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Bindings: map[string]string{ - "key1": "value1", - "key2": "value2", - }, Users: []jujuparams.OfferUserDetails{{ UserName: "alice@canonical.com", Access: "admin", @@ -2716,15 +2509,6 @@ func TestListApplicationOffers(t *testing.T) { UserName: "bob@canonical.com", Access: "consume", }}, - Spaces: []jujuparams.RemoteSpace{{ - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderId: "test-provider-id", - ProviderAttributes: map[string]interface{}{ - "attr1": "value1", - "attr2": "value2", - }, - }}, }, ApplicationName: "application-1", CharmURL: "charm-1", @@ -2735,7 +2519,7 @@ func TestListApplicationOffers(t *testing.T) { Endpoint: "an-endpoint", }}, }, { - ApplicationOfferDetails: jujuparams.ApplicationOfferDetails{ + ApplicationOfferDetailsV5: jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: "00000011-0000-0000-0000-000000000002", OfferUUID: "00000012-0000-0000-0000-000000000002", OfferURL: "test-offer-url", @@ -2747,10 +2531,6 @@ func TestListApplicationOffers(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Bindings: map[string]string{ - "key1": "value1", - "key2": "value2", - }, Users: []jujuparams.OfferUserDetails{{ UserName: "alice@canonical.com", Access: "admin", @@ -2761,15 +2541,6 @@ func TestListApplicationOffers(t *testing.T) { UserName: "bob@canonical.com", Access: "consume", }}, - Spaces: []jujuparams.RemoteSpace{{ - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderId: "test-provider-id", - ProviderAttributes: map[string]interface{}{ - "attr1": "value1", - "attr2": "value2", - }, - }}, }, ApplicationName: "application-2", CharmURL: "charm-2", @@ -2781,8 +2552,8 @@ func TestListApplicationOffers(t *testing.T) { }}, }}, nil case "model-2": - return []jujuparams.ApplicationOfferAdminDetails{{ - ApplicationOfferDetails: jujuparams.ApplicationOfferDetails{ + return []jujuparams.ApplicationOfferAdminDetailsV5{{ + ApplicationOfferDetailsV5: jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: "00000011-0000-0000-0000-000000000003", OfferUUID: "00000012-0000-0000-0000-000000000003", OfferURL: "test-offer-url", @@ -2794,10 +2565,6 @@ func TestListApplicationOffers(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Bindings: map[string]string{ - "key1": "value1", - "key2": "value2", - }, Users: []jujuparams.OfferUserDetails{{ UserName: "alice@canonical.com", Access: "admin", @@ -2808,15 +2575,6 @@ func TestListApplicationOffers(t *testing.T) { UserName: "bob@canonical.com", Access: "consume", }}, - Spaces: []jujuparams.RemoteSpace{{ - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderId: "test-provider-id", - ProviderAttributes: map[string]interface{}{ - "attr1": "value1", - "attr2": "value2", - }, - }}, }, ApplicationName: "application-3", CharmURL: "charm-3", @@ -2896,8 +2654,8 @@ func TestListApplicationOffers(t *testing.T) { return offers[i].Users[j].UserName < offers[i].Users[k].UserName }) } - c.Check(offers, qt.DeepEquals, []jujuparams.ApplicationOfferAdminDetails{{ - ApplicationOfferDetails: jujuparams.ApplicationOfferDetails{ + c.Check(offers, qt.DeepEquals, []jujuparams.ApplicationOfferAdminDetailsV5{{ + ApplicationOfferDetailsV5: jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: "00000011-0000-0000-0000-000000000003", OfferUUID: "00000012-0000-0000-0000-000000000003", OfferURL: "test-offer-url", @@ -2909,10 +2667,6 @@ func TestListApplicationOffers(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Bindings: map[string]string{ - "key1": "value1", - "key2": "value2", - }, Users: []jujuparams.OfferUserDetails{{ UserName: "alice@canonical.com", Access: "admin", @@ -2923,15 +2677,6 @@ func TestListApplicationOffers(t *testing.T) { UserName: "eve@canonical.com", Access: "read", }}, - Spaces: []jujuparams.RemoteSpace{{ - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderId: "test-provider-id", - ProviderAttributes: map[string]interface{}{ - "attr1": "value1", - "attr2": "value2", - }, - }}, }, ApplicationName: "application-3", CharmURL: "charm-3", @@ -2942,7 +2687,7 @@ func TestListApplicationOffers(t *testing.T) { Endpoint: "an-endpoint", }}, }, { - ApplicationOfferDetails: jujuparams.ApplicationOfferDetails{ + ApplicationOfferDetailsV5: jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: "00000011-0000-0000-0000-000000000001", OfferUUID: "00000012-0000-0000-0000-000000000001", OfferURL: "test-offer-url", @@ -2954,10 +2699,6 @@ func TestListApplicationOffers(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Bindings: map[string]string{ - "key1": "value1", - "key2": "value2", - }, Users: []jujuparams.OfferUserDetails{{ UserName: "alice@canonical.com", Access: "admin", @@ -2968,15 +2709,6 @@ func TestListApplicationOffers(t *testing.T) { UserName: "eve@canonical.com", Access: "read", }}, - Spaces: []jujuparams.RemoteSpace{{ - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderId: "test-provider-id", - ProviderAttributes: map[string]interface{}{ - "attr1": "value1", - "attr2": "value2", - }, - }}, }, ApplicationName: "application-1", CharmURL: "charm-1", @@ -2987,7 +2719,7 @@ func TestListApplicationOffers(t *testing.T) { Endpoint: "an-endpoint", }}, }, { - ApplicationOfferDetails: jujuparams.ApplicationOfferDetails{ + ApplicationOfferDetailsV5: jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: "00000011-0000-0000-0000-000000000002", OfferUUID: "00000012-0000-0000-0000-000000000002", OfferURL: "test-offer-url", @@ -2999,10 +2731,6 @@ func TestListApplicationOffers(t *testing.T) { Interface: "unknown", Limit: 1, }}, - Bindings: map[string]string{ - "key1": "value1", - "key2": "value2", - }, Users: []jujuparams.OfferUserDetails{{ UserName: "alice@canonical.com", Access: "admin", @@ -3013,15 +2741,6 @@ func TestListApplicationOffers(t *testing.T) { UserName: "eve@canonical.com", Access: "read", }}, - Spaces: []jujuparams.RemoteSpace{{ - CloudType: "test-cloud-type", - Name: "test-remote-space", - ProviderId: "test-provider-id", - ProviderAttributes: map[string]interface{}{ - "attr1": "value1", - "attr2": "value2", - }, - }}, }, ApplicationName: "application-2", CharmURL: "charm-2", diff --git a/internal/jimm/jimm.go b/internal/jimm/jimm.go index fbf22e097..8dc0c1484 100644 --- a/internal/jimm/jimm.go +++ b/internal/jimm/jimm.go @@ -264,11 +264,11 @@ type API interface { // FindApplicationOffers finds application offers that match the // filter. - FindApplicationOffers(context.Context, []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) + FindApplicationOffers(context.Context, []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) // GetApplicationOffer completes the given ApplicationOfferAdminDetails // structure. - GetApplicationOffer(context.Context, *jujuparams.ApplicationOfferAdminDetails) error + GetApplicationOffer(context.Context, *jujuparams.ApplicationOfferAdminDetailsV5) error // GetApplicationOfferConsumeDetails gets the details required to // consume an application offer @@ -292,7 +292,7 @@ type API interface { // ListApplicationOffers lists application offers that match the // filter. - ListApplicationOffers(context.Context, []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) + ListApplicationOffers(context.Context, []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) // ModelInfo fetches a model's ModelInfo. ModelInfo(context.Context, *jujuparams.ModelInfo) error diff --git a/internal/jimmtest/api.go b/internal/jimmtest/api.go index 97e17aa5b..07dc0c28b 100644 --- a/internal/jimmtest/api.go +++ b/internal/jimmtest/api.go @@ -133,15 +133,15 @@ type API struct { DestroyModel_ func(context.Context, names.ModelTag, *bool, *bool, *time.Duration, *time.Duration) error DumpModel_ func(context.Context, names.ModelTag, bool) (string, error) DumpModelDB_ func(context.Context, names.ModelTag) (map[string]interface{}, error) - FindApplicationOffers_ func(context.Context, []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) - GetApplicationOffer_ func(context.Context, *jujuparams.ApplicationOfferAdminDetails) error + FindApplicationOffers_ func(context.Context, []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) + GetApplicationOffer_ func(context.Context, *jujuparams.ApplicationOfferAdminDetailsV5) error GetApplicationOfferConsumeDetails_ func(context.Context, names.UserTag, *jujuparams.ConsumeOfferDetails, bakery.Version) error GrantApplicationOfferAccess_ func(context.Context, string, names.UserTag, jujuparams.OfferAccessPermission) error GrantCloudAccess_ func(context.Context, names.CloudTag, names.UserTag, string) error GrantJIMMModelAdmin_ func(context.Context, names.ModelTag) error GrantModelAccess_ func(context.Context, names.ModelTag, names.UserTag, jujuparams.UserAccessPermission) error IsBroken_ bool - ListApplicationOffers_ func(context.Context, []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) + ListApplicationOffers_ func(context.Context, []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) ModelInfo_ func(context.Context, *jujuparams.ModelInfo) error ModelStatus_ func(context.Context, *jujuparams.ModelStatus) error ModelSummaryWatcherNext_ func(context.Context, string) ([]jujuparams.ModelAbstract, error) @@ -267,14 +267,14 @@ func (a *API) DumpModelDB(ctx context.Context, mt names.ModelTag) (map[string]in return a.DumpModelDB_(ctx, mt) } -func (a *API) FindApplicationOffers(ctx context.Context, f []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) { +func (a *API) FindApplicationOffers(ctx context.Context, f []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) { if a.FindApplicationOffers_ == nil { return nil, errors.E(errors.CodeNotImplemented) } return a.FindApplicationOffers_(ctx, f) } -func (a *API) GetApplicationOffer(ctx context.Context, offer *jujuparams.ApplicationOfferAdminDetails) error { +func (a *API) GetApplicationOffer(ctx context.Context, offer *jujuparams.ApplicationOfferAdminDetailsV5) error { if a.GetApplicationOffer_ == nil { return errors.E(errors.CodeNotImplemented) } @@ -320,7 +320,7 @@ func (a *API) IsBroken() bool { return a.IsBroken_ } -func (a *API) ListApplicationOffers(ctx context.Context, f []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) { +func (a *API) ListApplicationOffers(ctx context.Context, f []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) { if a.ListApplicationOffers_ == nil { return nil, errors.E(errors.CodeNotImplemented) } diff --git a/internal/jimmtest/jimm_mock.go b/internal/jimmtest/jimm_mock.go index 6b598f344..244f2a8e5 100644 --- a/internal/jimmtest/jimm_mock.go +++ b/internal/jimmtest/jimm_mock.go @@ -46,7 +46,7 @@ type JIMM struct { DumpModel_ func(ctx context.Context, u *openfga.User, mt names.ModelTag, simplified bool) (string, error) DumpModelDB_ func(ctx context.Context, u *openfga.User, mt names.ModelTag) (map[string]interface{}, error) EarliestControllerVersion_ func(ctx context.Context) (version.Number, error) - FindApplicationOffers_ func(ctx context.Context, user *openfga.User, filters ...jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) + FindApplicationOffers_ func(ctx context.Context, user *openfga.User, filters ...jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) FindAuditEvents_ func(ctx context.Context, user *openfga.User, filter db.AuditLogFilter) ([]dbmodel.AuditLogEntry, error) ForEachCloud_ func(ctx context.Context, user *openfga.User, f func(*dbmodel.Cloud) error) error ForEachModel_ func(ctx context.Context, u *openfga.User, f func(*dbmodel.Model, jujuparams.UserAccessPermission) error) error @@ -54,7 +54,7 @@ type JIMM struct { ForEachUserCloudCredential_ func(ctx context.Context, u *dbmodel.Identity, ct names.CloudTag, f func(cred *dbmodel.CloudCredential) error) error ForEachUserModel_ func(ctx context.Context, u *openfga.User, f func(*dbmodel.Model, jujuparams.UserAccessPermission) error) error FullModelStatus_ func(ctx context.Context, user *openfga.User, modelTag names.ModelTag, patterns []string) (*jujuparams.FullStatus, error) - GetApplicationOffer_ func(ctx context.Context, user *openfga.User, offerURL string) (*jujuparams.ApplicationOfferAdminDetails, error) + GetApplicationOffer_ func(ctx context.Context, user *openfga.User, offerURL string) (*jujuparams.ApplicationOfferAdminDetailsV5, error) GetApplicationOfferConsumeDetails_ func(ctx context.Context, user *openfga.User, details *jujuparams.ConsumeOfferDetails, v bakery.Version) error GetCloud_ func(ctx context.Context, u *openfga.User, tag names.CloudTag) (dbmodel.Cloud, error) GetCloudCredential_ func(ctx context.Context, user *openfga.User, tag names.CloudCredentialTag) (*dbmodel.CloudCredential, error) @@ -76,7 +76,7 @@ type JIMM struct { IdentityModelDefaults_ func(ctx context.Context, user *dbmodel.Identity) (map[string]interface{}, error) InitiateMigration_ func(ctx context.Context, user *openfga.User, spec jujuparams.MigrationSpec, targetControllerID uint) (jujuparams.InitiateMigrationResult, error) InitiateInternalMigration_ func(ctx context.Context, user *openfga.User, modelTag names.ModelTag, targetController string) (jujuparams.InitiateMigrationResult, error) - ListApplicationOffers_ func(ctx context.Context, user *openfga.User, filters ...jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) + ListApplicationOffers_ func(ctx context.Context, user *openfga.User, filters ...jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) ListControllers_ func(ctx context.Context, user *openfga.User) ([]dbmodel.Controller, error) ListGroups_ func(ctx context.Context, user *openfga.User) ([]dbmodel.GroupEntry, error) ModelDefaultsForCloud_ func(ctx context.Context, user *dbmodel.Identity, cloudTag names.CloudTag) (jujuparams.ModelDefaultsResult, error) @@ -218,7 +218,7 @@ func (j *JIMM) EarliestControllerVersion(ctx context.Context) (version.Number, e } return j.EarliestControllerVersion_(ctx) } -func (j *JIMM) FindApplicationOffers(ctx context.Context, user *openfga.User, filters ...jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) { +func (j *JIMM) FindApplicationOffers(ctx context.Context, user *openfga.User, filters ...jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) { if j.FindApplicationOffers_ == nil { return nil, errors.E(errors.CodeNotImplemented) } @@ -266,7 +266,7 @@ func (j *JIMM) FullModelStatus(ctx context.Context, user *openfga.User, modelTag } return j.FullModelStatus_(ctx, user, modelTag, patterns) } -func (j *JIMM) GetApplicationOffer(ctx context.Context, user *openfga.User, offerURL string) (*jujuparams.ApplicationOfferAdminDetails, error) { +func (j *JIMM) GetApplicationOffer(ctx context.Context, user *openfga.User, offerURL string) (*jujuparams.ApplicationOfferAdminDetailsV5, error) { if j.GetApplicationOffer_ == nil { return nil, errors.E(errors.CodeNotImplemented) } @@ -394,7 +394,7 @@ func (j *JIMM) InitiateInternalMigration(ctx context.Context, user *openfga.User } return j.InitiateInternalMigration_(ctx, user, modelTag, targetController) } -func (j *JIMM) ListApplicationOffers(ctx context.Context, user *openfga.User, filters ...jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) { +func (j *JIMM) ListApplicationOffers(ctx context.Context, user *openfga.User, filters ...jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) { if j.ListApplicationOffers_ == nil { return nil, errors.E(errors.CodeNotImplemented) } diff --git a/internal/jujuapi/applicationoffers.go b/internal/jujuapi/applicationoffers.go index 245c91004..167e88687 100644 --- a/internal/jujuapi/applicationoffers.go +++ b/internal/jujuapi/applicationoffers.go @@ -114,7 +114,7 @@ func (r *controllerRoot) getConsumeDetails(ctx context.Context, user *openfga.Us } details := jujuparams.ConsumeOfferDetails{ - Offer: &jujuparams.ApplicationOfferDetails{ + Offer: &jujuparams.ApplicationOfferDetailsV5{ OfferURL: ourl.AsLocal().Path(), }, } @@ -125,9 +125,9 @@ func (r *controllerRoot) getConsumeDetails(ctx context.Context, user *openfga.Us } // ListApplicationOffers returns all offers matching the specified filters. -func (r *controllerRoot) ListApplicationOffers(ctx context.Context, args jujuparams.OfferFilters) (jujuparams.QueryApplicationOffersResults, error) { +func (r *controllerRoot) ListApplicationOffers(ctx context.Context, args jujuparams.OfferFilters) (jujuparams.QueryApplicationOffersResultsV5, error) { const op = errors.Op("jujuapi.ListApplicationOffers") - results := jujuparams.QueryApplicationOffersResults{} + results := jujuparams.QueryApplicationOffersResultsV5{} offers, err := r.jimm.ListApplicationOffers(ctx, r.user, args.Filters...) if err != nil { @@ -141,9 +141,9 @@ func (r *controllerRoot) ListApplicationOffers(ctx context.Context, args jujupar // FindApplicationOffers returns all offers matching the specified filters // as long as the user has read access to each offer. It also omits details // on users and connections. -func (r *controllerRoot) FindApplicationOffers(ctx context.Context, args jujuparams.OfferFilters) (jujuparams.QueryApplicationOffersResults, error) { +func (r *controllerRoot) FindApplicationOffers(ctx context.Context, args jujuparams.OfferFilters) (jujuparams.QueryApplicationOffersResultsV5, error) { const op = errors.Op("jujuapi.FindApplicationOffers") - results := jujuparams.QueryApplicationOffersResults{} + results := jujuparams.QueryApplicationOffersResultsV5{} offers, err := r.jimm.FindApplicationOffers(ctx, r.user, args.Filters...) if err != nil { diff --git a/internal/jujuapi/applicationoffers_test.go b/internal/jujuapi/applicationoffers_test.go index 10624bd1c..41f305eed 100644 --- a/internal/jujuapi/applicationoffers_test.go +++ b/internal/jujuapi/applicationoffers_test.go @@ -112,7 +112,7 @@ func (s *applicationOffersSuite) TestGetConsumeDetails(c *gc.C) { return details.Offer.Users[i].UserName < details.Offer.Users[j].UserName }) c.Check(details, gc.DeepEquals, jujuparams.ConsumeOfferDetails{ - Offer: &jujuparams.ApplicationOfferDetails{ + Offer: &jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: s.Model.Tag().String(), OfferURL: ourl.Path(), OfferName: "test-offer", @@ -156,7 +156,7 @@ func (s *applicationOffersSuite) TestGetConsumeDetails(c *gc.C) { return details.Offer.Users[j].UserName < details.Offer.Users[k].UserName }) c.Check(details, gc.DeepEquals, jujuparams.ConsumeOfferDetails{ - Offer: &jujuparams.ApplicationOfferDetails{ + Offer: &jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: s.Model.Tag().String(), OfferURL: ourl.Path(), OfferName: "test-offer", diff --git a/internal/jujuapi/controllerroot.go b/internal/jujuapi/controllerroot.go index ac8b84a8e..24207c542 100644 --- a/internal/jujuapi/controllerroot.go +++ b/internal/jujuapi/controllerroot.go @@ -45,7 +45,7 @@ type JIMM interface { DumpModel(ctx context.Context, u *openfga.User, mt names.ModelTag, simplified bool) (string, error) DumpModelDB(ctx context.Context, u *openfga.User, mt names.ModelTag) (map[string]interface{}, error) EarliestControllerVersion(ctx context.Context) (version.Number, error) - FindApplicationOffers(ctx context.Context, user *openfga.User, filters ...jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) + FindApplicationOffers(ctx context.Context, user *openfga.User, filters ...jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) FindAuditEvents(ctx context.Context, user *openfga.User, filter db.AuditLogFilter) ([]dbmodel.AuditLogEntry, error) ForEachCloud(ctx context.Context, user *openfga.User, f func(*dbmodel.Cloud) error) error ForEachModel(ctx context.Context, u *openfga.User, f func(*dbmodel.Model, jujuparams.UserAccessPermission) error) error @@ -53,7 +53,7 @@ type JIMM interface { ForEachUserCloudCredential(ctx context.Context, u *dbmodel.Identity, ct names.CloudTag, f func(cred *dbmodel.CloudCredential) error) error ForEachUserModel(ctx context.Context, u *openfga.User, f func(*dbmodel.Model, jujuparams.UserAccessPermission) error) error FullModelStatus(ctx context.Context, user *openfga.User, modelTag names.ModelTag, patterns []string) (*jujuparams.FullStatus, error) - GetApplicationOffer(ctx context.Context, user *openfga.User, offerURL string) (*jujuparams.ApplicationOfferAdminDetails, error) + GetApplicationOffer(ctx context.Context, user *openfga.User, offerURL string) (*jujuparams.ApplicationOfferAdminDetailsV5, error) GetApplicationOfferConsumeDetails(ctx context.Context, user *openfga.User, details *jujuparams.ConsumeOfferDetails, v bakery.Version) error GetCloud(ctx context.Context, u *openfga.User, tag names.CloudTag) (dbmodel.Cloud, error) GetCloudCredential(ctx context.Context, user *openfga.User, tag names.CloudCredentialTag) (*dbmodel.CloudCredential, error) @@ -74,7 +74,7 @@ type JIMM interface { ImportModel(ctx context.Context, user *openfga.User, controllerName string, modelTag names.ModelTag, newOwner string) error InitiateInternalMigration(ctx context.Context, user *openfga.User, modelTag names.ModelTag, targetController string) (jujuparams.InitiateMigrationResult, error) InitiateMigration(ctx context.Context, user *openfga.User, spec jujuparams.MigrationSpec, targetControllerID uint) (jujuparams.InitiateMigrationResult, error) - ListApplicationOffers(ctx context.Context, user *openfga.User, filters ...jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) + ListApplicationOffers(ctx context.Context, user *openfga.User, filters ...jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) ListGroups(ctx context.Context, user *openfga.User) ([]dbmodel.GroupEntry, error) ModelDefaultsForCloud(ctx context.Context, user *dbmodel.Identity, cloudTag names.CloudTag) (jujuparams.ModelDefaultsResult, error) ModelInfo(ctx context.Context, u *openfga.User, mt names.ModelTag) (*jujuparams.ModelInfo, error) diff --git a/internal/jujuapi/modelmanager_test.go b/internal/jujuapi/modelmanager_test.go index a8b6f7260..d65931031 100644 --- a/internal/jujuapi/modelmanager_test.go +++ b/internal/jujuapi/modelmanager_test.go @@ -34,7 +34,7 @@ import ( ofganames "github.com/canonical/jimm/internal/openfga/names" ) -const jujuVersion = "3.5-beta1" +const jujuVersion = "3.5-rc1" type modelManagerSuite struct { websocketSuite diff --git a/internal/jujuclient/applicationoffers.go b/internal/jujuclient/applicationoffers.go index fd1117cc5..6c1c78b81 100644 --- a/internal/jujuclient/applicationoffers.go +++ b/internal/jujuclient/applicationoffers.go @@ -64,14 +64,14 @@ func (c Connection) Offer(ctx context.Context, offerURL crossmodel.OfferURL, off // ListApplicationOffers lists ApplicationOffers on the controller matching // the given filters. ListApplicationOffers uses the ListApplicationOffers // procedure on the ApplicationOffers facade. -func (c Connection) ListApplicationOffers(ctx context.Context, filters []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) { +func (c Connection) ListApplicationOffers(ctx context.Context, filters []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) { const op = errors.Op("jujuclient.ListApplicationOffers") args := jujuparams.OfferFilters{ Filters: filters, } - var resp jujuparams.QueryApplicationOffersResults - err := c.CallHighestFacadeVersion(ctx, "ApplicationOffers", []int{4, 2}, "", "ListApplicationOffers", &args, &resp) + var resp jujuparams.QueryApplicationOffersResultsV5 + err := c.CallHighestFacadeVersion(ctx, "ApplicationOffers", []int{5, 4}, "", "ListApplicationOffers", &args, &resp) if err != nil { return nil, errors.E(op, jujuerrors.Cause(err)) } @@ -81,14 +81,14 @@ func (c Connection) ListApplicationOffers(ctx context.Context, filters []jujupar // FindApplicationOffers finds ApplicationOffers on the controller matching // the given filters. FindApplicationOffers uses the FindApplicationOffers // procedure on the ApplicationOffers facade. -func (c Connection) FindApplicationOffers(ctx context.Context, filters []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error) { +func (c Connection) FindApplicationOffers(ctx context.Context, filters []jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetailsV5, error) { const op = errors.Op("jujuclient.FindApplicationOffers") args := jujuparams.OfferFilters{ Filters: filters, } - var resp jujuparams.QueryApplicationOffersResults - err := c.CallHighestFacadeVersion(ctx, "ApplicationOffers", []int{4, 2}, "", "FindApplicationOffers", &args, &resp) + var resp jujuparams.QueryApplicationOffersResultsV5 + err := c.CallHighestFacadeVersion(ctx, "ApplicationOffers", []int{5, 4}, "", "FindApplicationOffers", &args, &resp) if err != nil { return nil, errors.E(op, jujuerrors.Cause(err)) } @@ -100,7 +100,7 @@ func (c Connection) FindApplicationOffers(ctx context.Context, filters []jujupar // OfferURL the rest of the structure will be filled in by the API request. // GetApplicationOffer uses the ApplicationOffers procedure on the // ApplicationOffers facade. -func (c Connection) GetApplicationOffer(ctx context.Context, info *jujuparams.ApplicationOfferAdminDetails) error { +func (c Connection) GetApplicationOffer(ctx context.Context, info *jujuparams.ApplicationOfferAdminDetailsV5) error { const op = errors.Op("jujuclient.GetApplicationOffer") args := jujuparams.OfferURLs{ OfferURLs: []string{info.OfferURL}, @@ -109,7 +109,7 @@ func (c Connection) GetApplicationOffer(ctx context.Context, info *jujuparams.Ap resp := jujuparams.ApplicationOffersResults{ Results: make([]jujuparams.ApplicationOfferResult, 1), } - err := c.CallHighestFacadeVersion(ctx, "ApplicationOffers", []int{4, 2}, "", "ApplicationOffers", &args, &resp) + err := c.CallHighestFacadeVersion(ctx, "ApplicationOffers", []int{5, 4}, "", "ApplicationOffers", &args, &resp) if err != nil { return errors.E(op, jujuerrors.Cause(err)) } @@ -137,7 +137,7 @@ func (c Connection) GrantApplicationOfferAccess(ctx context.Context, offerURL st resp := jujuparams.ErrorResults{ Results: make([]jujuparams.ErrorResult, 1), } - err := c.CallHighestFacadeVersion(ctx, "ApplicationOffers", []int{4, 2}, "", "ModifyOfferAccess", &args, &resp) + err := c.CallHighestFacadeVersion(ctx, "ApplicationOffers", []int{5, 4}, "", "ModifyOfferAccess", &args, &resp) if err != nil { return errors.E(op, jujuerrors.Cause(err)) } @@ -164,7 +164,7 @@ func (c Connection) RevokeApplicationOfferAccess(ctx context.Context, offerURL s resp := jujuparams.ErrorResults{ Results: make([]jujuparams.ErrorResult, 1), } - err := c.CallHighestFacadeVersion(ctx, "ApplicationOffers", []int{4, 2}, "", "ModifyOfferAccess", &args, &resp) + err := c.CallHighestFacadeVersion(ctx, "ApplicationOffers", []int{5, 4}, "", "ModifyOfferAccess", &args, &resp) if err != nil { return errors.E(op, jujuerrors.Cause(err)) } @@ -187,7 +187,7 @@ func (c Connection) DestroyApplicationOffer(ctx context.Context, offer string, f resp := jujuparams.ErrorResults{ Results: make([]jujuparams.ErrorResult, 1), } - err := c.CallHighestFacadeVersion(ctx, "ApplicationOffers", []int{4, 2}, "", "DestroyOffers", &args, &resp) + err := c.CallHighestFacadeVersion(ctx, "ApplicationOffers", []int{5, 4}, "", "DestroyOffers", &args, &resp) if err != nil { return errors.E(op, jujuerrors.Cause(err)) } diff --git a/internal/jujuclient/applicationoffers_test.go b/internal/jujuclient/applicationoffers_test.go index 0f78ec0b9..b2e1d599b 100644 --- a/internal/jujuclient/applicationoffers_test.go +++ b/internal/jujuclient/applicationoffers_test.go @@ -164,7 +164,7 @@ func (s *applicationoffersSuite) TestListApplicationOffersMatching(c *gc.C) { ) c.Assert(err, gc.Equals, nil) - var info jujuparams.ApplicationOfferAdminDetails + var info jujuparams.ApplicationOfferAdminDetailsV5 info.OfferURL = offerURL.String() err = s.API.GetApplicationOffer(ctx, &info) c.Assert(err, gc.Equals, nil) @@ -176,7 +176,7 @@ func (s *applicationoffersSuite) TestListApplicationOffersMatching(c *gc.C) { ModelName: s.modelInfo.Name, }}) c.Assert(err, gc.Equals, nil) - c.Check(offers, gc.DeepEquals, []jujuparams.ApplicationOfferAdminDetails{info}) + c.Check(offers, gc.DeepEquals, []jujuparams.ApplicationOfferAdminDetailsV5{info}) } func (s *applicationoffersSuite) TestListApplicationOffersNoMatch(c *gc.C) { @@ -280,7 +280,7 @@ func (s *applicationoffersSuite) TestFindApplicationOffersMatching(c *gc.C) { ) c.Assert(err, gc.Equals, nil) - var info jujuparams.ApplicationOfferAdminDetails + var info jujuparams.ApplicationOfferAdminDetailsV5 info.OfferURL = offerURL.String() err = s.API.GetApplicationOffer(ctx, &info) c.Assert(err, gc.Equals, nil) @@ -292,7 +292,7 @@ func (s *applicationoffersSuite) TestFindApplicationOffersMatching(c *gc.C) { ModelName: s.modelInfo.Name, }}) c.Assert(err, gc.Equals, nil) - c.Check(offers, gc.DeepEquals, []jujuparams.ApplicationOfferAdminDetails{info}) + c.Check(offers, gc.DeepEquals, []jujuparams.ApplicationOfferAdminDetailsV5{info}) } func (s *applicationoffersSuite) TestFindApplicationOffersNoMatch(c *gc.C) { @@ -380,7 +380,7 @@ func (s *applicationoffersSuite) TestGetApplicationOffer(c *gc.C) { ) c.Assert(err, gc.Equals, nil) - var info jujuparams.ApplicationOfferAdminDetails + var info jujuparams.ApplicationOfferAdminDetailsV5 info.OfferURL = offerURL.String() err = s.API.GetApplicationOffer(ctx, &info) c.Assert(err, gc.Equals, nil) @@ -392,8 +392,8 @@ func (s *applicationoffersSuite) TestGetApplicationOffer(c *gc.C) { }) c.Check(info.CharmURL, gc.Matches, `ch:amd64/quantal/wordpress-[0-9]*`) info.CharmURL = "" - c.Check(info, jc.DeepEquals, jujuparams.ApplicationOfferAdminDetails{ - ApplicationOfferDetails: jujuparams.ApplicationOfferDetails{ + c.Check(info, jc.DeepEquals, jujuparams.ApplicationOfferAdminDetailsV5{ + ApplicationOfferDetailsV5: jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: names.NewModelTag(s.modelInfo.UUID).String(), OfferURL: offerURL.String(), OfferName: "test-offer", @@ -420,7 +420,7 @@ func (s *applicationoffersSuite) TestGetApplicationOffer(c *gc.C) { func (s *applicationoffersSuite) TestGetApplicationOfferNotFound(c *gc.C) { ctx := context.Background() - var info jujuparams.ApplicationOfferAdminDetails + var info jujuparams.ApplicationOfferAdminDetailsV5 info.OfferURL = "test-user@canonical.com/test-model.test-offer" err := s.API.GetApplicationOffer(ctx, &info) c.Assert(err, gc.ErrorMatches, `application offer "test-user@canonical.com/test-model.test-offer" not found`) @@ -466,7 +466,7 @@ func (s *applicationoffersSuite) TestGrantApplicationOfferAccess(c *gc.C) { err = s.API.GrantApplicationOfferAccess(ctx, offerURL.String(), names.NewUserTag("test-user-2@canonical.com"), jujuparams.OfferConsumeAccess) c.Assert(err, gc.Equals, nil) - var info jujuparams.ApplicationOfferAdminDetails + var info jujuparams.ApplicationOfferAdminDetailsV5 info.OfferURL = offerURL.String() err = s.API.GetApplicationOffer(ctx, &info) c.Assert(err, gc.Equals, nil) @@ -477,8 +477,8 @@ func (s *applicationoffersSuite) TestGrantApplicationOfferAccess(c *gc.C) { }) c.Check(info.CharmURL, gc.Matches, `ch:amd64/quantal/wordpress-[0-9]*`) info.CharmURL = "" - c.Check(info, jc.DeepEquals, jujuparams.ApplicationOfferAdminDetails{ - ApplicationOfferDetails: jujuparams.ApplicationOfferDetails{ + c.Check(info, jc.DeepEquals, jujuparams.ApplicationOfferAdminDetailsV5{ + ApplicationOfferDetailsV5: jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: names.NewModelTag(s.modelInfo.UUID).String(), OfferURL: offerURL.String(), OfferName: "test-offer", @@ -553,7 +553,7 @@ func (s *applicationoffersSuite) TestRevokeApplicationOfferAccess(c *gc.C) { err = s.API.GrantApplicationOfferAccess(ctx, offerURL.String(), names.NewUserTag("test-user-2@canonical.com"), jujuparams.OfferConsumeAccess) c.Assert(err, gc.Equals, nil) - var info jujuparams.ApplicationOfferAdminDetails + var info jujuparams.ApplicationOfferAdminDetailsV5 info.OfferURL = offerURL.String() err = s.API.GetApplicationOffer(ctx, &info) c.Assert(err, gc.Equals, nil) @@ -565,8 +565,8 @@ func (s *applicationoffersSuite) TestRevokeApplicationOfferAccess(c *gc.C) { }) c.Check(info.CharmURL, gc.Matches, `ch:amd64/quantal/wordpress-[0-9]*`) info.CharmURL = "" - c.Check(info, jc.DeepEquals, jujuparams.ApplicationOfferAdminDetails{ - ApplicationOfferDetails: jujuparams.ApplicationOfferDetails{ + c.Check(info, jc.DeepEquals, jujuparams.ApplicationOfferAdminDetailsV5{ + ApplicationOfferDetailsV5: jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: names.NewModelTag(s.modelInfo.UUID).String(), OfferURL: "test-user@canonical.com/test-model.test-offer", OfferName: "test-offer", @@ -604,8 +604,8 @@ func (s *applicationoffersSuite) TestRevokeApplicationOfferAccess(c *gc.C) { }) c.Check(info.CharmURL, gc.Matches, `ch:amd64/quantal/wordpress-[0-9]*`) info.CharmURL = "" - c.Check(info, jc.DeepEquals, jujuparams.ApplicationOfferAdminDetails{ - ApplicationOfferDetails: jujuparams.ApplicationOfferDetails{ + c.Check(info, jc.DeepEquals, jujuparams.ApplicationOfferAdminDetailsV5{ + ApplicationOfferDetailsV5: jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: names.NewModelTag(s.modelInfo.UUID).String(), OfferURL: offerURL.String(), OfferName: "test-offer", @@ -735,7 +735,7 @@ func (s *applicationoffersSuite) TestGetApplicationOfferConsumeDetails(c *gc.C) c.Assert(err, gc.Equals, nil) var info jujuparams.ConsumeOfferDetails - info.Offer = &jujuparams.ApplicationOfferDetails{ + info.Offer = &jujuparams.ApplicationOfferDetailsV5{ OfferURL: offerURL.String(), } err = s.API.GetApplicationOfferConsumeDetails(ctx, names.NewUserTag("admin"), &info, bakery.Version2) @@ -748,7 +748,7 @@ func (s *applicationoffersSuite) TestGetApplicationOfferConsumeDetails(c *gc.C) return a.UserName < b.UserName } c.Check(info, jimmtest.CmpEquals(cmpopts.SortSlices(lessF)), jujuparams.ConsumeOfferDetails{ - Offer: &jujuparams.ApplicationOfferDetails{ + Offer: &jujuparams.ApplicationOfferDetailsV5{ SourceModelTag: names.NewModelTag(s.modelInfo.UUID).String(), OfferURL: "test-user@canonical.com/test-model.test-offer", OfferName: "test-offer", @@ -779,7 +779,7 @@ func (s *applicationoffersSuite) TestGetApplicationOfferConsumeDetails(c *gc.C) func (s *applicationoffersSuite) TestGetApplicationOfferConsumeDetailsNotFound(c *gc.C) { var info jujuparams.ConsumeOfferDetails - info.Offer = &jujuparams.ApplicationOfferDetails{ + info.Offer = &jujuparams.ApplicationOfferDetailsV5{ OfferURL: "test-user@canonical.com/test-model.test-offer", } err := s.API.GetApplicationOfferConsumeDetails(context.Background(), names.NewUserTag("test-user@canonical.com"), &info, bakery.Version2)