Skip to content

Commit

Permalink
chore: change golang to 1.21 and istio to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
shengjiangfeng committed Sep 11, 2024
1 parent 35f65b5 commit 208b1a0
Show file tree
Hide file tree
Showing 4,091 changed files with 1,525,639 additions and 410 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

90 changes: 90 additions & 0 deletions .idea/workspace.xml

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

5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

# Build the operator binary
FROM golang:1.18 as builder
FROM golang:1.21 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -35,7 +35,7 @@ COPY controller/reconciler.go controller/reconciler.go

# Run after copying so the files are generated into
# the docker's api/ folder instead of the host
RUN make generate
# RUN make generate

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o operator main.go
Expand All @@ -44,6 +44,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o operator
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
#COPY --from=builder /workspace/operator .
COPY --from=builder /workspace/operator .
USER nonroot:nonroot

Expand Down
51 changes: 51 additions & 0 deletions Dockerfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# Copyright 2021 - now, the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Build the operator binary
FROM golang:1.21 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
COPY hack hack/
COPY Makefile Makefile
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY api api/
COPY controller/controller.go controller/controller.go
COPY controller/reconciler.go controller/reconciler.go


# Run after copying so the files are generated into
# the docker's api/ folder instead of the host
# RUN make generate

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o operator main.go

# Use distroless as minimal base image to package the operator binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
#COPY --from=builder /workspace/operator .
COPY --from=builder /workspace/operator .
USER nonroot:nonroot

ENTRYPOINT ["/operator"]
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ help: ## Display this help.

##@ Development

.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases

generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
Expand Down
3 changes: 1 addition & 2 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
)

type VirtualServicePatchReconciler struct {
Expand Down Expand Up @@ -61,7 +60,7 @@ func (r *VirtualServicePatchReconciler) Configure(ctx reconciler.Context) error
},
},
)).
Watches(&source.Kind{Type: &istio.VirtualService{}}, handler.EnqueueRequestsFromMapFunc(func(obj client.Object) []reconcile.Request {
Watches(&istio.VirtualService{}, handler.EnqueueRequestsFromMapFunc(func(ctx2 context.Context, obj client.Object) []reconcile.Request {
vs := obj.(*istio.VirtualService)
requests := make([]reconcile.Request, 0)

Expand Down
7 changes: 7 additions & 0 deletions controller/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package controllers
import (
"context"
"fmt"
"sigs.k8s.io/yaml"

"github.com/monimesl/istio-virtualservice-merger/api/v1alpha1"
"github.com/monimesl/operator-helper/oputil"
Expand Down Expand Up @@ -111,6 +112,9 @@ func updateTarget(ctx reconciler.Context, client versionedclient.Interface, patc
if err != nil {
return err
}
data, err := yaml.Marshal(target)
fmt.Println("orgin target ")
fmt.Println(string(data))
if remove {
patch.RemoveTcpRoutes(target)
patch.RemoveTlsRoutes(target)
Expand All @@ -120,6 +124,9 @@ func updateTarget(ctx reconciler.Context, client versionedclient.Interface, patc
patch.AddTlsRoutes(target)
patch.AddHttpRoutes(ctx, target)
}
data1, err := yaml.Marshal(target)
fmt.Println("patched target ")
fmt.Println(string(data1))
if _, err = client.NetworkingV1alpha3().VirtualServices(targetNamespace).
Update(context.TODO(), target, metav1.UpdateOptions{}); err != nil {
return err
Expand Down
Loading

0 comments on commit 208b1a0

Please sign in to comment.