Skip to content

Commit

Permalink
Merged main and removed conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
kian99 committed Jul 3, 2023
2 parents 475cc83 + b8373d8 commit 7723598
Show file tree
Hide file tree
Showing 24 changed files with 80 additions and 135 deletions.
1 change: 1 addition & 0 deletions .air.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ tmp_dir = "tmp"

[log]
time = false
main_only = true

[misc]
clean_on_exit = false
Expand Down
4 changes: 2 additions & 2 deletions charms/jimm-k8s/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def _update_workload(self, event):
if dashboard_relation and self.unit.is_leader():
dashboard_relation.data[self.app].update(
{
"controller-url": dns_name,
"controller-url": "wss://{}".format(dns_name),
"identity-provider-url": self.config.get("candid-url"),
"is-juju": str(False),
}
Expand Down Expand Up @@ -347,7 +347,7 @@ def _on_dashboard_relation_joined(self, event: RelationJoinedEvent):

event.relation.data[self.app].update(
{
"controller-url": dns_name,
"controller-url": "wss://{}".format(dns_name),
"identity-provider-url": self.config["candid-url"],
"is-juju": str(False),
}
Expand Down
2 changes: 1 addition & 1 deletion charms/jimm-k8s/tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def test_dashboard_relation_joined(self):
self.assertTrue(data)
self.assertEqual(
data["controller-url"],
"juju-jimm-k8s-0.juju-jimm-k8s-endpoints.None.svc.cluster.local",
"wss://juju-jimm-k8s-0.juju-jimm-k8s-endpoints.None.svc.cluster.local",
)
self.assertEqual(data["identity-provider-url"], "https://candid.example.com")
self.assertEqual(data["is-juju"], "False")
Expand Down
1 change: 1 addition & 0 deletions charms/jimm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ juju deploy openfga
juju add-relation juju-jimm:openfga postgresql:openfga
```


## Developing

Create and activate a virtualenv with the development requirements:
Expand Down
17 changes: 10 additions & 7 deletions charms/jimm/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ type: "charm"
parts:
charm:
prime:
- ./templates
- ./files
- README.md
- ./templates
- ./files
- README.md
charm-python-packages: [setuptools]
charm-binary-python-packages:
- pydantic
- cosl
bases:
# Ensure run-on is the same or newer than build-on
# since jimm-server is a Go binary using CGO dependencies
- build-on:
- name: "ubuntu"
channel: "20.04"
- name: "ubuntu"
channel: "20.04"
run-on:
- name: "ubuntu"
channel: "20.04"
- name: "ubuntu"
channel: "20.04"
2 changes: 1 addition & 1 deletion charms/jimm/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ issues: https://github.com/canonical/jimm/issues

description: |
JIMM is a juju controller, used in conjunction with the JaaS dashboard to provide a seamless way
to manage models, regardless of where their controllers reside or what cloud they may be running on.
to manage models, regardless of where their controllers reside or what cloud they may be running on.
provides:
website:
Expand Down
2 changes: 1 addition & 1 deletion charms/jimm/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Jinja2 >= 2.11.3
ops >= 2.0.0
charmhelpers >= 0.20.22
hvac >= 0.11.0
pydantic
pydantic == 1.10.10
cosl
5 changes: 2 additions & 3 deletions charms/jimm/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ def _on_config_changed(self, _):

with open(self._env_filename(), "wt") as f:
f.write(self._render_template("jimm.env", **args))

if self._ready():
self.restart()
self._on_update_status(None)
Expand All @@ -151,7 +150,7 @@ def _on_config_changed(self, _):
if dashboard_relation:
dashboard_relation.data[self.app].update(
{
"controller-url": self.config["dns-name"],
"controller-url": "wss://{}".format(self.config["dns-name"]),
"identity-provider-url": self.config["candid-url"],
"is-juju": str(False),
}
Expand Down Expand Up @@ -399,7 +398,7 @@ def _snap(self, *args):
def _on_dashboard_relation_joined(self, event):
event.relation.data[self.app].update(
{
"controller-url": self.config["dns-name"],
"controller-url": "wss://{}".format(self.config["dns-name"]),
"identity-provider-url": self.config["candid-url"],
"is-juju": str(False),
}
Expand Down
4 changes: 2 additions & 2 deletions charms/jimm/tests/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def test_dashboard_relation_joined(self):
harness.charm._agent_filename = tmp.name
harness.update_config(
{
"dns-name": "https://jimm.example.com",
"dns-name": "jimm.example.com",
"candid-agent-username": "username@candid",
"candid-agent-private-key": "agent-private-key",
"candid-agent-public-key": "agent-public-key",
Expand All @@ -526,7 +526,7 @@ def test_dashboard_relation_joined(self):
harness.add_relation_unit(id, "juju-dashboard/0")
data = harness.get_relation_data(id, "juju-jimm")
self.assertTrue(data)
self.assertEqual(data["controller-url"], "https://jimm.example.com")
self.assertEqual(data["controller-url"], "wss://jimm.example.com")
self.assertEqual(data["identity-provider-url"], "https://candid.example.com")
self.assertEqual(data["is-juju"], "False")

Expand Down
1 change: 0 additions & 1 deletion charms/jimm/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ envlist = lint, unit
[vars]
src_path = {toxinidir}/src/
tst_path = {toxinidir}/tests/
;lib_path = {toxinidir}/lib/charms/operator_name_with_underscores
all_path = {[vars]src_path} {[vars]tst_path}

[testenv]
Expand Down
2 changes: 1 addition & 1 deletion cmd/jimmctl/cmd/modelstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (c *modelStatusCommand) SetFlags(f *gnuflag.FlagSet) {

// Init implements the cmd.Command interface.
func (c *modelStatusCommand) Init(args []string) error {
if len(args) < 0 {
if len(args) < 1 {
return errors.E("missing model uuid")
}
c.modelUUID, args = args[0], args[1:]
Expand Down
9 changes: 4 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ services:
ports:
- 17070:80
environment:
JIMM_LOG_LEVEL: "debug"
JIMM_UUID: "3217dbc9-8ea9-4381-9e97-01eab0b3f6bb"
JIMM_DSN: "postgresql://jimm:jimm@db/jimm"
CANDID_URL: "http://0.0.0.0:8081" # For external client redirects (in the case of compose and running outside)
Expand Down Expand Up @@ -78,9 +79,9 @@ services:
condition: service_healthy
labels:
traefik.enable: true
traefik.http.routers.httpd.rule: Host(`jimm.localhost`)
traefik.http.routers.httpd.entrypoints: websecure
traefik.http.routers.httpd.tls: true
traefik.http.routers.jimm.rule: Host(`jimm.localhost`)
traefik.http.routers.jimm.entrypoints: websecure
traefik.http.routers.jimm.tls: true

db:
image: postgres
Expand Down Expand Up @@ -134,8 +135,6 @@ services:
image: candid:latest
container_name: candid
entrypoint: "/candid.sh"
command: ""
# command: "/etc/candid/config.yaml && echo 'hi' && ls"
expose:
- 8081
ports:
Expand Down
1 change: 0 additions & 1 deletion internal/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func Handler(ctx context.Context, loc string) http.Handler {
)
continue
}

type guiArchiveVersion struct {
// Version holds the Juju GUI version number.
Version version.Number `json:"version"`
Expand Down
1 change: 0 additions & 1 deletion internal/dashboard/dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ func TestGUIArchiveEndpoint(t *testing.T) {
c.Check(resp.StatusCode, qt.Equals, http.StatusOK)
buf, err := io.ReadAll(resp.Body)
c.Assert(err, qt.IsNil)

c.Check(
string(buf),
qt.Equals,
Expand Down
2 changes: 1 addition & 1 deletion internal/jimm/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ users:
CloudRegion: "test-region-1",
CloudCredentialTag: names.NewCloudCredentialTag("test-cloud/alice@external/test-credential-1").String(),
},
expectError: "failed to update cloud credential: a silly error",
expectError: "failed to update cloud credential",
}}

func TestAddModel(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/jujuapi/applicationoffers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func init() {
r.AddMethod("ApplicationOffers", 4, "FindApplicationOffers", findOffersMethod)
r.AddMethod("ApplicationOffers", 4, "ApplicationOffers", applicationOffersMethod)

return []int{1, 2, 3}
return []int{1, 2, 3, 4}
}
}

Expand Down
1 change: 1 addition & 0 deletions internal/jujuapi/jimm.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func init() {
r.AddMethod("JIMM", 3, "UpdateMigratedModel", updateMigratedModelMethod)
r.AddMethod("JIMM", 3, "AddCloudToController", addCloudToControllerMethod)
r.AddMethod("JIMM", 3, "RemoveCloudFromController", removeCloudFromControllerMethod)
r.AddMethod("JIMM", 3, "CrossModelQuery", crossModelQueryMethod)

// JIMM Generic RPC
r.AddMethod("JIMM", 4, "AddController", addControllerMethod)
Expand Down
11 changes: 10 additions & 1 deletion internal/jujuapi/modelmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ func (s *modelManagerSuite) TestModelInfo(c *gc.C) {
Description: "the version of Juju used by the model",
Version: jujuVersion,
}},
DefaultBase: "[email protected]/stable",

Check failure on line 348 in internal/jujuapi/modelmanager_test.go

View workflow job for this annotation

GitHub Actions / Build and Test

duplicate field name DefaultBase in struct literal
},
}, {
Error: &jujuparams.Error{
Expand Down Expand Up @@ -381,6 +382,7 @@ func (s *modelManagerSuite) TestModelInfo(c *gc.C) {
Description: "the version of Juju used by the model",
Version: jujuVersion,
}},
DefaultBase: "[email protected]/stable",

Check failure on line 385 in internal/jujuapi/modelmanager_test.go

View workflow job for this annotation

GitHub Actions / Build and Test

duplicate field name DefaultBase in struct literal
},
}, {
Result: &jujuparams.ModelInfo{
Expand Down Expand Up @@ -433,6 +435,7 @@ func (s *modelManagerSuite) TestModelInfo(c *gc.C) {
Description: "the version of Juju used by the model",
Version: jujuVersion,
}},
DefaultBase: "[email protected]/stable",

Check failure on line 438 in internal/jujuapi/modelmanager_test.go

View workflow job for this annotation

GitHub Actions / Build and Test

duplicate field name DefaultBase in struct literal
},
}, {
Result: &jujuparams.ModelInfo{
Expand Down Expand Up @@ -470,6 +473,7 @@ func (s *modelManagerSuite) TestModelInfo(c *gc.C) {
Description: "the version of Juju used by the model",
Version: jujuVersion,
}},
DefaultBase: "[email protected]/stable",

Check failure on line 476 in internal/jujuapi/modelmanager_test.go

View workflow job for this annotation

GitHub Actions / Build and Test

duplicate field name DefaultBase in struct literal
},
}, {
Error: &jujuparams.Error{
Expand Down Expand Up @@ -575,6 +579,7 @@ func (s *modelManagerSuite) TestModelInfoDisableControllerUUIDMasking(c *gc.C) {
Description: "the version of Juju used by the model",
Version: jujuVersion,
}},
DefaultBase: "[email protected]/stable",

Check failure on line 582 in internal/jujuapi/modelmanager_test.go

View workflow job for this annotation

GitHub Actions / Build and Test

duplicate field name DefaultBase in struct literal
},
}, {
Result: &jujuparams.ModelInfo{
Expand Down Expand Up @@ -612,6 +617,7 @@ func (s *modelManagerSuite) TestModelInfoDisableControllerUUIDMasking(c *gc.C) {
Description: "the version of Juju used by the model",
Version: jujuVersion,
}},
DefaultBase: "[email protected]/stable",

Check failure on line 620 in internal/jujuapi/modelmanager_test.go

View workflow job for this annotation

GitHub Actions / Build and Test

duplicate field name DefaultBase in struct literal
},
}, {
Result: &jujuparams.ModelInfo{
Expand Down Expand Up @@ -670,6 +676,7 @@ func (s *modelManagerSuite) TestModelInfoDisableControllerUUIDMasking(c *gc.C) {
Description: "the version of Juju used by the model",
Version: jujuVersion,
}},
DefaultBase: "[email protected]/stable",

Check failure on line 679 in internal/jujuapi/modelmanager_test.go

View workflow job for this annotation

GitHub Actions / Build and Test

duplicate field name DefaultBase in struct literal
},
}, {
Result: &jujuparams.ModelInfo{
Expand Down Expand Up @@ -728,6 +735,7 @@ func (s *modelManagerSuite) TestModelInfoDisableControllerUUIDMasking(c *gc.C) {
Description: "the version of Juju used by the model",
Version: jujuVersion,
}},
DefaultBase: "[email protected]/stable",

Check failure on line 738 in internal/jujuapi/modelmanager_test.go

View workflow job for this annotation

GitHub Actions / Build and Test

duplicate field name DefaultBase in struct literal
},
}, {
Result: &jujuparams.ModelInfo{
Expand Down Expand Up @@ -765,6 +773,7 @@ func (s *modelManagerSuite) TestModelInfoDisableControllerUUIDMasking(c *gc.C) {
Description: "the version of Juju used by the model",
Version: jujuVersion,
}},
DefaultBase: "[email protected]/stable",

Check failure on line 776 in internal/jujuapi/modelmanager_test.go

View workflow job for this annotation

GitHub Actions / Build and Test

duplicate field name DefaultBase in struct literal
},
}, {
Error: &jujuparams.Error{
Expand Down Expand Up @@ -810,7 +819,7 @@ var createModelTests = []struct {
region: "no-such-region",
cloudTag: names.NewCloudTag(jimmtest.TestCloudName).String(),
credentialTag: "",
expectError: `cloudregion not found \(not found\)`,
expectError: `failed to set cloud region \(not found\)`,
}, {
about: "local user",
name: "model-4",
Expand Down
1 change: 0 additions & 1 deletion internal/jujuclient/modelmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ func (s *modelmanagerSuite) TestRevokeModelAccessError(c *gc.C) {

func (s *modelmanagerSuite) TestValidateModelUpgrade(c *gc.C) {
c.Skip("juju 3.x no longer implements this method")

ctx := context.Background()

args := jujuparams.ModelCreateArgs{
Expand Down
Loading

0 comments on commit 7723598

Please sign in to comment.