diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c95923f --- /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 + +[{*.go,go.mod,Makefile}] +indent_style = unset + +[{*.{yaml,yml},PROJECT}] +indent_size = 2 + +[{*.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 ce7b4e0..356b022 100644 --- a/Makefile +++ b/Makefile @@ -204,8 +204,23 @@ 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 ## 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 +237,7 @@ 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) + +.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 +*/