diff --git a/.eslintrc.yml b/.eslintrc.yml index cc4e73a73..7a34eedcb 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -99,3 +99,7 @@ overrides: 'jest/globals': true rules: 'react/jsx-no-constructed-context-values': off + - files: + - app/**/*.stories.* + rules: + 'no-alert': off diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 000000000..7d15d6796 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,4 @@ +# prettier +cf5056d9c03b62d91a25c3b9127caac838695f98 + +# prettier v2 (put here after fix/EE-2344/fix-eslint-issues is merged) \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..926c760aa --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,41 @@ +name: Lint + +on: + push: + branches: + - master + - develop + - release/* + pull_request: + branches: + - master + - develop + - release/* + +jobs: + run-linters: + name: Run linters + runs-on: ubuntu-latest + + steps: + - name: Check out Git repository + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v1 + with: + node-version: 12 + + # ESLint and Prettier must be in `package.json` + - name: Install Node.js dependencies + run: yarn + + - name: Run linters + uses: wearerequired/lint-action@v1 + with: + eslint: true + eslint_extensions: ts,tsx,js,jsx + prettier: true + prettier_dir: app/ + gofmt: true + gofmt_dir: api/ diff --git a/.github/workflows/test-client.yaml b/.github/workflows/test-client.yaml new file mode 100644 index 000000000..256849b43 --- /dev/null +++ b/.github/workflows/test-client.yaml @@ -0,0 +1,11 @@ +name: Test Frontend +on: push +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install modules + run: yarn + - name: Run tests + run: yarn test:client diff --git a/.prettierrc b/.prettierrc index 184ed56cb..a9d2ada8a 100644 --- a/.prettierrc +++ b/.prettierrc @@ -4,21 +4,16 @@ "htmlWhitespaceSensitivity": "strict", "overrides": [ { - "files": [ - "*.html" - ], + "files": ["*.html"], "options": { "parser": "angular" } }, { - "files": [ - "*.{j,t}sx", - "*.ts" - ], + "files": ["*.{j,t}sx", "*.ts"], "options": { "printWidth": 80 } } ] -} \ No newline at end of file +} diff --git a/.vscode.example/settings.json b/.vscode.example/settings.json index 64be114a1..02a896c80 100644 --- a/.vscode.example/settings.json +++ b/.vscode.example/settings.json @@ -1,4 +1,5 @@ { "go.lintTool": "golangci-lint", - "go.lintFlags": ["--fast", "-E", "exportloopref"] + "go.lintFlags": ["--fast", "-E", "exportloopref"], + "gitlens.advanced.blame.customArguments": ["–ignore-revs-file", ".git-blame-ignore-revs"] } diff --git a/api/datastore/init.go b/api/datastore/init.go index a92abe3da..d46d76297 100644 --- a/api/datastore/init.go +++ b/api/datastore/init.go @@ -34,10 +34,10 @@ func (store *Store) Init() error { AutoCreateUsers: true, TLSConfig: portainer.TLSConfiguration{}, SearchSettings: []portainer.LDAPSearchSettings{ - portainer.LDAPSearchSettings{}, + {}, }, GroupSearchSettings: []portainer.LDAPGroupSearchSettings{ - portainer.LDAPGroupSearchSettings{}, + {}, }, }, OAuthSettings: portainer.OAuthSettings{}, diff --git a/api/docker/client.go b/api/docker/client.go index b80c772da..eac3b238c 100644 --- a/api/docker/client.go +++ b/api/docker/client.go @@ -95,7 +95,7 @@ func createEdgeClient(endpoint *portainer.Endpoint, signatureService portainer.D if err != nil { return nil, err } - + endpointURL := fmt.Sprintf("http://127.0.0.1:%d", tunnel.Port) return client.NewClientWithOpts( diff --git a/api/exec/common.go b/api/exec/common.go index abae6dac7..97a10f432 100644 --- a/api/exec/common.go +++ b/api/exec/common.go @@ -33,7 +33,7 @@ func (s StringSet) List() []string { list := make([]string, s.Len()) i := 0 - for k, _ := range s { + for k := range s { list[i] = k i++ } diff --git a/api/http/handler/endpointproxy/proxy_docker.go b/api/http/handler/endpointproxy/proxy_docker.go index d84588b65..96a539ddb 100644 --- a/api/http/handler/endpointproxy/proxy_docker.go +++ b/api/http/handler/endpointproxy/proxy_docker.go @@ -4,9 +4,9 @@ import ( "errors" httperror "github.com/portainer/libhttp/error" "github.com/portainer/libhttp/request" + portainer "github.com/portainer/portainer/api" "strconv" "strings" - portainer "github.com/portainer/portainer/api" "net/http" ) diff --git a/api/http/handler/registries/registry_configure.go b/api/http/handler/registries/registry_configure.go index 146d425b0..0c56e267d 100644 --- a/api/http/handler/registries/registry_configure.go +++ b/api/http/handler/registries/registry_configure.go @@ -21,7 +21,7 @@ type registryConfigurePayload struct { // Password used to authenticate against this registry. required when Authentication is true Password string `example:"registry_password"` // ECR region - Region string + Region string // Use TLS TLS bool `example:"true"` // Skip the verification of the server TLS certificate diff --git a/api/http/handler/registries/registry_update.go b/api/http/handler/registries/registry_update.go index 57075880c..cf0a6a51a 100644 --- a/api/http/handler/registries/registry_update.go +++ b/api/http/handler/registries/registry_update.go @@ -25,13 +25,13 @@ type registryUpdatePayload struct { // Username used to authenticate against this registry. Required when Authentication is true Username *string `example:"registry_user"` // Password used to authenticate against this registry. required when Authentication is true - Password *string `example:"registry_password"` + Password *string `example:"registry_password"` // Quay data - Quay *portainer.QuayRegistryData + Quay *portainer.QuayRegistryData // Registry access control RegistryAccesses *portainer.RegistryAccesses `json:",omitempty"` // ECR data - Ecr *portainer.EcrData `json:",omitempty"` + Ecr *portainer.EcrData `json:",omitempty"` } func (payload *registryUpdatePayload) Validate(r *http.Request) error { diff --git a/api/http/handler/webhooks/webhook_create.go b/api/http/handler/webhooks/webhook_create.go index 077f159d7..78326b720 100644 --- a/api/http/handler/webhooks/webhook_create.go +++ b/api/http/handler/webhooks/webhook_create.go @@ -17,7 +17,7 @@ import ( type webhookCreatePayload struct { ResourceID string EndpointID int - RegistryID portainer.RegistryID + RegistryID portainer.RegistryID WebhookType int } diff --git a/api/http/handler/webhooks/webhook_execute.go b/api/http/handler/webhooks/webhook_execute.go index e7e9c1394..e312c3b64 100644 --- a/api/http/handler/webhooks/webhook_execute.go +++ b/api/http/handler/webhooks/webhook_execute.go @@ -80,13 +80,13 @@ func (handler *Handler) executeServiceWebhook( } service.Spec.TaskTemplate.ForceUpdate++ - + var imageName = strings.Split(service.Spec.TaskTemplate.ContainerSpec.Image, "@sha")[0] if imageTag != "" { var tagIndex = strings.LastIndex(imageName, ":") if tagIndex == -1 { - tagIndex = len(imageName) + tagIndex = len(imageName) } service.Spec.TaskTemplate.ContainerSpec.Image = imageName[:tagIndex] + ":" + imageTag } else { diff --git a/api/http/proxy/factory/kubernetes/deployments.go b/api/http/proxy/factory/kubernetes/deployments.go index ee8e85e0b..2cd7257d1 100644 --- a/api/http/proxy/factory/kubernetes/deployments.go +++ b/api/http/proxy/factory/kubernetes/deployments.go @@ -12,4 +12,4 @@ func (transport *baseTransport) proxyDeploymentsRequest(request *http.Request, n default: return transport.executeKubernetesRequest(request) } -} \ No newline at end of file +} diff --git a/api/http/proxy/factory/kubernetes/pods.go b/api/http/proxy/factory/kubernetes/pods.go index 743c716b7..9a88508a3 100644 --- a/api/http/proxy/factory/kubernetes/pods.go +++ b/api/http/proxy/factory/kubernetes/pods.go @@ -12,4 +12,4 @@ func (transport *baseTransport) proxyPodsRequest(request *http.Request, namespac default: return transport.executeKubernetesRequest(request) } -} \ No newline at end of file +} diff --git a/api/http/proxy/factory/kubernetes/refresh_registry.go b/api/http/proxy/factory/kubernetes/refresh_registry.go index 7e9025bfb..e58f672ae 100644 --- a/api/http/proxy/factory/kubernetes/refresh_registry.go +++ b/api/http/proxy/factory/kubernetes/refresh_registry.go @@ -14,4 +14,4 @@ func (transport *baseTransport) refreshRegistry(request *http.Request, namespace err = registryutils.RefreshEcrSecret(cli, transport.endpoint, transport.dataStore, namespace) return -} \ No newline at end of file +} diff --git a/api/internal/endpointutils/endpoint_test.go b/api/internal/endpointutils/endpoint_test.go index 8d65552a2..ad6b3c76f 100644 --- a/api/internal/endpointutils/endpoint_test.go +++ b/api/internal/endpointutils/endpoint_test.go @@ -101,4 +101,4 @@ func Test_FilterByExcludeIDs(t *testing.T) { tt.asserts(t, output) }) } -} \ No newline at end of file +} diff --git a/api/kubernetes/cli/client.go b/api/kubernetes/cli/client.go index 88f73e32b..bc3e43c46 100644 --- a/api/kubernetes/cli/client.go +++ b/api/kubernetes/cli/client.go @@ -50,7 +50,7 @@ func (factory *ClientFactory) GetInstanceID() (instanceID string) { } // Remove the cached kube client so a new one can be created - func (factory *ClientFactory) RemoveKubeClient(endpointID portainer.EndpointID) { +func (factory *ClientFactory) RemoveKubeClient(endpointID portainer.EndpointID) { factory.endpointClients.Remove(strconv.Itoa(int(endpointID))) } diff --git a/api/kubernetes/cli/registries.go b/api/kubernetes/cli/registries.go index b8c7e5278..ed6fb736c 100644 --- a/api/kubernetes/cli/registries.go +++ b/api/kubernetes/cli/registries.go @@ -16,8 +16,8 @@ import ( const ( secretDockerConfigKey = ".dockerconfigjson" - labelRegistryType = "io.portainer.kubernetes.registry.type" - annotationRegistryID = "portainer.io/registry.id" + labelRegistryType = "io.portainer.kubernetes.registry.type" + annotationRegistryID = "portainer.io/registry.id" ) type ( diff --git a/app/agent/components/file-uploader/fileUploader.html b/app/agent/components/file-uploader/fileUploader.html index 27b741b0a..aced458fa 100644 --- a/app/agent/components/file-uploader/fileUploader.html +++ b/app/agent/components/file-uploader/fileUploader.html @@ -1,3 +1,3 @@ diff --git a/app/agent/components/files-datatable/filesDatatable.html b/app/agent/components/files-datatable/filesDatatable.html index c29562d61..d4e719d47 100644 --- a/app/agent/components/files-datatable/filesDatatable.html +++ b/app/agent/components/files-datatable/filesDatatable.html @@ -41,9 +41,7 @@ - - Actions - + Actions diff --git a/app/assets/ico/manifest.json b/app/assets/ico/manifest.json index 843e03e83..f70fd66f2 100644 --- a/app/assets/ico/manifest.json +++ b/app/assets/ico/manifest.json @@ -1,18 +1,18 @@ { - "name": "Portainer", - "icons": [ - { - "src": "ico/android-chrome-192x192.png", - "sizes": "192x192", - "type": "image/png" - }, - { - "src": "ico/android-chrome-256x256.png", - "sizes": "256x256", - "type": "image/png" - } - ], - "theme_color": "#ffffff", - "background_color": "#ffffff", - "display": "standalone" -} \ No newline at end of file + "name": "Portainer", + "icons": [ + { + "src": "ico/android-chrome-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "ico/android-chrome-256x256.png", + "sizes": "256x256", + "type": "image/png" + } + ], + "theme_color": "#ffffff", + "background_color": "#ffffff", + "display": "standalone" +} diff --git a/app/azure/components/azure-endpoint-config/azureEndpointConfig.html b/app/azure/components/azure-endpoint-config/azureEndpointConfig.html index efc8bd79f..b6ee79f3d 100644 --- a/app/azure/components/azure-endpoint-config/azureEndpointConfig.html +++ b/app/azure/components/azure-endpoint-config/azureEndpointConfig.html @@ -1,7 +1,5 @@
-
- Azure configuration -
+
Azure configuration
diff --git a/app/azure/components/datatables/containergroups-datatable/containerGroupsDatatable.html b/app/azure/components/datatables/containergroups-datatable/containerGroupsDatatable.html index bea19d1fc..abcc2e92a 100644 --- a/app/azure/components/datatables/containergroups-datatable/containerGroupsDatatable.html +++ b/app/azure/components/datatables/containergroups-datatable/containerGroupsDatatable.html @@ -2,7 +2,7 @@
-
{{ $ctrl.titleText }}
+
{{ $ctrl.titleText }}
- {{ state.formValidationError }} + {{ state.formValidationError }}
diff --git a/app/docker/components/container-capabilities/containerCapabilities.html b/app/docker/components/container-capabilities/containerCapabilities.html index 22d6b9aed..89163c10a 100644 --- a/app/docker/components/container-capabilities/containerCapabilities.html +++ b/app/docker/components/container-capabilities/containerCapabilities.html @@ -1,12 +1,10 @@ - -
- Container capabilities -
+ +
Container capabilities
-
-
{{ $ctrl.titleText }}
+
{{ $ctrl.titleText }}
Settings