Skip to content

Commit

Permalink
package utils => names
Browse files Browse the repository at this point in the history
  • Loading branch information
jichenjc committed May 25, 2021
1 parent 76b25dd commit f3088d8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions pkg/cloud/services/compute/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ import (

infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha4"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/record"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils"
capoerrors "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/names"
)

const (
Expand Down Expand Up @@ -162,7 +162,7 @@ func (s *Service) createInstance(eventObject runtime.Object, clusterName string,
}

if i.Trunk {
trunk, err := getOrCreateTrunk(eventObject, clusterName, i.Name, port.ID)
trunk, err := s.getOrCreateTrunk(eventObject, clusterName, i.Name, port.ID)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -396,7 +396,7 @@ func (s *Service) getOrCreatePort(eventObject runtime.Object, clusterName string
Name: portName,
NetworkID: net.ID,
SecurityGroups: securityGroups,
Description: utils.GetDescription(clusterName),
Description: names.GetDescription(clusterName),
}
if net.Subnet.ID != "" {
portCreateOpts.FixedIPs = []ports.IP{{SubnetID: net.Subnet.ID}}
Expand All @@ -411,7 +411,7 @@ func (s *Service) getOrCreatePort(eventObject runtime.Object, clusterName string
return port, nil
}

func getOrCreateTrunk(eventObject runtime.Object, clusterName, trunkName, portID string) (*trunks.Trunk, error) {
func (s *Service) getOrCreateTrunk(eventObject runtime.Object, clusterName, trunkName, portID string) (*trunks.Trunk, error) {
allPages, err := trunks.List(s.networkClient, trunks.ListOpts{
Name: trunkName,
PortID: portID,
Expand All @@ -431,7 +431,7 @@ func getOrCreateTrunk(eventObject runtime.Object, clusterName, trunkName, portID
trunkCreateOpts := trunks.CreateOpts{
Name: trunkName,
PortID: portID,
Description: utils.GetDescription(clusterName),
Description: names.GetDescription(clusterName),
}
trunk, err := trunks.Create(s.networkClient, trunkCreateOpts).Extract()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloud/services/loadbalancer/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha4"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/record"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/names"
)

const (
Expand All @@ -53,7 +53,7 @@ func (s *Service) ReconcileLoadBalancer(openStackCluster *infrav1.OpenStackClust
lbCreateOpts := loadbalancers.CreateOpts{
Name: loadBalancerName,
VipSubnetID: openStackCluster.Status.Network.Subnet.ID,
Description: utils.GetDescription(clusterName),
Description: names.GetDescription(clusterName),
}

lb, err = loadbalancers.Create(s.loadbalancerClient, lbCreateOpts).Extract()
Expand Down
8 changes: 4 additions & 4 deletions pkg/cloud/services/networking/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha4"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/record"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/names"
)

type createOpts struct {
Expand Down Expand Up @@ -195,7 +195,7 @@ func (s *Service) ReconcileSubnet(openStackCluster *infrav1.OpenStackCluster, cl
var subnet *subnets.Subnet
if len(subnetList) == 0 {
var err error
subnet, err = createSubnet(openStackCluster, clusterName, subnetName)
subnet, err = s.createSubnet(openStackCluster, clusterName, subnetName)
if err != nil {
return err
}
Expand All @@ -213,14 +213,14 @@ func (s *Service) ReconcileSubnet(openStackCluster *infrav1.OpenStackCluster, cl
return nil
}

func createSubnet(openStackCluster *infrav1.OpenStackCluster, clusterName string, name string) (*subnets.Subnet, error) {
func (s *Service) createSubnet(openStackCluster *infrav1.OpenStackCluster, clusterName string, name string) (*subnets.Subnet, error) {
opts := subnets.CreateOpts{
NetworkID: openStackCluster.Status.Network.ID,
Name: name,
IPVersion: 4,
CIDR: openStackCluster.Spec.NodeCIDR,
DNSNameservers: openStackCluster.Spec.DNSNameservers,
Description: utils.GetDescription(clusterName),
Description: names.GetDescription(clusterName),
}
subnet, err := subnets.Create(s.client, opts).Extract()
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/cloud/services/networking/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (

infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha4"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/record"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils"
capoerrors "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
"sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/names"
)

func (s *Service) ReconcileRouter(openStackCluster *infrav1.OpenStackCluster, clusterName string) error {
Expand Down Expand Up @@ -66,7 +66,7 @@ func (s *Service) ReconcileRouter(openStackCluster *infrav1.OpenStackCluster, cl
var router *routers.Router
if len(routerList) == 0 {
var err error
router, err = createRouter(openStackCluster, clusterName, routerName)
router, err = s.createRouter(openStackCluster, clusterName, routerName)
if err != nil {
return err
}
Expand Down Expand Up @@ -120,7 +120,7 @@ INTERFACE_LOOP:

func (s *Service) createRouter(openStackCluster *infrav1.OpenStackCluster, clusterName, name string) (*routers.Router, error) {
opts := routers.CreateOpts{
Description: utils.GetDescription(clusterName),
Description: names.GetDescription(clusterName),
Name: name,
}
// only set the GatewayInfo right now when no externalIPs
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/utils.go → pkg/utils/names/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package utils
package names

import (
"fmt"
Expand Down

0 comments on commit f3088d8

Please sign in to comment.