Skip to content

Commit

Permalink
Initialize Initialize the contributor file
Browse files Browse the repository at this point in the history
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
  • Loading branch information
cubxxw committed Apr 2, 2023
1 parent 970a449 commit 49e478d
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 21 deletions.
10 changes: 5 additions & 5 deletions build/buildimage/differ.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ import (
osi "github.com/sealerio/sealer/utils/os"
)

// TODO: update the variable name
// TODO: update the variable name.
var (
copyToManifests = "manifests"
copyToChart = "charts"
copyToImageList = "imageList"
copyToApplication = "application"
)

type parseContainerImageStringSliceFunc func(srcPath string) ([]string, error)
type parseContainerImageListFunc func(srcPath string) ([]*v12.ContainerImage, error)
type (
parseContainerImageStringSliceFunc func(srcPath string) ([]string, error)
parseContainerImageListFunc func(srcPath string) ([]*v12.ContainerImage, error)
)

var parseContainerImageStringSliceFuncMap = map[string]func(srcPath string) ([]string, error){
copyToManifests: parseYamlImages,
Expand Down Expand Up @@ -274,7 +276,6 @@ func parseApplicationKubeImages(kubePath string) ([]string, error) {
}

ima, err := imageSearcher.ListImages(path)

if err != nil {
return err
}
Expand Down Expand Up @@ -351,7 +352,6 @@ func parseYamlImages(srcPath string) ([]string, error) {
}

ima, err := imageSearcher.ListImages(path)

if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions build/kubefile/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ const (
Label = "label"
Maintainer = "maintainer"

// Deprecated
// Deprecated.
Cmd = "cmd"

// the following commands are the intenal implementations for kube commands
// the following commands are the intenal implementations for kube commands.
Add = "add"
Arg = "arg"
Copy = "copy"
Expand All @@ -56,7 +56,7 @@ var (
LabelKubeCSIPrefix = fmt.Sprintf("%s-", LabelSupportedKubeCSIAlpha)
)

// SupportedCommands is list of all Kubefile commands
// SupportedCommands is list of all Kubefile commands.
var SupportedCommands = map[string]struct{}{
Add: {},
Arg: {},
Expand Down
2 changes: 1 addition & 1 deletion pkg/checker/node_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (n *NodeChecker) Check(cluster *v2.Cluster, phase string) error {
}

func (n *NodeChecker) Output(nodeCLusterStatus NodeClusterStatus) error {
//t1, err := template.ParseFiles("templates/node_checker.tpl")
// t1, err := template.ParseFiles("templates/node_checker.tpl")
t := template.New("node_checker")
t, err := t.Parse(
`Cluster Node Status
Expand Down
13 changes: 13 additions & 0 deletions scripts/coverage.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env awk

{
print $0
if (match($0, /^total:/)) {
sub(/%/, "", $NF);
printf("test coverage is %s%(quality gate is %s%)\n", $NF, target)
if (strtonum($NF) < target) {
printf("test coverage does not meet expectations: %d%, please add test cases!\n", target)
exit 1;
}
}
}
15 changes: 14 additions & 1 deletion scripts/make-rules/ca.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,17 @@
# 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.
# limitations under the License.

# ==============================================================================
# Makefile helper functions for create CA files
#

.PHONY: ca.gen.%
ca.gen.%:
$(eval CA := $(word 1,$(subst ., ,$*)))
@echo "===========> Generating CA files for $(CA)"
@${ROOT_DIR}/scripts/gencerts.sh generate-iam-cert $(OUTPUT_DIR)/cert $(CA)

.PHONY: ca.gen
ca.gen: $(addprefix ca.gen., $(CERTIFICATES))
25 changes: 24 additions & 1 deletion scripts/make-rules/dependencies.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,27 @@
# 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.
# limitations under the License.

# ==============================================================================
# Makefile helper functions for dependencies
#

.PHONY: dependencies.run
dependencies.run: dependencies.packages dependencies.tools

.PHONY: dependencies.packages
dependencies.packages:
@$(GO) mod tidy

.PHONY: dependencies.tools
dependencies.tools: dependencies.tools.blocker dependencies.tools.critical

.PHONY: dependencies.tools.blocker
dependencies.tools.blocker: go.build.verify $(addprefix tools.verify., $(BLOCKER_TOOLS))

.PHONY: dependencies.tools.critical
dependencies.tools.critical: $(addprefix tools.verify., $(CRITICAL_TOOLS))

.PHONY: dependencies.tools.trivial
dependencies.tools.trivial: $(addprefix tools.verify., $(TRIVIAL_TOOLS))
26 changes: 25 additions & 1 deletion scripts/make-rules/deploy.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,28 @@
# 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.
# limitations under the License.

# ==============================================================================
# Makefile helper functions for deploy to developer env
#

KUBECTL := kubectl
NAMESPACE ?= iam
CONTEXT ?= marmotedu.dev

DEPLOYS=iam-apiserver iam-authz-server iam-pump iam-watcher

.PHONY: deploy.run.all
deploy.run.all:
@echo "===========> Deploying all"
@$(MAKE) deploy.run

.PHONY: deploy.run
deploy.run: $(addprefix deploy.run., $(DEPLOYS))

.PHONY: deploy.run.%
deploy.run.%:
$(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM))))
@echo "===========> Deploying $* $(VERSION)-$(ARCH)"
echo @$(KUBECTL) -n $(NAMESPACE) --context=$(CONTEXT) set image deployment/$* $*=$(REGISTRY_PREFIX)/$*-$(ARCH):$(VERSION)
39 changes: 32 additions & 7 deletions scripts/make-rules/golang.mk
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ EXCLUDE_TESTS := github.com/sealerio/sealer/test github.com/sealerio/sealer/pkg/
# └── seautil
# └── linux_amd64
# └── seautil
# COMMAND=sealer
# PLATFORM=linux_amd64
# OS=linux
# ARCH=amd64
# BINS=sealer seautil
# BIN_DIR=/root/workspaces/sealer/_output/bin
# ==============================================================================

## go.build.verify: Verify that a suitable version of Go exists
Expand All @@ -106,13 +112,24 @@ go.build.%:
$(eval PLATFORM := $(word 1,$(subst ., ,$*)))
$(eval OS := $(word 1,$(subst _, ,$(PLATFORM))))
$(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM))))
@echo "COMMAND=$(COMMAND)"
@echo "PLATFORM=$(PLATFORM)"
@echo "OS=$(OS)"
@echo "ARCH=$(ARCH)"
@echo "BINS=$(BINS)"
@echo "BIN_DIR=$(BIN_DIR)"
@echo "===========> Building binary $(COMMAND) $(VERSION) for $(OS) $(ARCH)"
@mkdir -p $(OUTPUT_DIR)/bin/$(OS)/$(ARCH)

@CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o $(OUTPUT_DIR)/bin/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) $(ROOT_PACKAGE)/cmd/$(COMMAND)

## go.build: Build binaries
.PHONY: go.build
go.build: go.build.verify $(addprefix go.build., $(addprefix $(PLATFORM)., $(BINS)))
@echo "COMMAND=$(COMMAND)"
@echo "PLATFORM=$(PLATFORM)"
@echo "OS=$(OS)"
@echo "ARCH=$(ARCH)"
@echo "===========> Building binary $(BINS) $(VERSION) for $(PLATFORM)"

## go.build.multiarch: Build multi-arch binaries
Expand All @@ -123,25 +140,33 @@ go.build.multiarch: go.build.verify $(foreach p,$(PLATFORMS),$(addprefix go.buil
.PHONY: go.lint
go.lint: tools.verify.golangci-lint
@echo "===========> Run golangci to lint source codes"
@golangci-lint run -c $(ROOT_DIR)/.golangci.yaml $(ROOT_DIR)/...
@golangci-lint run -c $(ROOT_DIR)/.golangci.yml $(ROOT_DIR)/...

## go.test: Run unit test
.PHONY: go.test
go.test: tools.verify.go-junit-report
@echo "===========> Run unit test"
@set -o pipefail;$(GO) test -race -cover -coverprofile=$(OUTPUT_DIR)/coverage.out \
-timeout=10m -shuffle=on -short -v `go list ./...|\
egrep -v $(subst $(SPACE),'|',$(sort $(EXCLUDE_TESTS)))` 2>&1 | \
tee >(go-junit-report --set-exit-code >$(OUTPUT_DIR)/report.xml)
@sed -i '/mock_.*.go/d' $(OUTPUT_DIR)/coverage.out # remove mock_.*.go files from test coverage
@$(GO) tool cover -html=$(OUTPUT_DIR)/coverage.out -o $(OUTPUT_DIR)/coverage.html
# @set -o pipefail;$(GO) test -race -cover -coverprofile=$(OUTPUT_DIR)/coverage.out \
# -timeout=10m -shuffle=on -short -v `go list ./...|\
# egrep -v $(subst $(SPACE),'|',$(sort $(EXCLUDE_TESTS)))` 2>&1 | \
# tee >(go-junit-report --set-exit-code >$(OUTPUT_DIR)/report.xml)
# @sed -i '/mock_.*.go/d' $(OUTPUT_DIR)/coverage.out # remove mock_.*.go files from test coverage
# @$(GO) tool cover -html=$(OUTPUT_DIR)/coverage.out -o $(OUTPUT_DIR)/coverage.html

## go.test.cover: Run unit test and check coverage
.PHONY: go.test.cover
go.test.cover: go.test
@$(GO) tool cover -func=$(OUTPUT_DIR)/coverage.out | \
awk -v target=$(COVERAGE) -f $(ROOT_DIR)/scripts/coverage.awk

## go.test.integration: Run integration test
.PHONY: go.format
go.format: tools.verify.goimports
@echo "===========> Formating codes"
@$(FIND) -type f -name '*.go' | xargs gofmt -s -w
@$(FIND) -type f -name '*.go' | xargs $(TOOLS_DIR)/goimports -l -w -local $(ROOT_PACKAGE)
@$(GO) mod edit -fmt

## go.updates: Check for updates to go.mod dependencies
.PHONY: go.updates
go.updates: tools.verify.go-mod-outdated
Expand Down
22 changes: 21 additions & 1 deletion scripts/make-rules/release.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,24 @@
# 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.
# limitations under the License.

# ==============================================================================
# Makefile helper functions for release
#
#

.PHONY: release.run
release.run: release.verify release.ensure-tag
@scripts/release.sh

.PHONY: release.verify
release.verify: tools.verify.git-chglog tools.verify.github-release tools.verify.coscmd

.PHONY: release.tag
release.tag: tools.verify.gsemver release.ensure-tag
@git push origin `git describe --tags --abbrev=0`

.PHONY: release.ensure-tag
release.ensure-tag: tools.verify.gsemver
@scripts/ensure_tag.sh
15 changes: 14 additions & 1 deletion scripts/make-rules/swagger.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,17 @@
# 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.
# limitations under the License.

# ==============================================================================
# Makefile helper functions for swagger
#

.PHONY: swagger.run
swagger.run: tools.verify.swagger
@echo "===========> Generating swagger API docs"
@swagger generate spec --scan-models -w $(ROOT_DIR)/cmd/genswaggertypedocs -o $(ROOT_DIR)/api/swagger/swagger.yaml

.PHONY: swagger.serve
swagger.serve: tools.verify.swagger
@swagger serve -F=redoc --no-open --port 36666 $(ROOT_DIR)/api/swagger/swagger.yaml
5 changes: 5 additions & 0 deletions scripts/make-rules/tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ install.ginkgo:
# Tools that might be used include go gvm
#

.PHONY: install.go-junit-report
## go-junit-report: Install go-junit-report, used to convert go test output to junit xml
install.go-junit-report:
@$(GO) install github.com/jstemmer/go-junit-report@latest

.PHONY: install.kube-score
## install.kube-score: Install kube-score, used to check kubernetes yaml files
install.kube-score:
Expand Down

0 comments on commit 49e478d

Please sign in to comment.