Skip to content

Commit

Permalink
Fix typos (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 authored Apr 3, 2024
1 parent 341b026 commit 98eb923
Show file tree
Hide file tree
Showing 26 changed files with 57 additions and 57 deletions.
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/datastore/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ func checkSizeReservations(available metal.Machines, projectid, partitionid stri
return true
}

// substract already used up reservations of the project
// subtract already used up reservations of the project
reservations = max(reservations-alreadyAllocated, 0)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/datastore/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (rs *RethinkStore) CreatePartition(p *metal.Partition) error {
return rs.createEntity(rs.partitionTable(), p)
}

// DeletePartition delets a partition.
// DeletePartition deletes a partition.
func (rs *RethinkStore) DeletePartition(p *metal.Partition) error {
return rs.deleteEntity(rs.partitionTable(), p)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/fsm/fsm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func TestHandleProvisioningEvent(t *testing.T) {
},
},
{
name: "valid transition from crashing to pxe booting, maintaing crash loop",
name: "valid transition from crashing to pxe booting, maintaining crash loop",
container: &metal.ProvisioningEventContainer{
Events: metal.ProvisioningEvents{
{
Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/metal/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func (c *FilesystemLayoutConstraints) validate() error {
var validOPS = map[string]bool{"=": true, "!=": true, ">": true, "<": true, ">=": true, "=>": true, "<=": true, "=<": true, "~": true, "~>": true, "^": true}

func convertToOpAndVersion(versionconstraint string) (string, *semver.Version, error) {
// a version constrain op is given it must be seperated by a whitespace
// a version constrain op is given it must be separated by a whitespace
parts := strings.SplitN(versionconstraint, " ", 2)
// might be a single specific version, then it must parse into a semver
if len(parts) == 1 {
Expand Down
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/metal/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ type IPType string
type IPScope string

const (
// TagIPSeperator is the seperator character for key and values in IP-Tags
TagIPSeperator = "="
// TagIPSeparator is the separator character for key and values in IP-Tags
TagIPSeparator = "="

// Ephemeral IPs will be cleaned up automatically on machine, network, project deletion
Ephemeral IPType = "ephemeral"
Expand Down Expand Up @@ -102,7 +102,7 @@ func (ip *IP) HasMachineId(id string) bool {

func (ip *IP) GetMachineIds() []string {
ts := tags.New(ip.Tags)
return ts.Values(tag.MachineID + TagIPSeperator)
return ts.Values(tag.MachineID + TagIPSeparator)
}

func (ip *IP) AddMachineId(id string) {
Expand All @@ -121,7 +121,7 @@ func (ip *IP) RemoveMachineId(id string) {
}

func IpTag(key, value string) string {
return fmt.Sprintf("%s%s%s", key, TagIPSeperator, value)
return fmt.Sprintf("%s%s%s", key, TagIPSeparator, value)
}

type IPs []IP
Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/metal/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (r EgressRule) Validate() error {
case ProtocolTCP, ProtocolUDP:
// ok
default:
return fmt.Errorf("invalid procotol: %s", r.Protocol)
return fmt.Errorf("invalid protocol: %s", r.Protocol)
}

if err := validateComment(r.Comment); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/metal/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func TestEgressRule_Validate(t *testing.T) {
To: []string{"1.2.3.0/24", "2.3.4.5/32"},
Comment: "allow apt update",
wantErr: true,
wantErrmsg: "invalid procotol: sctp",
wantErrmsg: "invalid protocol: sctp",
},
{
name: "wrong port",
Expand Down
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/metal/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
)

// A MacAddress is the type for mac adresses. When using a
// A MacAddress is the type for mac addresses. When using a
// custom type, we cannot use strings directly.
type MacAddress string

Expand Down Expand Up @@ -105,7 +105,7 @@ type NetworkUsage struct {
UsedPrefixes uint64 `json:"used_prefixes" description:"the total used Prefixes" readonly:"true"`
}

// ByID creates an indexed map of partitions whre the id is the index.
// ByID creates an indexed map of partitions where the id is the index.
func (nws Networks) ByID() NetworkMap {
res := make(NetworkMap)
for i, nw := range nws {
Expand Down Expand Up @@ -140,8 +140,8 @@ func (n *MachineNetwork) ContainsIP(ip string) bool {
return false
}

// SubstractPrefixes returns the prefixes of the network minus the prefixes passed in the arguments
func (n *Network) SubstractPrefixes(prefixes ...Prefix) []Prefix {
// SubtractPrefixes returns the prefixes of the network minus the prefixes passed in the arguments
func (n *Network) SubtractPrefixes(prefixes ...Prefix) []Prefix {
var result []Prefix
for _, p := range n.Prefixes {
contains := false
Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/metal/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Partitions []Partition
// PartitionMap is an indexed map of partitions
type PartitionMap map[string]Partition

// ByID creates an indexed map of partitions whre the id is the index.
// ByID creates an indexed map of partitions where the id is the index.
func (sz Partitions) ByID() PartitionMap {
res := make(PartitionMap)
for i, s := range sz {
Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/metal/size.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (rs *Reservations) Validate(partitions PartitionMap, projects map[string]*m
}

// A ConstraintMatchingLog is used do return a log message to the caller
// beside the contraint itself.
// beside the constraint itself.
type ConstraintMatchingLog struct {
Constraint Constraint
Match bool
Expand Down
4 changes: 2 additions & 2 deletions cmd/metal-api/internal/metal/sizeimageconstraint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestSizeImageConstraint_matches(t *testing.T) {
wantErr: errors.New("given size:n1-medium-x86 with image:firewall-2.0.20201101 does violate image constraint:firewall >=2.0.20211001"),
},
{
name: "c1 has no restrictins",
name: "c1 has no restrictions",
fields: fields{
Base: Base{ID: n1Medium.ID},
Images: map[string]string{
Expand Down Expand Up @@ -254,7 +254,7 @@ func TestSizeImageConstraints_Validate(t *testing.T) {
wantErr: true,
},
{
name: "invalid op and not seperated by space",
name: "invalid op and not separated by space",
scs: &SizeImageConstraints{
{
Base: Base{ID: n1Medium.ID},
Expand Down
6 changes: 3 additions & 3 deletions cmd/metal-api/internal/service/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,10 @@ func createTestEnvironment(t *testing.T) testEnv {
},
}

var createdSizeImageContraint v1.SizeImageConstraintResponse
te.sizeImageConstraintCreate(t, sic, &createdSizeImageContraint)
var createdSizeImageConstraint v1.SizeImageConstraintResponse
te.sizeImageConstraintCreate(t, sic, &createdSizeImageConstraint)
require.Equal(t, http.StatusCreated, status)
require.NotNil(t, createdSizeImageContraint)
require.NotNil(t, createdSizeImageConstraint)
require.Equal(t, "n1-medium", sic.ID)
require.Len(t, sic.Images, 1)

Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/service/machine-service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestMachineIPMIReport(t *testing.T) {
wantStatusCode: http.StatusOK,
},
{
name: "don't update machine with unkown mac",
name: "don't update machine with unknown mac",
input: v1.MachineIpmiReports{
PartitionID: testdata.M1.PartitionID,
Reports: map[string]v1.MachineIpmiReport{"xyz": {BMCIp: "192.167.0.1"}},
Expand Down
4 changes: 2 additions & 2 deletions cmd/metal-api/internal/service/network-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ func (r *networkResource) updateNetwork(request *restful.Request, response *rest
return
}

prefixesToBeRemoved = oldNetwork.SubstractPrefixes(newNetwork.Prefixes...)
prefixesToBeRemoved = oldNetwork.SubtractPrefixes(newNetwork.Prefixes...)

// now validate if there are ips which have a prefix to be removed as a parent
allIPs, err := r.ds.ListIPs()
Expand All @@ -632,7 +632,7 @@ func (r *networkResource) updateNetwork(request *restful.Request, response *rest
return
}

prefixesToBeAdded = newNetwork.SubstractPrefixes(oldNetwork.Prefixes...)
prefixesToBeAdded = newNetwork.SubtractPrefixes(oldNetwork.Prefixes...)
}

for _, p := range prefixesToBeRemoved {
Expand Down
24 changes: 12 additions & 12 deletions cmd/metal-api/internal/service/partition-service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ import (
"github.com/stretchr/testify/require"
)

type nopTopicCreater struct {
type nopTopicCreator struct {
}

func (n nopTopicCreater) CreateTopic(topicFQN string) error {
func (n nopTopicCreator) CreateTopic(topicFQN string) error {
return nil
}

type expectingTopicCreater struct {
type expectingTopicCreator struct {
t *testing.T
expectedTopics []string
}

func (n expectingTopicCreater) CreateTopic(topicFQN string) error {
func (n expectingTopicCreator) CreateTopic(topicFQN string) error {
ass := assert.New(n.t)
ass.NotEmpty(topicFQN)
ass.Contains(n.expectedTopics, topicFQN, "Expectation %v contains %s failed.", n.expectedTopics, topicFQN)
Expand All @@ -44,7 +44,7 @@ func TestGetPartitions(t *testing.T) {
ds, mock := datastore.InitMockDB(t)
testdata.InitMockDBData(mock)

service := NewPartition(slog.Default(), ds, &nopTopicCreater{})
service := NewPartition(slog.Default(), ds, &nopTopicCreator{})
container := restful.NewContainer().Add(service)
req := httptest.NewRequest("GET", "/v1/partition", nil)
w := httptest.NewRecorder()
Expand Down Expand Up @@ -73,7 +73,7 @@ func TestGetPartition(t *testing.T) {
ds, mock := datastore.InitMockDB(t)
testdata.InitMockDBData(mock)

service := NewPartition(slog.Default(), ds, &nopTopicCreater{})
service := NewPartition(slog.Default(), ds, &nopTopicCreator{})
container := restful.NewContainer().Add(service)
req := httptest.NewRequest("GET", "/v1/partition/1", nil)
w := httptest.NewRecorder()
Expand All @@ -96,7 +96,7 @@ func TestGetPartitionNotFound(t *testing.T) {
testdata.InitMockDBData(mock)
log := slog.Default()

service := NewPartition(log, ds, &nopTopicCreater{})
service := NewPartition(log, ds, &nopTopicCreator{})
container := restful.NewContainer().Add(service)
req := httptest.NewRequest("GET", "/v1/partition/999", nil)
w := httptest.NewRecorder()
Expand All @@ -118,7 +118,7 @@ func TestDeletePartition(t *testing.T) {
testdata.InitMockDBData(mock)
log := slog.Default()

service := NewPartition(log, ds, &nopTopicCreater{})
service := NewPartition(log, ds, &nopTopicCreator{})
container := restful.NewContainer().Add(service)
req := httptest.NewRequest("DELETE", "/v1/partition/1", nil)
container = injectAdmin(log, container, req)
Expand All @@ -142,11 +142,11 @@ func TestCreatePartition(t *testing.T) {
testdata.InitMockDBData(mock)
log := slog.Default()

topicCreater := expectingTopicCreater{
topicCreator := expectingTopicCreator{
t: t,
expectedTopics: []string{"1-switch", "1-machine"},
}
service := NewPartition(log, ds, topicCreater)
service := NewPartition(log, ds, topicCreator)
container := restful.NewContainer().Add(service)

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -197,7 +197,7 @@ func TestUpdatePartition(t *testing.T) {
testdata.InitMockDBData(mock)
log := slog.Default()

service := NewPartition(log, ds, &nopTopicCreater{})
service := NewPartition(log, ds, &nopTopicCreator{})
container := restful.NewContainer().Add(service)
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "I am a downloadable content")
Expand Down Expand Up @@ -259,7 +259,7 @@ func TestPartitionCapacity(t *testing.T) {
testdata.InitMockDBData(mock)
log := slog.Default()

service := NewPartition(log, ds, &nopTopicCreater{})
service := NewPartition(log, ds, &nopTopicCreator{})
container := restful.NewContainer().Add(service)

pcRequest := &v1.PartitionCapacityRequest{}
Expand Down
6 changes: 3 additions & 3 deletions cmd/metal-api/internal/service/switch-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (r *switchResource) deleteSwitch(request *restful.Request, response *restfu
r.send(request, response, http.StatusOK, resp)
}

// notifySwitch is called periodically from every switch to report last duration and error if ocurred
// notifySwitch is called periodically from every switch to report last duration and error if occurred
func (r *switchResource) notifySwitch(request *restful.Request, response *restful.Response) {
var requestPayload v1.SwitchNotifyRequest
err := request.ReadEntity(&requestPayload)
Expand Down Expand Up @@ -623,7 +623,7 @@ func updateSwitchNics(oldNics, newNics map[string]*metal.Nic, currentConnections
}

func makeSwitchResponse(s *metal.Switch, ds *datastore.RethinkStore) (*v1.SwitchResponse, error) {
p, ips, machines, ss, err := findSwitchReferencedEntites(s, ds)
p, ips, machines, ss, err := findSwitchReferencedEntities(s, ds)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -769,7 +769,7 @@ func makeSwitchCons(s *metal.Switch) []v1.SwitchConnection {
return cons
}

func findSwitchReferencedEntites(s *metal.Switch, ds *datastore.RethinkStore) (*metal.Partition, metal.IPsMap, metal.Machines, *metal.SwitchStatus, error) {
func findSwitchReferencedEntities(s *metal.Switch, ds *datastore.RethinkStore) (*metal.Partition, metal.IPsMap, metal.Machines, *metal.SwitchStatus, error) {
var err error
var p *metal.Partition
var m metal.Machines
Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/service/v1/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type (
}
Filesystem struct {
Path *string `json:"path" description:"the mountpoint where this filesystem should be mounted on" optional:"true"`
Device string `json:"device" description:"the underlaying device where this filesystem should be created"`
Device string `json:"device" description:"the underlying device where this filesystem should be created"`
Format string `json:"format" description:"the filesystem format"`
Label *string `json:"label" description:"optional label for this this filesystem" optional:"true"`
MountOptions []string `json:"mountoptions" description:"the options to use to mount this filesystem" optional:"true"`
Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/service/v1/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ type MachineAllocateRequest struct {
PartitionID string `json:"partitionid" description:"the partition id to assign this machine to"`
SizeID string `json:"sizeid" description:"the size id to assign this machine to"`
ImageID string `json:"imageid" description:"the image id to assign this machine to"`
FilesystemLayoutID *string `json:"filesystemlayoutid" description:"the filesystemlayout id to assing to this machine" optional:"true"`
FilesystemLayoutID *string `json:"filesystemlayoutid" description:"the filesystemlayout id to assign to this machine" optional:"true"`
SSHPubKeys []string `json:"ssh_pub_keys" description:"the public ssh keys to access the machine with"`
UserData *string `json:"user_data" description:"cloud-init.io compatible userdata must be base64 encoded" optional:"true"`
Tags []string `json:"tags" description:"tags for this machine" optional:"true"`
Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/service/v1/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type NetworkImmutable struct {
PrivateSuper bool `json:"privatesuper" description:"if set to true, this network will serve as a partition's super network for the internal machine networks,there can only be one privatesuper network per partition"`
Underlay bool `json:"underlay" description:"if set to true, this network can be used for underlay communication"`
Vrf *uint `json:"vrf" description:"the vrf this network is associated with" optional:"true"`
VrfShared *bool `json:"vrfshared" description:"if set to true, given vrf can be used by multiple networks, which is sometimes useful for network partioning (default: false)" optional:"true"`
VrfShared *bool `json:"vrfshared" description:"if set to true, given vrf can be used by multiple networks, which is sometimes useful for network partitioning (default: false)" optional:"true"`
ParentNetworkID *string `json:"parentnetworkid" description:"the id of the parent network" optional:"true"`
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/service/v1/size.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type SizeSuggestRequest struct {
type SizeConstraintMatchingLog struct {
Constraint SizeConstraint `json:"constraint" description:"the size constraint to which this log relates to"`
Match bool `json:"match" description:"indicates whether the constraint matched or not"`
Log string `json:"log" description:"a string represention of the matching condition"`
Log string `json:"log" description:"a string representation of the matching condition"`
}

type SizeMatchingLog struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/service/v1/sizeimageconstraint.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package v1
import "github.com/metal-stack/metal-api/cmd/metal-api/internal/metal"

type SizeImageConstraintBase struct {
Images map[string]string `json:"images" description:"a list of images for this contraints apply"`
Images map[string]string `json:"images" description:"a list of images for this constraints apply"`
}

type SizeImageConstraintResponse struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/v1/boot_grpc.pb.go

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

2 changes: 1 addition & 1 deletion pkg/api/v1/event.pb.go

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

2 changes: 1 addition & 1 deletion proto/api/v1/boot.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ service BootService {
rpc Register(BootServiceRegisterRequest) returns (BootServiceRegisterResponse) {}
// Wait is a hanging call that waits until the machine gets allocated by a user
rpc Wait(BootServiceWaitRequest) returns (stream BootServiceWaitResponse);
// Report tells metal-api installation was either sucessful or failed
// Report tells metal-api installation was either successful or failed
rpc Report(BootServiceReportRequest) returns (BootServiceReportResponse) {}
// If reinstall failed and tell metal-api to restore to previous state
rpc AbortReinstall(BootServiceAbortReinstallRequest) returns (BootServiceAbortReinstallResponse) {}
Expand Down
2 changes: 1 addition & 1 deletion proto/api/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ message EventServiceSendResponse {
}

message MachineProvisioningEvent {
// timestamp when the event occured
// timestamp when the event occurred
google.protobuf.Timestamp time = 1;
// the event type
// must be one of metal.ProvisioningEventType, otherwise event will be skipped
Expand Down
Loading

0 comments on commit 98eb923

Please sign in to comment.