Skip to content

Commit

Permalink
Add storage pool state and service packages for managing storage pools.
Browse files Browse the repository at this point in the history
  • Loading branch information
wallyworld committed Feb 29, 2024
1 parent abd7f3e commit 61b0c33
Show file tree
Hide file tree
Showing 17 changed files with 1,510 additions and 33 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions domain/servicefactory/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ import (
networkstate "github.com/juju/juju/domain/network/state"
objectstoreservice "github.com/juju/juju/domain/objectstore/service"
objectstorestate "github.com/juju/juju/domain/objectstore/state"
storageservice "github.com/juju/juju/domain/storage/service"
storagestate "github.com/juju/juju/domain/storage/state"
unitservice "github.com/juju/juju/domain/unit/service"
unitstate "github.com/juju/juju/domain/unit/state"
"github.com/juju/juju/internal/storage"
)

// ModelFactory provides access to the services required by the apiserver.
Expand Down Expand Up @@ -114,3 +117,12 @@ func (s *ModelFactory) Annotation() *annotationService.Service {
annotationState.NewState(changestream.NewTxnRunnerFactory(s.modelDB)),
)
}

// Storage returns the model's storage service.
func (s *ModelFactory) Storage(registry storage.ProviderRegistry) *storageservice.Service {
return storageservice.NewService(
storagestate.NewState(changestream.NewTxnRunnerFactory(s.modelDB)),
s.logger.Child("storage"),
registry,
)
}
7 changes: 7 additions & 0 deletions domain/servicefactory/testing/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ import (
modelmanagerservice "github.com/juju/juju/domain/modelmanager/service"
networkservice "github.com/juju/juju/domain/network/service"
objectstoreservice "github.com/juju/juju/domain/objectstore/service"
storageservice "github.com/juju/juju/domain/storage/service"
unitservice "github.com/juju/juju/domain/unit/service"
upgradeservice "github.com/juju/juju/domain/upgrade/service"
userservice "github.com/juju/juju/domain/user/service"
"github.com/juju/juju/internal/servicefactory"
"github.com/juju/juju/internal/storage"
)

// TestingServiceFactory provides access to the services required by the apiserver.
Expand Down Expand Up @@ -133,6 +135,11 @@ func (s *TestingServiceFactory) Annotation() *annotationservice.Service {
return nil
}

// Storage returns the storage service.
func (s *TestingServiceFactory) Storage(storage.ProviderRegistry) *storageservice.Service {
return nil
}

// FactoryForModel returns a service factory for the given model uuid.
// This will late bind the model service factory to the actual service factory.
func (s *TestingServiceFactory) FactoryForModel(modelUUID string) servicefactory.ServiceFactory {
Expand Down
15 changes: 15 additions & 0 deletions domain/storage/errors/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2024 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package errors

import (
"github.com/juju/errors"
)

const (
// MissingPoolTypeError is used when a provider type is empty.
MissingPoolTypeError = errors.ConstError("pool provider type is missing")
// MissingPoolNameError is used when a name is empty.
MissingPoolNameError = errors.ConstError("pool name is missing")
)
14 changes: 14 additions & 0 deletions domain/storage/package_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2024 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package storage

import (
"testing"

gc "gopkg.in/check.v1"
)

func TestPackage(t *testing.T) {
gc.TestingT(t)
}
15 changes: 15 additions & 0 deletions domain/storage/service/package_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2024 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package service

import (
"testing"

gc "gopkg.in/check.v1"
)

//go:generate go run go.uber.org/mock/mockgen -package service -destination state_mock_test.go github.com/juju/juju/domain/storage/service State
func TestPackage(t *testing.T) {
gc.TestingT(t)
}
Loading

0 comments on commit 61b0c33

Please sign in to comment.