diff --git a/Dockerfile b/Dockerfile index ec6747e8c..aa0621e10 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,17 +13,9 @@ COPY go.sum go.sum COPY vendor/ vendor/ # Copy the go source -COPY main.go main.go +COPY cmd/ cmd/ COPY api/ api/ -COPY clusterversion/ clusterversion/ -COPY collector/ collector/ -COPY controllers/ controllers/ -COPY crhchttp/ crhchttp/ -COPY dirconfig/ dirconfig/ -COPY packaging/ packaging/ -COPY sources/ sources/ -COPY storage/ storage/ -COPY strset/ strset/ +COPY internal/ internal/ # Copy git to inject the commit during build COPY .git .git @@ -31,7 +23,7 @@ COPY .git .git RUN GIT_COMMIT=$(git rev-list -1 HEAD) && \ echo " injecting GIT COMMIT: $GIT_COMMIT" && \ CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} GOFLAGS=-mod=vendor \ -go build -ldflags "-w -s -X github.com/project-koku/koku-metrics-operator/controllers.GitCommit=$GIT_COMMIT" -a -o manager main.go +go build -ldflags "-w -s -X github.com/project-koku/koku-metrics-operator/controllers.GitCommit=$GIT_COMMIT" -a -o manager cmd/main.go # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/Makefile b/Makefile index 62dac07b9..b83e250ac 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ ARCH = $(shell go env GOARCH) # Set the Operator SDK version to use. By default, what is installed on the system is used. # This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit. -OPERATOR_SDK_VERSION ?= v1.32.0 +OPERATOR_SDK_VERSION ?= v1.33.0 # CONTAINER_TOOL defines the container tool to be used for building images. # Be aware that the target commands are only tested with Docker which is @@ -157,7 +157,7 @@ test: manifests generate fmt vet envtest ## Run tests. .PHONY: build build: manifests generate fmt vet vendor ## Build manager binary. - go build -o bin/manager main.go + go build -o bin/manager cmd/main.go SECRET_ABSPATH ?= ./testing WATCH_NAMESPACE ?= koku-metrics-operator @@ -165,7 +165,7 @@ WATCH_NAMESPACE ?= koku-metrics-operator .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. kubectl apply -f testing/sa.yaml - WATCH_NAMESPACE=$(WATCH_NAMESPACE) SECRET_ABSPATH=$(SECRET_ABSPATH) GIT_COMMIT=$(GIT_COMMIT) go run ./main.go + WATCH_NAMESPACE=$(WATCH_NAMESPACE) SECRET_ABSPATH=$(SECRET_ABSPATH) GIT_COMMIT=$(GIT_COMMIT) go run cmd/main.go # If you wish to build the manager image targeting other platforms you can use the --platform flag. # (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it. @@ -371,7 +371,7 @@ ifeq (,$(shell which opm 2>/dev/null)) set -e ;\ mkdir -p $(dir $(OPM)) ;\ OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \ - curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0/$${OS}-$${ARCH}-opm ;\ + curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.34.0/$${OS}-$${ARCH}-opm ;\ chmod +x $(OPM) ;\ } else diff --git a/PROJECT b/PROJECT index 951fd65ab..478fb1ae3 100644 --- a/PROJECT +++ b/PROJECT @@ -1,16 +1,19 @@ domain: openshift.io -layout: go.kubebuilder.io/v2 +layout: + - go.kubebuilder.io/v4 +plugins: + manifests.sdk.operatorframework.io/v2: {} + scorecard.sdk.operatorframework.io/v2: {} projectName: koku-metrics-operator repo: github.com/project-koku/koku-metrics-operator resources: -- - controller: true - domain: openshift.io - group: koku-metrics-cfg - kind: KokuMetricsConfig - path: github.com/project-koku/koku-metrics-operator/api/v1beta1 - version: v1beta1 + - api: + crdVersion: v1 + namespaced: true + controller: true + domain: openshift.io + group: koku-metrics-cfg + kind: KokuMetricsConfig + path: github.com/project-koku/koku-metrics-operator/api/v1beta1 + version: v1beta1 version: "3" -plugins: - manifests.sdk.operatorframework.io/v2: {} - scorecard.sdk.operatorframework.io/v2: {} diff --git a/main.go b/cmd/main.go similarity index 82% rename from main.go rename to cmd/main.go index 0d150ec7a..1f8a1cc04 100644 --- a/main.go +++ b/cmd/main.go @@ -19,11 +19,12 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/cache" + "sigs.k8s.io/controller-runtime/pkg/healthz" "sigs.k8s.io/controller-runtime/pkg/log/zap" metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" metricscfgv1beta1 "github.com/project-koku/koku-metrics-operator/api/v1beta1" - "github.com/project-koku/koku-metrics-operator/controllers" + "github.com/project-koku/koku-metrics-operator/internal/controller" // +kubebuilder:scaffold:imports ) @@ -48,11 +49,12 @@ func init() { func main() { var metricsAddr string var enableLeaderElection bool + var probeAddr string flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") + flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") flag.BoolVar(&enableLeaderElection, "leader-elect", false, "Enable leader election for controller manager. "+ "Enabling this will ensure there is only one active controller manager.") - flag.Parse() opts := zap.Options{ Development: true, @@ -75,8 +77,10 @@ func main() { } mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, - Metrics: metricsserver.Options{BindAddress: metricsAddr}, + Scheme: scheme, + Metrics: metricsserver.Options{BindAddress: metricsAddr}, + HealthProbeBindAddress: probeAddr, + LeaderElection: enableLeaderElection, LeaderElectionID: "91c624a5.openshift.io", Cache: cache.Options{DefaultNamespaces: map[string]cache.Config{watchNamespace: {}}}, @@ -86,13 +90,13 @@ func main() { os.Exit(1) } - clientset, err := controllers.GetClientset() + clientset, err := controller.GetClientset() if err != nil { setupLog.Error(err, "unable to get clientset") os.Exit(1) } - if err = (&controllers.MetricsConfigReconciler{ + if err = (&controller.MetricsConfigReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), Clientset: clientset, @@ -105,6 +109,15 @@ func main() { // +kubebuilder:scaffold:builder + if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { + setupLog.Error(err, "unable to set up health check") + os.Exit(1) + } + if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil { + setupLog.Error(err, "unable to set up ready check") + os.Exit(1) + } + setupLog.Info("starting manager") if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { setupLog.Error(err, "problem running manager") diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index bc80b887e..88fe62156 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -39,6 +39,18 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + livenessProbe: + httpGet: + path: /healthz + port: 8081 + initialDelaySeconds: 15 + periodSeconds: 20 + readinessProbe: + httpGet: + path: /readyz + port: 8081 + initialDelaySeconds: 5 + periodSeconds: 10 resources: limits: cpu: 500m @@ -46,10 +58,19 @@ spec: requests: cpu: 100m memory: 20Mi + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL terminationMessagePolicy: FallbackToLogsOnError volumeMounts: - mountPath: /tmp/koku-metrics-operator-reports name: koku-metrics-operator-reports + securityContext: + runAsNonRoot: true + seccompProfile: + type: RuntimeDefault serviceAccountName: controller-manager terminationGracePeriodSeconds: 10 volumes: diff --git a/config/manifests/bases/koku-metrics-operator.clusterserviceversion.yaml b/config/manifests/bases/koku-metrics-operator.clusterserviceversion.yaml index bfaf4c37f..fbec11e07 100644 --- a/config/manifests/bases/koku-metrics-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/koku-metrics-operator.clusterserviceversion.yaml @@ -16,14 +16,14 @@ metadata: operators.operatorframework.io/project_layout: go.kubebuilder.io/v2 repository: https://github.com/project-koku/koku-metrics-operator support: Cost Management - name: koku-metrics-operator.v0.0.0 - namespace: placeholder labels: operatorframework.io/arch.amd64: supported operatorframework.io/arch.arm64: supported operatorframework.io/arch.ppc64le: supported operatorframework.io/arch.s390x: supported operatorframework.io/os.linux: supported + name: koku-metrics-operator.v0.0.0 + namespace: placeholder spec: apiservicedefinitions: {} customresourcedefinitions: @@ -60,6 +60,7 @@ spec: - email: costmanagement@redhat.com name: costmanagement maturity: alpha + minKubeVersion: 1.24.0 provider: name: Red Hat version: 0.0.0 diff --git a/config/scorecard/kustomization.yaml b/config/scorecard/kustomization.yaml index 50cd2d084..61ceb4d78 100644 --- a/config/scorecard/kustomization.yaml +++ b/config/scorecard/kustomization.yaml @@ -1,16 +1,17 @@ resources: - bases/config.yaml -patchesJson6902: +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +patches: - path: patches/basic.config.yaml target: group: scorecard.operatorframework.io - version: v1alpha3 kind: Configuration name: config + version: v1alpha3 - path: patches/olm.config.yaml target: group: scorecard.operatorframework.io - version: v1alpha3 kind: Configuration name: config -#+kubebuilder:scaffold:patchesJson6902 + version: v1alpha3 diff --git a/clusterversion/cv.go b/internal/clusterversion/cv.go similarity index 100% rename from clusterversion/cv.go rename to internal/clusterversion/cv.go diff --git a/collector/collector.go b/internal/collector/collector.go similarity index 99% rename from collector/collector.go rename to internal/collector/collector.go index a041ab763..1c071706e 100644 --- a/collector/collector.go +++ b/internal/collector/collector.go @@ -21,7 +21,7 @@ import ( logr "sigs.k8s.io/controller-runtime/pkg/log" metricscfgv1beta1 "github.com/project-koku/koku-metrics-operator/api/v1beta1" - "github.com/project-koku/koku-metrics-operator/dirconfig" + "github.com/project-koku/koku-metrics-operator/internal/dirconfig" ) var ( diff --git a/collector/collector_test.go b/internal/collector/collector_test.go similarity index 99% rename from collector/collector_test.go rename to internal/collector/collector_test.go index 1f32265ee..21ed4f4c2 100644 --- a/collector/collector_test.go +++ b/internal/collector/collector_test.go @@ -18,9 +18,9 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" metricscfgv1beta1 "github.com/project-koku/koku-metrics-operator/api/v1beta1" - "github.com/project-koku/koku-metrics-operator/dirconfig" - "github.com/project-koku/koku-metrics-operator/strset" - "github.com/project-koku/koku-metrics-operator/testutils" + "github.com/project-koku/koku-metrics-operator/internal/dirconfig" + "github.com/project-koku/koku-metrics-operator/internal/strset" + "github.com/project-koku/koku-metrics-operator/internal/testutils" ) const epsilon = 0.00001 diff --git a/collector/prometheus.go b/internal/collector/prometheus.go similarity index 100% rename from collector/prometheus.go rename to internal/collector/prometheus.go diff --git a/collector/prometheus_test.go b/internal/collector/prometheus_test.go similarity index 99% rename from collector/prometheus_test.go rename to internal/collector/prometheus_test.go index eeeba47ef..dda618f1a 100644 --- a/collector/prometheus_test.go +++ b/internal/collector/prometheus_test.go @@ -19,7 +19,7 @@ import ( "github.com/prometheus/common/model" metricscfgv1beta1 "github.com/project-koku/koku-metrics-operator/api/v1beta1" - "github.com/project-koku/koku-metrics-operator/testutils" + "github.com/project-koku/koku-metrics-operator/internal/testutils" ) var trueDef = true @@ -79,7 +79,7 @@ type mockPrometheusConnectionPolling struct { func sleepContext(ctx context.Context, delay time.Duration) error { select { case <-ctx.Done(): - return ctxTimeout + return errCtxTimeout case <-time.After(delay): return nil } @@ -350,7 +350,7 @@ func TestTestPrometheusConnectionPolling(t *testing.T) { { name: "test query error", wait: 15 * time.Millisecond, - queryResult: &mockPromResult{err: ctxTimeout}, + queryResult: &mockPromResult{err: errCtxTimeout}, wantedError: errTest, }, } diff --git a/collector/queries.go b/internal/collector/queries.go similarity index 100% rename from collector/queries.go rename to internal/collector/queries.go diff --git a/collector/report.go b/internal/collector/report.go similarity index 97% rename from collector/report.go rename to internal/collector/report.go index 2567b6d6a..fc64b85db 100644 --- a/collector/report.go +++ b/internal/collector/report.go @@ -14,7 +14,7 @@ import ( "path/filepath" "strings" - "github.com/project-koku/koku-metrics-operator/strset" + "github.com/project-koku/koku-metrics-operator/internal/strset" ) type dataInterface interface { diff --git a/collector/report_test.go b/internal/collector/report_test.go similarity index 98% rename from collector/report_test.go rename to internal/collector/report_test.go index 6793cea1f..51b7fc3af 100644 --- a/collector/report_test.go +++ b/internal/collector/report_test.go @@ -8,12 +8,12 @@ import ( "strings" "testing" - "github.com/project-koku/koku-metrics-operator/strset" + "github.com/project-koku/koku-metrics-operator/internal/strset" ) var ( - ctxTimeout = errors.New("context timeout") - errTest = errors.New("test error") + errCtxTimeout = errors.New("context timeout") + errTest = errors.New("test error") ) type badReader struct{} diff --git a/collector/test_files/expected_reports/cm-openshift-namespace-usage-202011.csv b/internal/collector/test_files/expected_reports/cm-openshift-namespace-usage-202011.csv similarity index 100% rename from collector/test_files/expected_reports/cm-openshift-namespace-usage-202011.csv rename to internal/collector/test_files/expected_reports/cm-openshift-namespace-usage-202011.csv diff --git a/collector/test_files/expected_reports/cm-openshift-node-usage-202011.csv b/internal/collector/test_files/expected_reports/cm-openshift-node-usage-202011.csv similarity index 100% rename from collector/test_files/expected_reports/cm-openshift-node-usage-202011.csv rename to internal/collector/test_files/expected_reports/cm-openshift-node-usage-202011.csv diff --git a/collector/test_files/expected_reports/cm-openshift-pod-usage-202011.csv b/internal/collector/test_files/expected_reports/cm-openshift-pod-usage-202011.csv similarity index 100% rename from collector/test_files/expected_reports/cm-openshift-pod-usage-202011.csv rename to internal/collector/test_files/expected_reports/cm-openshift-pod-usage-202011.csv diff --git a/collector/test_files/expected_reports/cm-openshift-storage-usage-202011.csv b/internal/collector/test_files/expected_reports/cm-openshift-storage-usage-202011.csv similarity index 100% rename from collector/test_files/expected_reports/cm-openshift-storage-usage-202011.csv rename to internal/collector/test_files/expected_reports/cm-openshift-storage-usage-202011.csv diff --git a/collector/test_files/expected_reports/ros-openshift-202011.csv b/internal/collector/test_files/expected_reports/ros-openshift-202011.csv similarity index 100% rename from collector/test_files/expected_reports/ros-openshift-202011.csv rename to internal/collector/test_files/expected_reports/ros-openshift-202011.csv diff --git a/collector/test_files/single-line.csv b/internal/collector/test_files/single-line.csv similarity index 100% rename from collector/test_files/single-line.csv rename to internal/collector/test_files/single-line.csv diff --git a/collector/test_files/test_data/container-image-owner b/internal/collector/test_files/test_data/container-image-owner similarity index 100% rename from collector/test_files/test_data/container-image-owner rename to internal/collector/test_files/test_data/container-image-owner diff --git a/collector/test_files/test_data/container-image-workload b/internal/collector/test_files/test_data/container-image-workload similarity index 100% rename from collector/test_files/test_data/container-image-workload rename to internal/collector/test_files/test_data/container-image-workload diff --git a/collector/test_files/test_data/cpu-limit-container-avg b/internal/collector/test_files/test_data/cpu-limit-container-avg similarity index 100% rename from collector/test_files/test_data/cpu-limit-container-avg rename to internal/collector/test_files/test_data/cpu-limit-container-avg diff --git a/collector/test_files/test_data/cpu-limit-container-sum b/internal/collector/test_files/test_data/cpu-limit-container-sum similarity index 100% rename from collector/test_files/test_data/cpu-limit-container-sum rename to internal/collector/test_files/test_data/cpu-limit-container-sum diff --git a/collector/test_files/test_data/cpu-request-container-avg b/internal/collector/test_files/test_data/cpu-request-container-avg similarity index 100% rename from collector/test_files/test_data/cpu-request-container-avg rename to internal/collector/test_files/test_data/cpu-request-container-avg diff --git a/collector/test_files/test_data/cpu-request-container-sum b/internal/collector/test_files/test_data/cpu-request-container-sum similarity index 100% rename from collector/test_files/test_data/cpu-request-container-sum rename to internal/collector/test_files/test_data/cpu-request-container-sum diff --git a/collector/test_files/test_data/cpu-throttle-container-avg b/internal/collector/test_files/test_data/cpu-throttle-container-avg similarity index 100% rename from collector/test_files/test_data/cpu-throttle-container-avg rename to internal/collector/test_files/test_data/cpu-throttle-container-avg diff --git a/collector/test_files/test_data/cpu-throttle-container-max b/internal/collector/test_files/test_data/cpu-throttle-container-max similarity index 100% rename from collector/test_files/test_data/cpu-throttle-container-max rename to internal/collector/test_files/test_data/cpu-throttle-container-max diff --git a/collector/test_files/test_data/cpu-throttle-container-sum b/internal/collector/test_files/test_data/cpu-throttle-container-sum similarity index 100% rename from collector/test_files/test_data/cpu-throttle-container-sum rename to internal/collector/test_files/test_data/cpu-throttle-container-sum diff --git a/collector/test_files/test_data/cpu-usage-container-avg b/internal/collector/test_files/test_data/cpu-usage-container-avg similarity index 100% rename from collector/test_files/test_data/cpu-usage-container-avg rename to internal/collector/test_files/test_data/cpu-usage-container-avg diff --git a/collector/test_files/test_data/cpu-usage-container-max b/internal/collector/test_files/test_data/cpu-usage-container-max similarity index 100% rename from collector/test_files/test_data/cpu-usage-container-max rename to internal/collector/test_files/test_data/cpu-usage-container-max diff --git a/collector/test_files/test_data/cpu-usage-container-min b/internal/collector/test_files/test_data/cpu-usage-container-min similarity index 100% rename from collector/test_files/test_data/cpu-usage-container-min rename to internal/collector/test_files/test_data/cpu-usage-container-min diff --git a/collector/test_files/test_data/cpu-usage-container-sum b/internal/collector/test_files/test_data/cpu-usage-container-sum similarity index 100% rename from collector/test_files/test_data/cpu-usage-container-sum rename to internal/collector/test_files/test_data/cpu-usage-container-sum diff --git a/collector/test_files/test_data/memory-limit-container-avg b/internal/collector/test_files/test_data/memory-limit-container-avg similarity index 100% rename from collector/test_files/test_data/memory-limit-container-avg rename to internal/collector/test_files/test_data/memory-limit-container-avg diff --git a/collector/test_files/test_data/memory-limit-container-sum b/internal/collector/test_files/test_data/memory-limit-container-sum similarity index 100% rename from collector/test_files/test_data/memory-limit-container-sum rename to internal/collector/test_files/test_data/memory-limit-container-sum diff --git a/collector/test_files/test_data/memory-request-container-avg b/internal/collector/test_files/test_data/memory-request-container-avg similarity index 100% rename from collector/test_files/test_data/memory-request-container-avg rename to internal/collector/test_files/test_data/memory-request-container-avg diff --git a/collector/test_files/test_data/memory-request-container-sum b/internal/collector/test_files/test_data/memory-request-container-sum similarity index 100% rename from collector/test_files/test_data/memory-request-container-sum rename to internal/collector/test_files/test_data/memory-request-container-sum diff --git a/collector/test_files/test_data/memory-rss-usage-container-avg b/internal/collector/test_files/test_data/memory-rss-usage-container-avg similarity index 100% rename from collector/test_files/test_data/memory-rss-usage-container-avg rename to internal/collector/test_files/test_data/memory-rss-usage-container-avg diff --git a/collector/test_files/test_data/memory-rss-usage-container-max b/internal/collector/test_files/test_data/memory-rss-usage-container-max similarity index 100% rename from collector/test_files/test_data/memory-rss-usage-container-max rename to internal/collector/test_files/test_data/memory-rss-usage-container-max diff --git a/collector/test_files/test_data/memory-rss-usage-container-min b/internal/collector/test_files/test_data/memory-rss-usage-container-min similarity index 100% rename from collector/test_files/test_data/memory-rss-usage-container-min rename to internal/collector/test_files/test_data/memory-rss-usage-container-min diff --git a/collector/test_files/test_data/memory-rss-usage-container-sum b/internal/collector/test_files/test_data/memory-rss-usage-container-sum similarity index 100% rename from collector/test_files/test_data/memory-rss-usage-container-sum rename to internal/collector/test_files/test_data/memory-rss-usage-container-sum diff --git a/collector/test_files/test_data/memory-usage-container-avg b/internal/collector/test_files/test_data/memory-usage-container-avg similarity index 100% rename from collector/test_files/test_data/memory-usage-container-avg rename to internal/collector/test_files/test_data/memory-usage-container-avg diff --git a/collector/test_files/test_data/memory-usage-container-max b/internal/collector/test_files/test_data/memory-usage-container-max similarity index 100% rename from collector/test_files/test_data/memory-usage-container-max rename to internal/collector/test_files/test_data/memory-usage-container-max diff --git a/collector/test_files/test_data/memory-usage-container-min b/internal/collector/test_files/test_data/memory-usage-container-min similarity index 100% rename from collector/test_files/test_data/memory-usage-container-min rename to internal/collector/test_files/test_data/memory-usage-container-min diff --git a/collector/test_files/test_data/memory-usage-container-sum b/internal/collector/test_files/test_data/memory-usage-container-sum similarity index 100% rename from collector/test_files/test_data/memory-usage-container-sum rename to internal/collector/test_files/test_data/memory-usage-container-sum diff --git a/collector/test_files/test_data/namespace-labels b/internal/collector/test_files/test_data/namespace-labels similarity index 100% rename from collector/test_files/test_data/namespace-labels rename to internal/collector/test_files/test_data/namespace-labels diff --git a/collector/test_files/test_data/node-allocatable-cpu-cores b/internal/collector/test_files/test_data/node-allocatable-cpu-cores similarity index 100% rename from collector/test_files/test_data/node-allocatable-cpu-cores rename to internal/collector/test_files/test_data/node-allocatable-cpu-cores diff --git a/collector/test_files/test_data/node-allocatable-memory-bytes b/internal/collector/test_files/test_data/node-allocatable-memory-bytes similarity index 100% rename from collector/test_files/test_data/node-allocatable-memory-bytes rename to internal/collector/test_files/test_data/node-allocatable-memory-bytes diff --git a/collector/test_files/test_data/node-capacity-cpu-cores b/internal/collector/test_files/test_data/node-capacity-cpu-cores similarity index 100% rename from collector/test_files/test_data/node-capacity-cpu-cores rename to internal/collector/test_files/test_data/node-capacity-cpu-cores diff --git a/collector/test_files/test_data/node-capacity-memory-bytes b/internal/collector/test_files/test_data/node-capacity-memory-bytes similarity index 100% rename from collector/test_files/test_data/node-capacity-memory-bytes rename to internal/collector/test_files/test_data/node-capacity-memory-bytes diff --git a/collector/test_files/test_data/node-labels b/internal/collector/test_files/test_data/node-labels similarity index 100% rename from collector/test_files/test_data/node-labels rename to internal/collector/test_files/test_data/node-labels diff --git a/collector/test_files/test_data/node-role b/internal/collector/test_files/test_data/node-role similarity index 100% rename from collector/test_files/test_data/node-role rename to internal/collector/test_files/test_data/node-role diff --git a/collector/test_files/test_data/persistentvolume-labels b/internal/collector/test_files/test_data/persistentvolume-labels similarity index 100% rename from collector/test_files/test_data/persistentvolume-labels rename to internal/collector/test_files/test_data/persistentvolume-labels diff --git a/collector/test_files/test_data/persistentvolume-pod-info b/internal/collector/test_files/test_data/persistentvolume-pod-info similarity index 100% rename from collector/test_files/test_data/persistentvolume-pod-info rename to internal/collector/test_files/test_data/persistentvolume-pod-info diff --git a/collector/test_files/test_data/persistentvolumeclaim-capacity-bytes b/internal/collector/test_files/test_data/persistentvolumeclaim-capacity-bytes similarity index 100% rename from collector/test_files/test_data/persistentvolumeclaim-capacity-bytes rename to internal/collector/test_files/test_data/persistentvolumeclaim-capacity-bytes diff --git a/collector/test_files/test_data/persistentvolumeclaim-labels b/internal/collector/test_files/test_data/persistentvolumeclaim-labels similarity index 100% rename from collector/test_files/test_data/persistentvolumeclaim-labels rename to internal/collector/test_files/test_data/persistentvolumeclaim-labels diff --git a/collector/test_files/test_data/persistentvolumeclaim-request-bytes b/internal/collector/test_files/test_data/persistentvolumeclaim-request-bytes similarity index 100% rename from collector/test_files/test_data/persistentvolumeclaim-request-bytes rename to internal/collector/test_files/test_data/persistentvolumeclaim-request-bytes diff --git a/collector/test_files/test_data/persistentvolumeclaim-usage-bytes b/internal/collector/test_files/test_data/persistentvolumeclaim-usage-bytes similarity index 100% rename from collector/test_files/test_data/persistentvolumeclaim-usage-bytes rename to internal/collector/test_files/test_data/persistentvolumeclaim-usage-bytes diff --git a/collector/test_files/test_data/pod-labels b/internal/collector/test_files/test_data/pod-labels similarity index 100% rename from collector/test_files/test_data/pod-labels rename to internal/collector/test_files/test_data/pod-labels diff --git a/collector/test_files/test_data/pod-limit-cpu-cores b/internal/collector/test_files/test_data/pod-limit-cpu-cores similarity index 100% rename from collector/test_files/test_data/pod-limit-cpu-cores rename to internal/collector/test_files/test_data/pod-limit-cpu-cores diff --git a/collector/test_files/test_data/pod-limit-memory-bytes b/internal/collector/test_files/test_data/pod-limit-memory-bytes similarity index 100% rename from collector/test_files/test_data/pod-limit-memory-bytes rename to internal/collector/test_files/test_data/pod-limit-memory-bytes diff --git a/collector/test_files/test_data/pod-request-cpu-cores b/internal/collector/test_files/test_data/pod-request-cpu-cores similarity index 100% rename from collector/test_files/test_data/pod-request-cpu-cores rename to internal/collector/test_files/test_data/pod-request-cpu-cores diff --git a/collector/test_files/test_data/pod-request-memory-bytes b/internal/collector/test_files/test_data/pod-request-memory-bytes similarity index 100% rename from collector/test_files/test_data/pod-request-memory-bytes rename to internal/collector/test_files/test_data/pod-request-memory-bytes diff --git a/collector/test_files/test_data/pod-usage-cpu-cores b/internal/collector/test_files/test_data/pod-usage-cpu-cores similarity index 100% rename from collector/test_files/test_data/pod-usage-cpu-cores rename to internal/collector/test_files/test_data/pod-usage-cpu-cores diff --git a/collector/test_files/test_data/pod-usage-memory-bytes b/internal/collector/test_files/test_data/pod-usage-memory-bytes similarity index 100% rename from collector/test_files/test_data/pod-usage-memory-bytes rename to internal/collector/test_files/test_data/pod-usage-memory-bytes diff --git a/collector/test_files/test_secrets/.gitkeep b/internal/collector/test_files/test_secrets/.gitkeep similarity index 100% rename from collector/test_files/test_secrets/.gitkeep rename to internal/collector/test_files/test_secrets/.gitkeep diff --git a/collector/types.go b/internal/collector/types.go similarity index 100% rename from collector/types.go rename to internal/collector/types.go diff --git a/controllers/kokumetricsconfig_controller.go b/internal/controller/kokumetricsconfig_controller.go similarity index 98% rename from controllers/kokumetricsconfig_controller.go rename to internal/controller/kokumetricsconfig_controller.go index daea83831..005a500ee 100644 --- a/controllers/kokumetricsconfig_controller.go +++ b/internal/controller/kokumetricsconfig_controller.go @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -package controllers +package controller import ( "context" @@ -32,13 +32,13 @@ import ( logr "sigs.k8s.io/controller-runtime/pkg/log" metricscfgv1beta1 "github.com/project-koku/koku-metrics-operator/api/v1beta1" - cv "github.com/project-koku/koku-metrics-operator/clusterversion" - "github.com/project-koku/koku-metrics-operator/collector" - "github.com/project-koku/koku-metrics-operator/crhchttp" - "github.com/project-koku/koku-metrics-operator/dirconfig" - "github.com/project-koku/koku-metrics-operator/packaging" - "github.com/project-koku/koku-metrics-operator/sources" - "github.com/project-koku/koku-metrics-operator/storage" + cv "github.com/project-koku/koku-metrics-operator/internal/clusterversion" + "github.com/project-koku/koku-metrics-operator/internal/collector" + "github.com/project-koku/koku-metrics-operator/internal/crhchttp" + "github.com/project-koku/koku-metrics-operator/internal/dirconfig" + "github.com/project-koku/koku-metrics-operator/internal/packaging" + "github.com/project-koku/koku-metrics-operator/internal/sources" + "github.com/project-koku/koku-metrics-operator/internal/storage" ) const HOURS_IN_DAY int = 23 // first hour is 0: 0 -> 23 == 24 hrs diff --git a/controllers/kokumetricsconfig_controller_test.go b/internal/controller/kokumetricsconfig_controller_test.go similarity index 99% rename from controllers/kokumetricsconfig_controller_test.go rename to internal/controller/kokumetricsconfig_controller_test.go index cd3e3c097..1882fb5ae 100644 --- a/controllers/kokumetricsconfig_controller_test.go +++ b/internal/controller/kokumetricsconfig_controller_test.go @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -package controllers +package controller import ( "context" @@ -28,11 +28,11 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" metricscfgv1beta1 "github.com/project-koku/koku-metrics-operator/api/v1beta1" - "github.com/project-koku/koku-metrics-operator/collector" - "github.com/project-koku/koku-metrics-operator/dirconfig" - "github.com/project-koku/koku-metrics-operator/mocks" - "github.com/project-koku/koku-metrics-operator/storage" - "github.com/project-koku/koku-metrics-operator/testutils" + "github.com/project-koku/koku-metrics-operator/internal/collector" + "github.com/project-koku/koku-metrics-operator/internal/dirconfig" + "github.com/project-koku/koku-metrics-operator/internal/mocks" + "github.com/project-koku/koku-metrics-operator/internal/storage" + "github.com/project-koku/koku-metrics-operator/internal/testutils" ) var ( diff --git a/controllers/prometheus.go b/internal/controller/prometheus.go similarity index 98% rename from controllers/prometheus.go rename to internal/controller/prometheus.go index 39e35ae58..fd745bfa2 100644 --- a/controllers/prometheus.go +++ b/internal/controller/prometheus.go @@ -1,4 +1,4 @@ -package controllers +package controller import ( "context" @@ -14,8 +14,8 @@ import ( "k8s.io/apimachinery/pkg/types" metricscfgv1beta1 "github.com/project-koku/koku-metrics-operator/api/v1beta1" - "github.com/project-koku/koku-metrics-operator/collector" - "github.com/project-koku/koku-metrics-operator/dirconfig" + "github.com/project-koku/koku-metrics-operator/internal/collector" + "github.com/project-koku/koku-metrics-operator/internal/dirconfig" ) var ( diff --git a/controllers/suite_data_test.go b/internal/controller/suite_data_test.go similarity index 98% rename from controllers/suite_data_test.go rename to internal/controller/suite_data_test.go index 674aa0ffa..cff4c6ee3 100644 --- a/controllers/suite_data_test.go +++ b/internal/controller/suite_data_test.go @@ -1,4 +1,4 @@ -package controllers +package controller import ( "encoding/json" diff --git a/controllers/suite_test.go b/internal/controller/suite_test.go similarity index 98% rename from controllers/suite_test.go rename to internal/controller/suite_test.go index 8171b3474..9ef2f5ffb 100644 --- a/controllers/suite_test.go +++ b/internal/controller/suite_test.go @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 // -package controllers +package controller import ( "context" @@ -39,8 +39,8 @@ import ( metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" metricscfgv1beta1 "github.com/project-koku/koku-metrics-operator/api/v1beta1" - "github.com/project-koku/koku-metrics-operator/dirconfig" - "github.com/project-koku/koku-metrics-operator/testutils" + "github.com/project-koku/koku-metrics-operator/internal/dirconfig" + "github.com/project-koku/koku-metrics-operator/internal/testutils" // +kubebuilder:scaffold:imports ) @@ -195,7 +195,7 @@ var _ = BeforeSuite(func() { testEnv = &envtest.Environment{ UseExistingCluster: &useCluster, CRDDirectoryPaths: []string{ - filepath.Join("..", "config", "crd", "bases"), + filepath.Join("..", "..", "config", "crd", "bases"), filepath.Join("test_files", "crds"), }, } diff --git a/controllers/test_files/crds/config.openshift.io_clusterversions.yaml b/internal/controller/test_files/crds/config.openshift.io_clusterversions.yaml similarity index 100% rename from controllers/test_files/crds/config.openshift.io_clusterversions.yaml rename to internal/controller/test_files/crds/config.openshift.io_clusterversions.yaml diff --git a/controllers/test_files/kubeconfig b/internal/controller/test_files/kubeconfig similarity index 100% rename from controllers/test_files/kubeconfig rename to internal/controller/test_files/kubeconfig diff --git a/controllers/test_files/testFile.tar.gz b/internal/controller/test_files/testFile.tar.gz similarity index 100% rename from controllers/test_files/testFile.tar.gz rename to internal/controller/test_files/testFile.tar.gz diff --git a/crhchttp/config.go b/internal/crhchttp/config.go similarity index 100% rename from crhchttp/config.go rename to internal/crhchttp/config.go diff --git a/crhchttp/config_test.go b/internal/crhchttp/config_test.go similarity index 100% rename from crhchttp/config_test.go rename to internal/crhchttp/config_test.go diff --git a/crhchttp/http_cloud_dot_redhat.go b/internal/crhchttp/http_cloud_dot_redhat.go similarity index 99% rename from crhchttp/http_cloud_dot_redhat.go rename to internal/crhchttp/http_cloud_dot_redhat.go index 8a4f1dbb0..812f4343e 100644 --- a/crhchttp/http_cloud_dot_redhat.go +++ b/internal/crhchttp/http_cloud_dot_redhat.go @@ -25,7 +25,7 @@ import ( logr "sigs.k8s.io/controller-runtime/pkg/log" metricscfgv1beta1 "github.com/project-koku/koku-metrics-operator/api/v1beta1" - "github.com/project-koku/koku-metrics-operator/packaging" + "github.com/project-koku/koku-metrics-operator/internal/packaging" ) // Client is an http.Client diff --git a/crhchttp/suite_test.go b/internal/crhchttp/suite_test.go similarity index 97% rename from crhchttp/suite_test.go rename to internal/crhchttp/suite_test.go index dedd6d8bb..6193961ef 100755 --- a/crhchttp/suite_test.go +++ b/internal/crhchttp/suite_test.go @@ -19,7 +19,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/envtest" logf "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/project-koku/koku-metrics-operator/testutils" + "github.com/project-koku/koku-metrics-operator/internal/testutils" ) var ( diff --git a/dirconfig/dirconfig.go b/internal/dirconfig/dirconfig.go similarity index 100% rename from dirconfig/dirconfig.go rename to internal/dirconfig/dirconfig.go diff --git a/dirconfig/dirconfig_test.go b/internal/dirconfig/dirconfig_test.go similarity index 99% rename from dirconfig/dirconfig_test.go rename to internal/dirconfig/dirconfig_test.go index 89446ac72..023617d7d 100644 --- a/dirconfig/dirconfig_test.go +++ b/internal/dirconfig/dirconfig_test.go @@ -12,7 +12,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/project-koku/koku-metrics-operator/testutils" + "github.com/project-koku/koku-metrics-operator/internal/testutils" ) var errTest = errors.New("test error") @@ -52,7 +52,6 @@ func (mfi MockFileInfo) Size() int64 { return 100 } func (mfi MockFileInfo) ModTime() time.Time { return time.Unix(110, 0) } func (mfi MockFileInfo) IsDir() bool { return mfi.isDir } func (mfi MockFileInfo) Sys() any { return nil } - func (mfi MockFileInfo) Mode() os.FileMode { if mfi.isDir { return os.ModeDir diff --git a/dirconfig/test_files/test_file b/internal/dirconfig/test_files/test_file similarity index 100% rename from dirconfig/test_files/test_file rename to internal/dirconfig/test_files/test_file diff --git a/mocks/mock_collector.go b/internal/mocks/mock_collector.go similarity index 100% rename from mocks/mock_collector.go rename to internal/mocks/mock_collector.go diff --git a/packaging/packaging.go b/internal/packaging/packaging.go similarity index 99% rename from packaging/packaging.go rename to internal/packaging/packaging.go index 28d927704..390e21bf8 100644 --- a/packaging/packaging.go +++ b/internal/packaging/packaging.go @@ -26,8 +26,8 @@ import ( logr "sigs.k8s.io/controller-runtime/pkg/log" metricscfgv1beta1 "github.com/project-koku/koku-metrics-operator/api/v1beta1" - "github.com/project-koku/koku-metrics-operator/dirconfig" - "github.com/project-koku/koku-metrics-operator/strset" + "github.com/project-koku/koku-metrics-operator/internal/dirconfig" + "github.com/project-koku/koku-metrics-operator/internal/strset" ) // FilePackager struct for defining the packaging vars diff --git a/packaging/packaging_test.go b/internal/packaging/packaging_test.go similarity index 99% rename from packaging/packaging_test.go rename to internal/packaging/packaging_test.go index 9c6f8f32d..7c4306172 100644 --- a/packaging/packaging_test.go +++ b/internal/packaging/packaging_test.go @@ -25,8 +25,8 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" metricscfgv1beta1 "github.com/project-koku/koku-metrics-operator/api/v1beta1" - "github.com/project-koku/koku-metrics-operator/dirconfig" - "github.com/project-koku/koku-metrics-operator/testutils" + "github.com/project-koku/koku-metrics-operator/internal/dirconfig" + "github.com/project-koku/koku-metrics-operator/internal/testutils" ) var testingDir string diff --git a/packaging/test_files/20210720T180121-cost-mgmt.tar.gz b/internal/packaging/test_files/20210720T180121-cost-mgmt.tar.gz similarity index 100% rename from packaging/test_files/20210720T180121-cost-mgmt.tar.gz rename to internal/packaging/test_files/20210720T180121-cost-mgmt.tar.gz diff --git a/packaging/test_files/bad-csv.csv b/internal/packaging/test_files/bad-csv.csv similarity index 100% rename from packaging/test_files/bad-csv.csv rename to internal/packaging/test_files/bad-csv.csv diff --git a/packaging/test_files/badfile.tar.gz b/internal/packaging/test_files/badfile.tar.gz similarity index 100% rename from packaging/test_files/badfile.tar.gz rename to internal/packaging/test_files/badfile.tar.gz diff --git a/packaging/test_files/nonCSV.txt b/internal/packaging/test_files/nonCSV.txt similarity index 100% rename from packaging/test_files/nonCSV.txt rename to internal/packaging/test_files/nonCSV.txt diff --git a/packaging/test_files/ocp_node_label.csv b/internal/packaging/test_files/ocp_node_label.csv similarity index 100% rename from packaging/test_files/ocp_node_label.csv rename to internal/packaging/test_files/ocp_node_label.csv diff --git a/packaging/test_files/ocp_pod_label.csv b/internal/packaging/test_files/ocp_pod_label.csv similarity index 100% rename from packaging/test_files/ocp_pod_label.csv rename to internal/packaging/test_files/ocp_pod_label.csv diff --git a/packaging/test_files/ocp_pod_missing_end.csv b/internal/packaging/test_files/ocp_pod_missing_end.csv similarity index 100% rename from packaging/test_files/ocp_pod_missing_end.csv rename to internal/packaging/test_files/ocp_pod_missing_end.csv diff --git a/packaging/test_files/ocp_pod_missing_header.csv b/internal/packaging/test_files/ocp_pod_missing_header.csv similarity index 100% rename from packaging/test_files/ocp_pod_missing_header.csv rename to internal/packaging/test_files/ocp_pod_missing_header.csv diff --git a/packaging/test_files/ocp_pod_missing_start.csv b/internal/packaging/test_files/ocp_pod_missing_start.csv similarity index 100% rename from packaging/test_files/ocp_pod_missing_start.csv rename to internal/packaging/test_files/ocp_pod_missing_start.csv diff --git a/packaging/test_files/ros-openshift.csv b/internal/packaging/test_files/ros-openshift.csv similarity index 100% rename from packaging/test_files/ros-openshift.csv rename to internal/packaging/test_files/ros-openshift.csv diff --git a/packaging/test_files/small-csv.csv b/internal/packaging/test_files/small-csv.csv similarity index 100% rename from packaging/test_files/small-csv.csv rename to internal/packaging/test_files/small-csv.csv diff --git a/sources/handler.go b/internal/sources/handler.go similarity index 99% rename from sources/handler.go rename to internal/sources/handler.go index 618d48c8d..e0e7e7599 100644 --- a/sources/handler.go +++ b/internal/sources/handler.go @@ -16,7 +16,7 @@ import ( logr "sigs.k8s.io/controller-runtime/pkg/log" metricscfgv1beta1 "github.com/project-koku/koku-metrics-operator/api/v1beta1" - "github.com/project-koku/koku-metrics-operator/crhchttp" + "github.com/project-koku/koku-metrics-operator/internal/crhchttp" ) const ( diff --git a/sources/handler_test.go b/internal/sources/handler_test.go similarity index 99% rename from sources/handler_test.go rename to internal/sources/handler_test.go index 7111932b3..2b2d0bff4 100644 --- a/sources/handler_test.go +++ b/internal/sources/handler_test.go @@ -19,8 +19,8 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" metricscfgv1beta1 "github.com/project-koku/koku-metrics-operator/api/v1beta1" - "github.com/project-koku/koku-metrics-operator/crhchttp" - "github.com/project-koku/koku-metrics-operator/testutils" + "github.com/project-koku/koku-metrics-operator/internal/crhchttp" + "github.com/project-koku/koku-metrics-operator/internal/testutils" ) var ( diff --git a/storage/storage.go b/internal/storage/storage.go similarity index 100% rename from storage/storage.go rename to internal/storage/storage.go diff --git a/storage/storage_test.go b/internal/storage/storage_test.go similarity index 98% rename from storage/storage_test.go rename to internal/storage/storage_test.go index c50bbed98..b26f2dc80 100644 --- a/storage/storage_test.go +++ b/internal/storage/storage_test.go @@ -20,8 +20,8 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" metricscfgv1beta1 "github.com/project-koku/koku-metrics-operator/api/v1beta1" - "github.com/project-koku/koku-metrics-operator/dirconfig" - "github.com/project-koku/koku-metrics-operator/testutils" + "github.com/project-koku/koku-metrics-operator/internal/dirconfig" + "github.com/project-koku/koku-metrics-operator/internal/testutils" ) var ( diff --git a/storage/suite_test.go b/internal/storage/suite_test.go similarity index 96% rename from storage/suite_test.go rename to internal/storage/suite_test.go index a19ae3c6c..02bae7123 100644 --- a/storage/suite_test.go +++ b/internal/storage/suite_test.go @@ -22,7 +22,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/envtest" logf "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/project-koku/koku-metrics-operator/testutils" + "github.com/project-koku/koku-metrics-operator/internal/testutils" // +kubebuilder:scaffold:imports ) diff --git a/storage/test_files/crds/operators.coreos.com_clusterserviceversions.yaml b/internal/storage/test_files/crds/operators.coreos.com_clusterserviceversions.yaml similarity index 100% rename from storage/test_files/crds/operators.coreos.com_clusterserviceversions.yaml rename to internal/storage/test_files/crds/operators.coreos.com_clusterserviceversions.yaml diff --git a/strset/strset.go b/internal/strset/strset.go similarity index 100% rename from strset/strset.go rename to internal/strset/strset.go diff --git a/strset/strset_test.go b/internal/strset/strset_test.go similarity index 100% rename from strset/strset_test.go rename to internal/strset/strset_test.go diff --git a/testutils/certs.go b/internal/testutils/certs.go similarity index 100% rename from testutils/certs.go rename to internal/testutils/certs.go diff --git a/testutils/interface_to_file.go b/internal/testutils/interface_to_file.go similarity index 100% rename from testutils/interface_to_file.go rename to internal/testutils/interface_to_file.go diff --git a/testutils/random_string.go b/internal/testutils/random_string.go similarity index 100% rename from testutils/random_string.go rename to internal/testutils/random_string.go diff --git a/testutils/testlogr.go b/internal/testutils/testlogr.go similarity index 100% rename from testutils/testlogr.go rename to internal/testutils/testlogr.go diff --git a/scripts/requirements.txt b/scripts/requirements.txt new file mode 100644 index 000000000..7feeca342 --- /dev/null +++ b/scripts/requirements.txt @@ -0,0 +1 @@ +packaging==23.2 diff --git a/scripts/txt_replace.py b/scripts/txt_replace.py index e5b970266..428c27015 100755 --- a/scripts/txt_replace.py +++ b/scripts/txt_replace.py @@ -1,11 +1,15 @@ #!/usr/bin/env python3 import argparse -import pkg_resources import re from datetime import datetime, timezone from tempfile import mkstemp from shutil import move, copymode -from os import fdopen, path, remove +from os import fdopen, remove + +try: + from packaging.version import parse +except ImportError as e: + raise ImportError('`packaging` module not found, install with `pip3 install packaging`') from e valid_semver = re.compile("^(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$") @@ -15,7 +19,7 @@ def check_version(new, old): exit(1) if (matched_new := re.fullmatch(valid_semver, new)) and (matched_old := re.fullmatch(valid_semver, old)): - if pkg_resources.parse_version(new) <= pkg_resources.parse_version(old): + if parse(new) <= parse(old): print("\nnew version must sequentially follow old version!") exit(1) return