Skip to content

Commit

Permalink
moving worker to cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusfm committed Mar 16, 2023
1 parent f7e7cf7 commit 407e4b5
Show file tree
Hide file tree
Showing 20 changed files with 19 additions and 17 deletions.
10 changes: 5 additions & 5 deletions Dockerfile.worker
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download

COPY worker/ worker/
COPY cmd/worker/main.go cmd/worker/main.go
COPY apis/ apis/
COPY pkg/ pkg/

RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o bin/worker worker/main.go
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o worker cmd/worker/main.go

FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/bin/worker /usr/local/bin/
USER 65534:65534
COPY --from=builder /workspace/worker .
USER 65532:65532

ENTRYPOINT ["/usr/local/bin/worker"]
ENTRYPOINT ["/worker"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ clientset-gen: ## Generate clientset

build: generate fmt vet ## Build manager binary.
go build -o bin/manager main.go
go build -o bin/worker worker/main.go
go build -o bin/worker cmd/worker/main.go

run: install manifests generate ## Run a controller from your host.
go run ./main.go -default-plugins-names ${PLUGINS} -worker-image ${WORKER_IMG}
Expand Down
3 changes: 2 additions & 1 deletion worker/main.go → cmd/worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ package main
import (
"time"

"github.com/undistro/zora/worker/run"
"go.uber.org/zap/zapcore"

ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

"github.com/undistro/zora/pkg/worker/run"
)

var log = ctrl.Log.WithName("worker")
Expand Down
2 changes: 1 addition & 1 deletion docs/cluster-scan.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,5 @@ kubectl get clusterissues -l cluster=mycluster,scanID=fa4e63cc-5236-40f3-aa7f-59

These docs should help you understand why it's an issue and how to fix it.

All URLs are available [here](https://github.com/undistro/zora/blob/main/worker/report/popeye/parse_types.go#L109)
All URLs are available [here](https://github.com/undistro/zora/blob/main/pkg/worker/report/popeye/parse_types.go#L109)
and you can contribute to Zora adding new links. See our [contribution guidelines](https://github.com/undistro/zora/blob/main/CONTRIBUTING.md).
2 changes: 1 addition & 1 deletion worker/config/config.go → pkg/worker/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/go-logr/logr"

zorav1a1 "github.com/undistro/zora/apis/zora/v1alpha1"
"github.com/undistro/zora/worker/report/popeye"
"github.com/undistro/zora/pkg/worker/report/popeye"
)

const (
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion worker/report/parse.go → pkg/worker/report/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import (
"strings"

"github.com/go-logr/logr"

zorav1a1 "github.com/undistro/zora/apis/zora/v1alpha1"
"github.com/undistro/zora/worker/config"
"github.com/undistro/zora/pkg/worker/config"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"k8s.io/apimachinery/pkg/types"

zorav1a1 "github.com/undistro/zora/apis/zora/v1alpha1"
"github.com/undistro/zora/worker/config"
"github.com/undistro/zora/pkg/worker/config"
)

func TestParse(t *testing.T) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func TestParse(t *testing.T) {
return cis[i].ID > cis[j].ID
})
for c := 0; c < len(cis); c++ {
for r, _ := range cis[c].Resources {
for r := range cis[c].Resources {
sort.Strings(cis[c].Resources[r])
}
}
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions worker/run/run.go → pkg/worker/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ import (
"time"

"github.com/go-logr/logr"
"github.com/undistro/zora/pkg/clientset/versioned"
"github.com/undistro/zora/worker/config"
"github.com/undistro/zora/worker/report"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

ctrl "sigs.k8s.io/controller-runtime"

zorav1a1 "github.com/undistro/zora/apis/zora/v1alpha1"
"github.com/undistro/zora/pkg/clientset/versioned"
"github.com/undistro/zora/pkg/worker/config"
"github.com/undistro/zora/pkg/worker/report"
)

// CreateClusterIssues creates instances of <ClusterIssue> on the Kubernetes
Expand Down
2 changes: 1 addition & 1 deletion worker/run/run_test.go → pkg/worker/run/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"path"
"testing"

"github.com/undistro/zora/worker/config"
"github.com/undistro/zora/pkg/worker/config"
)

func TestDone(t *testing.T) {
Expand Down

0 comments on commit 407e4b5

Please sign in to comment.