Skip to content

Commit

Permalink
Go Code format checker and formatter (#112)
Browse files Browse the repository at this point in the history
Also formatted the files which dont adhere to go formats.
Build will fail if there exists any formatting issue
  • Loading branch information
faraazbrcm authored Nov 15, 2023
1 parent faaa9f5 commit faa2a51
Show file tree
Hide file tree
Showing 51 changed files with 3,582 additions and 3,588 deletions.
9 changes: 8 additions & 1 deletion cvl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ SRC_FILES=$(shell find . -name '*.go' | grep -v '_test.go' | grep -v '/tests/')
TEST_FILES=$(wildcard *_test.go)
TOP_DIR := ..
BUILD_DIR:=$(TOP_DIR)/build/cvl
FORMAT_CHECK = $(BUILD_DIR)/.formatcheck

CVL_SCHEMA_DIR = $(BUILD_DIR)/schema
CVL_SCHEMA = $(CVL_SCHEMA_DIR)/.done
Expand All @@ -36,7 +37,7 @@ CVL_TEST_SCHEMA = $(CVL_TEST_SCHEMA_DIR)/.done
CVL_TEST_YANGS = $(wildcard testdata/schema/*.yang)
CVL_TEST_YANGS += $(wildcard $(YANG_SRC_DIR)/sonic/common/*.yang)

DEFAULT_TARGETS = $(CVL_SCHEMA)
DEFAULT_TARGETS = $(CVL_SCHEMA) $(FORMAT_CHECK)
ifeq ($(NO_TEST_BINS),)
DEFAULT_TARGETS += $(CVL_TEST_BIN)
endif
Expand Down Expand Up @@ -79,6 +80,12 @@ gotest: $(CVL_TEST_SCHEMA)
CVL_SCHEMA_PATH=$(abspath $(CVL_TEST_SCHEMA_DIR)) \
tests/run_test.sh

$(FORMAT_CHECK): $(SRC_FILES) $(TEST_FILES) | $$(@D)/.
$(TOP_DIR)/tools/test/format-check.sh \
--log=$(@D)/formatcheck.log \
$?
touch $@

clean:
$(RM) -r $(CVL_TEST_DIR) $(BUILD_DIR)

Expand Down
8 changes: 4 additions & 4 deletions cvl/custom_validation/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ const (

// CVLEditConfigData Strcture for key and data in API
type CVLEditConfigData struct {
VType CVLValidateType //Validation type
VOp CVLOperation //Operation type
Key string //Key format : "PORT|Ethernet4"
Data map[string]string //Value : {"alias": "40GE0/28", "mtu" : 9100, "admin_status": down}
VType CVLValidateType //Validation type
VOp CVLOperation //Operation type
Key string //Key format : "PORT|Ethernet4"
Data map[string]string //Value : {"alias": "40GE0/28", "mtu" : 9100, "admin_status": down}
}

// CVLErrorInfo CVL Error Structure
Expand Down
Loading

0 comments on commit faa2a51

Please sign in to comment.