Skip to content

Commit

Permalink
Merge pull request juju#16975 from wallyworld/storage-pool-domain
Browse files Browse the repository at this point in the history
juju#16975

This PR adds the domain and service packages for managing storage pools. The main use cases to support are CRUD from the CLI (including querying based on a names and types filter), as well as getting a pool by name for use in the provisioning and deploy facades.

The service needs a registry representing the valid storage provisioners for the current model - this is passed in when the service is constructed.

## QA steps

just unit tests at this stage

## Links

**Jira card:** JUJU-5579
  • Loading branch information
jujubot authored Mar 1, 2024
2 parents 8e088f3 + 1868c55 commit 18671a8
Show file tree
Hide file tree
Showing 17 changed files with 1,606 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
21 changes: 21 additions & 0 deletions domain/storage/errors/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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 empty")
// MissingPoolNameError is used when a name is empty.
MissingPoolNameError = errors.ConstError("pool name is empty")

InvalidPoolNameError = errors.ConstError("pool name is not valid")

PoolNotFoundError = errors.ConstError("storage pool is not found")

PoolAlreadyExists = errors.ConstError("storage pool already exists")
)
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 18671a8

Please sign in to comment.