Skip to content

Commit

Permalink
Renamed intialTasks -> initialtasks
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardGomezEscandell committed Mar 20, 2023
1 parent 14ab485 commit 7c8594f
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 38 deletions.
6 changes: 3 additions & 3 deletions windows-agent/internal/distros/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/consts"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/distro"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialTasks"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialtasks"
log "github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/grpc/logstreamer"
"gopkg.in/yaml.v3"
)
Expand All @@ -35,7 +35,7 @@ type DistroDB struct {
scheduleTrigger chan struct{}

storageDir string
initialTasks *initialTasks.InitialTasks
initialTasks *initialtasks.InitialTasks
}

// New creates a database and populates it with data in the file located
Expand All @@ -47,7 +47,7 @@ type DistroDB struct {
// Every certain amount of times, the database wil purge all distros that
// are no longer registered or that have been marked as unreachable. This
// cleanup can be triggered on demmand with TriggerCleanup.
func New(storageDir string, initialTasks *initialTasks.InitialTasks) (*DistroDB, error) {
func New(storageDir string, initialTasks *initialtasks.InitialTasks) (*DistroDB, error) {
if err := os.MkdirAll(storageDir, 0600); err != nil {
return nil, fmt.Errorf("could not create database directory: %w", err)
}
Expand Down
10 changes: 5 additions & 5 deletions windows-agent/internal/distros/distro/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"sync/atomic"

"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialTasks"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialtasks"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/task"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/worker"
log "github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/grpc/logstreamer"
Expand Down Expand Up @@ -56,9 +56,9 @@ func (*NotValidError) Error() string {

type options struct {
guid windows.GUID
initialTasks *initialTasks.InitialTasks
initialTasks *initialtasks.InitialTasks
taskProcessingContext context.Context
newWorkerFunc func(context.Context, *Distro, string, *initialTasks.InitialTasks) (workerInterface, error)
newWorkerFunc func(context.Context, *Distro, string, *initialtasks.InitialTasks) (workerInterface, error)
}

// Option is an optional argument for distro.New.
Expand All @@ -74,7 +74,7 @@ func WithGUID(guid windows.GUID) Option {

// WithInitialTasks is an optional parameter for distro.New so that the
// distro con perform the tasks expected from any new distro.
func WithInitialTasks(i *initialTasks.InitialTasks) Option {
func WithInitialTasks(i *initialtasks.InitialTasks) Option {
return func(o *options) {
o.initialTasks = i
}
Expand All @@ -96,7 +96,7 @@ func New(name string, props Properties, storageDir string, args ...Option) (dist
opts := options{
guid: nilGUID,
taskProcessingContext: context.Background(),
newWorkerFunc: func(ctx context.Context, d *Distro, dir string, init *initialTasks.InitialTasks) (workerInterface, error) {
newWorkerFunc: func(ctx context.Context, d *Distro, dir string, init *initialtasks.InitialTasks) (workerInterface, error) {
return worker.New(ctx, d, dir, worker.WithInitialTasks(init))
},
}
Expand Down
8 changes: 4 additions & 4 deletions windows-agent/internal/distros/distro/distro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"

"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/distro"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialTasks"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialtasks"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/task"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/testutils"
"github.com/canonical/ubuntu-pro-for-windows/wslserviceapi"
Expand Down Expand Up @@ -244,7 +244,7 @@ func TestWorkerConstruction(t *testing.T) {
withMockWorker, worker := mockWorkerInjector(tc.constructorReturnErr)

workDir := t.TempDir()
initialTasks, err := initialTasks.New(workDir)
initialTasks, err := initialtasks.New(workDir)
require.NoError(t, err, "Setup: initialTasks should construct without issues")

d, err := distro.New(distroName,
Expand Down Expand Up @@ -398,7 +398,7 @@ type mockWorker struct {
newCtx context.Context
newDistro *distro.Distro
newDir string
newInit *initialTasks.InitialTasks
newInit *initialtasks.InitialTasks

isActiveCalled bool
clientCalled bool
Expand All @@ -409,7 +409,7 @@ type mockWorker struct {

func mockWorkerInjector(constructorReturnsError bool) (distro.Option, **mockWorker) {
worker := new(*mockWorker)
newMockWorker := func(ctx context.Context, d *distro.Distro, tmpDir string, init *initialTasks.InitialTasks) (distro.Worker, error) {
newMockWorker := func(ctx context.Context, d *distro.Distro, tmpDir string, init *initialtasks.InitialTasks) (distro.Worker, error) {
w := &mockWorker{
newCtx: ctx,
newDistro: d,
Expand Down
4 changes: 2 additions & 2 deletions windows-agent/internal/distros/distro/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package distro
import (
"context"

"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialTasks"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialtasks"
)

func WithTaskProcessingContext(ctx context.Context) Option {
Expand All @@ -16,7 +16,7 @@ func WithTaskProcessingContext(ctx context.Context) Option {

// WithNewWorker is an optional parameter for distro.New that allows for overriding
// the worker.New constructor. It is meant for dependency injection.
func WithNewWorker(newWorkerFunc func(context.Context, *Distro, string, *initialTasks.InitialTasks) (workerInterface, error)) Option {
func WithNewWorker(newWorkerFunc func(context.Context, *Distro, string, *initialtasks.InitialTasks) (workerInterface, error)) Option {
return func(o *options) {
o.newWorkerFunc = newWorkerFunc
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package initialTasks
package initialtasks

import (
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/task"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package initialTasks keeps track of tasks that must be performed on all
// Package initialtasks keeps track of tasks that must be performed on all
// new distros.
package initialTasks
package initialtasks

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package initialTasks_test
package initialtasks_test

import (
"bytes"
Expand All @@ -10,7 +10,7 @@ import (
"reflect"
"testing"

"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialTasks"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialtasks"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/task"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/testutils"
"github.com/canonical/ubuntu-pro-for-windows/wslserviceapi"
Expand Down Expand Up @@ -61,12 +61,12 @@ func TestNew(t *testing.T) {
dir := t.TempDir()
setUpSaveFile(t, tc.fileState, dir)

it, err := initialTasks.New(dir)
it, err := initialtasks.New(dir)
if tc.wantErr {
require.Error(t, err, "initialTasks.New should have returned an error")
require.Error(t, err, "initialtasks.New should have returned an error")
return
}
require.NoError(t, err, "initialTasks.New should have returned no error")
require.NoError(t, err, "initialtasks.New should have returned no error")

got := it.Tasks()
require.ElementsMatch(t, tc.want, got, "Mismatch between expected and obtained tasks after construction")
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestAdd(t *testing.T) {
dir := t.TempDir()
setUpSaveFile(t, tc.fileStateBeforeNew, dir)

it, err := initialTasks.New(dir)
it, err := initialtasks.New(dir)
require.NoError(t, err, "Setup: could not create initial tasks")

setUpSaveFile(t, tc.fileStateBeforeAdd, dir)
Expand Down Expand Up @@ -160,7 +160,7 @@ func TestRemove(t *testing.T) {
dir := t.TempDir()
setUpSaveFile(t, fileHasValidTask, dir)

it, err := initialTasks.New(dir)
it, err := initialtasks.New(dir)
require.NoError(t, err, "Setup: could not create initial tasks")

setUpSaveFile(t, tc.fileStateBeforeRemove, dir)
Expand Down Expand Up @@ -207,9 +207,9 @@ func TestAll(t *testing.T) {
dir := t.TempDir()
setUpSaveFile(t, tc.fileState, dir)

var it *initialTasks.InitialTasks
var it *initialtasks.InitialTasks
if !tc.nilTaskList {
i, err := initialTasks.New(dir)
i, err := initialtasks.New(dir)
require.NoError(t, err, "Setup: could not create initial tasks")
it = i
}
Expand All @@ -223,7 +223,7 @@ func TestAll(t *testing.T) {
func setUpSaveFile(t *testing.T, fileState saveFileState, dir string) {
t.Helper()

file := filepath.Join(dir, initialTasks.InitialTasksFileName)
file := filepath.Join(dir, initialtasks.InitialTasksFileName)

removeFile := func() {
t.Helper()
Expand Down
6 changes: 3 additions & 3 deletions windows-agent/internal/distros/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"sync"
"time"

"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialTasks"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialtasks"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/task"
log "github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/grpc/logstreamer"
"github.com/canonical/ubuntu-pro-for-windows/wslserviceapi"
Expand Down Expand Up @@ -37,15 +37,15 @@ type Worker struct {
}

type options struct {
initialTasks *initialTasks.InitialTasks
initialTasks *initialtasks.InitialTasks
}

// Option is an optional argument for worker.New.
type Option func(*options)

// WithInitialTasks is an optional parameter for worker.New that allows for
// conditionally importing initial tasks.
func WithInitialTasks(init *initialTasks.InitialTasks) Option {
func WithInitialTasks(init *initialtasks.InitialTasks) Option {
return func(o *options) {
o.initialTasks = init
}
Expand Down
4 changes: 2 additions & 2 deletions windows-agent/internal/proservices/proservices.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
agent_api "github.com/canonical/ubuntu-pro-for-windows/agentapi/go"
"github.com/canonical/ubuntu-pro-for-windows/common"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/database"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialTasks"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialtasks"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/grpc/interceptorschain"
log "github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/grpc/logstreamer"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/proservices/ui"
Expand Down Expand Up @@ -71,7 +71,7 @@ func New(ctx context.Context, args ...Option) (s Manager, err error) {
return s, err
}

initTasks, err := initialTasks.New(opts.cacheDir)
initTasks, err := initialtasks.New(opts.cacheDir)
if err != nil {
return s, err
}
Expand Down
6 changes: 3 additions & 3 deletions windows-agent/internal/proservices/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import (

agentapi "github.com/canonical/ubuntu-pro-for-windows/agentapi/go"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/database"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialTasks"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialtasks"
log "github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/grpc/logstreamer"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/tasks"
)

// Service it the UI GRPC service implementation.
type Service struct {
db *database.DistroDB
initialTasks *initialTasks.InitialTasks
initialTasks *initialtasks.InitialTasks

agentapi.UnimplementedUIServer
}

// New returns a new service handling the UI API.
func New(ctx context.Context, db *database.DistroDB, initialTasks *initialTasks.InitialTasks) (s Service) {
func New(ctx context.Context, db *database.DistroDB, initialTasks *initialtasks.InitialTasks) (s Service) {
log.Debug(ctx, "Building new GRPC UI service")

return Service{
Expand Down
6 changes: 3 additions & 3 deletions windows-agent/internal/proservices/ui/ui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

agentapi "github.com/canonical/ubuntu-pro-for-windows/agentapi/go"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/database"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialTasks"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/initialtasks"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/proservices/ui"
"github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/tasks"
"github.com/stretchr/testify/require"
Expand All @@ -18,7 +18,7 @@ func TestNew(t *testing.T) {
dir := t.TempDir()
db, err := database.New(dir, nil)
require.NoError(t, err, "Setup: empty database New() should return no error")
initTasks, err := initialTasks.New(dir)
initTasks, err := initialtasks.New(dir)
require.NoError(t, err, "Setup: initial tasks New() should return no error")

_ = ui.New(context.Background(), db, initTasks)
Expand All @@ -45,7 +45,7 @@ func TestAttachProInitial(t *testing.T) {
dir := t.TempDir()
db, err := database.New(dir, nil)
require.NoError(t, err, "Setup: empty database New() should return no error")
initTasks, err := initialTasks.New(dir)
initTasks, err := initialtasks.New(dir)
require.NoError(t, err, "Setup: initial tasks New() should return no error")
serv := ui.New(context.Background(), db, initTasks)

Expand Down

0 comments on commit 7c8594f

Please sign in to comment.