From b2a1bdf70a8ac7b67ec1256872b7d4dc5bf5bb10 Mon Sep 17 00:00:00 2001 From: Mateus Oliveira Date: Thu, 29 Feb 2024 16:20:31 -0300 Subject: [PATCH 1/2] feat: add editorconfig Signed-off-by: Mateus Oliveira --- .editorconfig | 20 ++++++++++++++++++++ Makefile | 21 ++++++++++++++++++++- README.md | 14 +++++++------- hack/boilerplate.go.txt | 2 +- 4 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8c680d3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# https://EditorConfig.org + +root = true + +[*] +indent_size = 4 +indent_style = space +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[Makefile] +indent_style = unset + +[{*.{yaml,yml},PROJECT}] +indent_size = 2 + +[{*.go,go.mod,*.md,LICENSE}] +indent_size = unset diff --git a/Makefile b/Makefile index ce7b4e0..47bd400 100644 --- a/Makefile +++ b/Makefile @@ -205,7 +205,7 @@ endef ##@ oadp-nac specifics .PHONY: ci -ci: simulation-test lint docker-build hadolint check-generate check-manifests ## Run all checks run by the project continuous integration (CI) locally. +ci: simulation-test lint docker-build hadolint check-generate check-manifests ec ## Run all checks run by the project continuous integration (CI) locally. .PHONY: simulation-test simulation-test: envtest ## Run unit and integration tests. @@ -222,3 +222,22 @@ check-generate: generate ## Check if 'make generate' was run. .PHONY: check-manifests check-manifests: manifests ## Check if 'make manifests' was run. test -z "$(shell git status --short)" || (echo "run 'make manifests' to generate code" && exit 1) + +EC ?= $(LOCALBIN)/ec-$(EC_VERSION) +EC_VERSION ?= 2.8.0 + +.PHONY: editorconfig +editorconfig: $(LOCALBIN) ## Download editorconfig locally if necessary. + @[ -f $(EC) ] || { \ + set -e ;\ + ec_binary=ec-$(shell go env GOOS)-$(shell go env GOARCH) ;\ + ec_tar=$(LOCALBIN)/$${ec_binary}.tar.gz ;\ + curl -sSLo $${ec_tar} https://github.com/editorconfig-checker/editorconfig-checker/releases/download/$(EC_VERSION)/$${ec_binary}.tar.gz ;\ + tar xzf $${ec_tar} ;\ + rm -rf $${ec_tar} ;\ + mv $(LOCALBIN)/$${ec_binary} $(EC) ;\ + } + +.PHONY: ec +ec: editorconfig ## Run file formatter checks against all project's files. + $(EC) diff --git a/README.md b/README.md index d7f50a4..6aa28eb 100644 --- a/README.md +++ b/README.md @@ -38,12 +38,12 @@ metadata: name: cluster spec: identityProviders: - - name: oadp_nac_test_provider - mappingMethod: claim + - name: oadp_nac_test_provider + mappingMethod: claim type: HTPasswd htpasswd: fileData: - name: htpass-secret + name: htpass-secret EOF ``` **Apply the OAuth file to the cluster:** @@ -60,7 +60,7 @@ $ oc apply -f config/rbac/nonadminbackup_editor_role.yaml **Create Role Binding for our test user within nac-testing namespace:** **NOTE:** There could be also a ClusterRoleBinding for the nacuser or one of the groups -to which nacuser belongs to easy administrative tasks and allow use of NAC for wider audience. Please see next paragraph. +to which nacuser belongs to easy administrative tasks and allow use of NAC for wider audience. Please see next paragraph. ```sh $ cat > nacuser-rolebinding.yaml < **NOTE**: If you encounter RBAC errors, you may need to grant yourself cluster-admin +> **NOTE**: If you encounter RBAC errors, you may need to grant yourself cluster-admin privileges or be logged in as admin. **Create instances of your solution** diff --git a/hack/boilerplate.go.txt b/hack/boilerplate.go.txt index ff72ff2..06a460e 100644 --- a/hack/boilerplate.go.txt +++ b/hack/boilerplate.go.txt @@ -12,4 +12,4 @@ 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. -*/ \ No newline at end of file +*/ From 46d41c0a4e37ed5f7d4f4299d38f22a7934cb5ad Mon Sep 17 00:00:00 2001 From: Mateus Oliveira Date: Fri, 1 Mar 2024 14:07:59 -0300 Subject: [PATCH 2/2] fixup! feat: add editorconfig Signed-off-by: Mateus Oliveira --- .editorconfig | 4 ++-- .github/workflows/ci.yml | 3 ++- Makefile | 30 +++++++++++++++--------------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.editorconfig b/.editorconfig index 8c680d3..c95923f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,11 +10,11 @@ charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true -[Makefile] +[{*.go,go.mod,Makefile}] indent_style = unset [{*.{yaml,yml},PROJECT}] indent_size = 2 -[{*.go,go.mod,*.md,LICENSE}] +[{*.md,LICENSE}] indent_size = unset diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 617a0d1..1c6955f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,4 +62,5 @@ jobs: - name: Check if 'make manifests' was run run: make check-manifests - # TODO editorconfig + - name: Check all files format + run: make ec diff --git a/Makefile b/Makefile index 47bd400..356b022 100644 --- a/Makefile +++ b/Makefile @@ -204,6 +204,21 @@ endef ##@ oadp-nac specifics +EC ?= $(LOCALBIN)/ec-$(EC_VERSION) +EC_VERSION ?= 2.8.0 + +.PHONY: editorconfig +editorconfig: $(LOCALBIN) ## Download editorconfig locally if necessary. + @[ -f $(EC) ] || { \ + set -e ;\ + ec_binary=ec-$(shell go env GOOS)-$(shell go env GOARCH) ;\ + ec_tar=$(LOCALBIN)/$${ec_binary}.tar.gz ;\ + curl -sSLo $${ec_tar} https://github.com/editorconfig-checker/editorconfig-checker/releases/download/$(EC_VERSION)/$${ec_binary}.tar.gz ;\ + tar xzf $${ec_tar} ;\ + rm -rf $${ec_tar} ;\ + mv $(LOCALBIN)/$${ec_binary} $(EC) ;\ + } + .PHONY: ci ci: simulation-test lint docker-build hadolint check-generate check-manifests ec ## Run all checks run by the project continuous integration (CI) locally. @@ -223,21 +238,6 @@ check-generate: generate ## Check if 'make generate' was run. check-manifests: manifests ## Check if 'make manifests' was run. test -z "$(shell git status --short)" || (echo "run 'make manifests' to generate code" && exit 1) -EC ?= $(LOCALBIN)/ec-$(EC_VERSION) -EC_VERSION ?= 2.8.0 - -.PHONY: editorconfig -editorconfig: $(LOCALBIN) ## Download editorconfig locally if necessary. - @[ -f $(EC) ] || { \ - set -e ;\ - ec_binary=ec-$(shell go env GOOS)-$(shell go env GOARCH) ;\ - ec_tar=$(LOCALBIN)/$${ec_binary}.tar.gz ;\ - curl -sSLo $${ec_tar} https://github.com/editorconfig-checker/editorconfig-checker/releases/download/$(EC_VERSION)/$${ec_binary}.tar.gz ;\ - tar xzf $${ec_tar} ;\ - rm -rf $${ec_tar} ;\ - mv $(LOCALBIN)/$${ec_binary} $(EC) ;\ - } - .PHONY: ec ec: editorconfig ## Run file formatter checks against all project's files. $(EC)