Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests/topology tests #61

Merged
merged 8 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ issues:
- funlen
- gochecknoglobals

- path: logging/fake.go
linters:
- revive

# ignore globals for standard k8s things
- linters:
- gochecknoglobals
Expand Down
4 changes: 3 additions & 1 deletion clabverter/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"strings"
"text/template"

clabernetesutilkubernetes "github.com/srl-labs/clabernetes/util/kubernetes"

clabernetesutil "github.com/srl-labs/clabernetes/util"
clabernetesutilcontainerlab "github.com/srl-labs/clabernetes/util/containerlab"
)
Expand Down Expand Up @@ -262,7 +264,7 @@ func (c *Clabverter) handleExtraFiles() error {
c.extraFilesConfigMaps[nodeName] = make([]topologyConfigMapTemplateVars, 0)

for extraFilePath, extraFileContent := range nodeExtraFiles {
safeFileName := clabernetesutil.SafeConcatNameKubernetes(
safeFileName := clabernetesutilkubernetes.SafeConcatNameKubernetes(
strings.Split(extraFilePath, "/")...)

safeFileName = strings.TrimPrefix(safeFileName, "-")
Expand Down
6 changes: 4 additions & 2 deletions clicker/clabernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"sync"
"time"

clabernetesutilkubernetes "github.com/srl-labs/clabernetes/util/kubernetes"

"gopkg.in/yaml.v3"

claberneteserrors "github.com/srl-labs/clabernetes/errors"
Expand Down Expand Up @@ -203,7 +205,7 @@ func (c *clabernetes) run() error {
func (c *clabernetes) setup() error {
var err error

c.namespace, err = clabernetesutil.CurrentNamespace()
c.namespace, err = clabernetesutilkubernetes.CurrentNamespace()
if err != nil {
c.logger.Criticalf("failed getting current namespace, err: %s", err)

Expand Down Expand Up @@ -318,7 +320,7 @@ func envToResources() (k8scorev1.ResourceRequirements, error) {
return out, nil
}

parsedOut, err := clabernetesutil.YAMLToK8sResourceRequirements(asStr)
parsedOut, err := clabernetesutilkubernetes.YAMLToK8sResourceRequirements(asStr)
if err != nil {
return out, err
}
Expand Down
3 changes: 3 additions & 0 deletions config/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ var (
managerInstanceOnce sync.Once //nolint:gochecknoglobals
)

// ManagerGetterFunc returns an instance of the config manager.
type ManagerGetterFunc func() Manager

// InitManager initializes the config manager -- it does this once only, its a no-op if the manager
// is already initialized.
func InitManager(ctx context.Context, appName, namespace string, client *kubernetes.Clientset) {
Expand Down
18 changes: 18 additions & 0 deletions constants/kubernetes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package constants

const (
// KubernetesConfigMap is a const to use for "configmap".
KubernetesConfigMap = "configmap"

// KubernetesService is a const to use for "service".
KubernetesService = "service"

// KubernetesDeployment is a const to use for "deployment".
KubernetesDeployment = "deployment"

// KubernetesServiceClusterIPType is a const to use for "ClusterIP".
KubernetesServiceClusterIPType = "ClusterIP"

// KubernetesServiceLoadBalancerType is a const to use for "LoadBalancer".
KubernetesServiceLoadBalancerType = "LoadBalancer"
)
13 changes: 12 additions & 1 deletion controllers/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"fmt"

clabernetesutilkubernetes "github.com/srl-labs/clabernetes/util/kubernetes"

ctrlruntimeevent "sigs.k8s.io/controller-runtime/pkg/event"
ctrlruntimepredicate "sigs.k8s.io/controller-runtime/pkg/predicate"

Expand Down Expand Up @@ -58,7 +60,7 @@ func NewBaseController(
return &BaseController{
Ctx: ctx,
AppName: appName,
ControllerNamespace: clabernetesutil.MustCurrentNamespace(),
ControllerNamespace: clabernetesutilkubernetes.MustCurrentNamespace(),
Log: logger,
Config: config,
Client: client,
Expand Down Expand Up @@ -127,3 +129,12 @@ func (c *BaseController) LogReconcileCompleteObjectNotExist(_ ctrlruntime.Reques
func (c *BaseController) LogReconcileFailedGettingObject(req ctrlruntime.Request, err error) {
c.Log.Criticalf("failed fetching '%s/%s', error: %s", req.Namespace, req.Name, err)
}

// GetServiceDNSSuffix returns the default "svc.cluster.local" dns suffix, or the user's provided
// override value.
func (c *BaseController) GetServiceDNSSuffix() string {
return clabernetesutil.GetEnvStrOrDefault(
clabernetesconstants.InClusterDNSSuffixEnv,
clabernetesconstants.DefaultInClusterDNSSuffix,
)
}
56 changes: 0 additions & 56 deletions controllers/deployments.go

This file was deleted.

31 changes: 0 additions & 31 deletions controllers/services.go

This file was deleted.

159 changes: 0 additions & 159 deletions controllers/topology/configmap.go

This file was deleted.

Loading