Skip to content

Commit

Permalink
Merge branch 'master' into chore/mpatch-tests-skip
Browse files Browse the repository at this point in the history
  • Loading branch information
crenshaw-dev committed Apr 5, 2022
2 parents 1b3ae50 + b0cd653 commit 851ba53
Show file tree
Hide file tree
Showing 19 changed files with 422 additions and 289 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/ci-build.yaml
Expand Up @@ -60,11 +60,15 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Golang
uses: actions/setup-go@v1
with:
go-version: ${{ env.GOLANG_VERSION }}
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: v1.38.0
args: --timeout 10m --exclude SA5011
version: v1.45.2
args: --timeout 10m --exclude SA5011 --verbose

test-go:
name: Run unit tests for Go packages
Expand Down
22 changes: 0 additions & 22 deletions .golangci.yml

This file was deleted.

40 changes: 31 additions & 9 deletions applicationset/services/scm_provider/gitlab.go
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
pathpkg "path"

gitlab "github.com/xanzy/go-gitlab"
)
Expand Down Expand Up @@ -105,17 +106,38 @@ func (g *GitlabProvider) RepoHasPath(_ context.Context, repo *Repository, path s
if err != nil {
return false, err
}
_, resp, err := g.client.Repositories.ListTree(p.ID, &gitlab.ListTreeOptions{
Path: &path,
Ref: &repo.Branch,
})
if err != nil {
return false, err
directories := []string{
path,
pathpkg.Dir(path),
}
if resp.TotalItems == 0 {
return false, nil
for _, directory := range directories {
options := gitlab.ListTreeOptions{
Path: &directory,
Ref: &repo.Branch,
}
for {
treeNode, resp, err := g.client.Repositories.ListTree(p.ID, &options)
if err != nil {
return false, err
}
if path == directory {
if resp.TotalItems > 0 {
return true, nil
}
}
for i := range treeNode {
if treeNode[i].Path == path {
return true, nil
}
}
if resp.NextPage == 0 {
// no future pages
break
}
options.Page = resp.NextPage
}
}
return true, nil
return false, nil
}

func (g *GitlabProvider) listBranches(_ context.Context, repo *Repository) ([]gitlab.Branch, error) {
Expand Down
39 changes: 33 additions & 6 deletions applicationset/services/scm_provider/gitlab_test.go
Expand Up @@ -79,11 +79,38 @@ func TestGitlabHasPath(t *testing.T) {
Repository: "argocd",
Branch: "master",
}
ok, err := host.RepoHasPath(context.Background(), repo, "argocd")
assert.Nil(t, err)
assert.True(t, ok)

ok, err = host.RepoHasPath(context.Background(), repo, "notathing")
assert.Nil(t, err)
assert.False(t, ok)
cases := []struct {
name, path string
exists bool
}{
{
name: "directory exists",
path: "argocd",
exists: true,
},
{
name: "file exists",
path: "argocd/install.yaml",
exists: true,
},
{
name: "directory does not exist",
path: "notathing",
exists: false,
},
{
name: "file does not exist",
path: "argocd/notathing.yaml",
exists: false,
},
}

for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
ok, err := host.RepoHasPath(context.Background(), repo, c.path)
assert.Nil(t, err)
assert.Equal(t, c.exists, ok)
})
}
}
2 changes: 1 addition & 1 deletion hack/installers/install-lint-tools.sh
@@ -1,4 +1,4 @@
#!/bin/bash
set -eux -o pipefail

GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.38.0
GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2
Expand Up @@ -151,8 +151,8 @@ export const ApplicationCreatePanel = (props: {
)) || (
<Form
validateError={(a: models.Application) => ({
'metadata.name': !a.metadata.name && 'Application name is required',
'spec.project': !a.spec.project && 'Project name is required',
'metadata.name': !a.metadata.name && 'Application Name is required',
'spec.project': !a.spec.project && 'Project Name is required',
'spec.source.repoURL': !a.spec.source.repoURL && 'Repository URL is required',
'spec.source.targetRevision': !a.spec.source.targetRevision && a.spec.source.hasOwnProperty('chart') && 'Version is required',
'spec.source.path': !a.spec.source.path && !a.spec.source.chart && 'Path is required',
Expand Down Expand Up @@ -204,7 +204,7 @@ export const ApplicationCreatePanel = (props: {
<div className='argo-form-row'>
<FormField
formApi={api}
label='Project'
label='Project Name'
qeId='application-create-field-project'
field='spec.project'
component={AutocompleteField}
Expand Down
Expand Up @@ -27,23 +27,23 @@ export const ApplicationsSummary = ({applications}: {applications: models.Applic

const attributes = [
{
title: 'APPLICATIONS:',
title: 'APPLICATIONS',
value: applications.length
},
{
title: 'SYNCED:',
title: 'SYNCED',
value: applications.filter(app => app.status.sync.status === 'Synced').length
},
{
title: 'HEALTHY:',
title: 'HEALTHY',
value: applications.filter(app => app.status.health.status === 'Healthy').length
},
{
title: 'CLUSTERS:',
title: 'CLUSTERS',
value: new Set(applications.map(app => app.spec.destination.server)).size
},
{
title: 'NAMESPACES:',
title: 'NAMESPACES',
value: new Set(applications.map(app => app.spec.destination.namespace)).size
}
];
Expand Down
111 changes: 54 additions & 57 deletions ui/src/app/settings/components/certs-list/certs-list.tsx
Expand Up @@ -43,10 +43,12 @@ export class CertsList extends React.Component<RouteComponentProps<any>> {
items: [
{
title: 'Add TLS certificate',
iconClassName: 'fa fa-plus',
action: () => (this.showAddTLSCertificate = true)
},
{
title: 'Add SSH known hosts',
iconClassName: 'fa fa-plus',
action: () => (this.showAddSSHKnownHosts = true)
}
]
Expand Down Expand Up @@ -123,33 +125,31 @@ export class CertsList extends React.Component<RouteComponentProps<any>> {
</button>
</div>
}>
<div className='argo-container'>
<div className='certs-list white-box'>
<h4>Create TLS repository certificate</h4>
<Form
onSubmit={params => this.addTLSCertificate(params as NewTLSCertParams)}
getApi={api => (this.formApiTLS = api)}
preSubmit={(params: NewTLSCertParams) => ({
serverName: params.serverName,
certData: btoa(params.certData)
})}
validateError={(params: NewTLSCertParams) => ({
serverName: !params.serverName && 'Repository server name is required',
certData: !params.certData && 'Certificate data is required'
})}>
{formApiTLS => (
<form onSubmit={formApiTLS.submitForm} role='form' className='certs-list width-control' encType='multipart/form-data'>
<div className='argo-form-row'>
<FormField formApi={formApiTLS} label='Repository server name' field='serverName' component={Text} />
</div>
<div className='argo-form-row'>
<FormField formApi={formApiTLS} label='TLS certificate (PEM format)' field='certData' component={TextArea} />
</div>
</form>
)}
</Form>
</div>
</div>
<Form
onSubmit={params => this.addTLSCertificate(params as NewTLSCertParams)}
getApi={api => (this.formApiTLS = api)}
preSubmit={(params: NewTLSCertParams) => ({
serverName: params.serverName,
certData: btoa(params.certData)
})}
validateError={(params: NewTLSCertParams) => ({
serverName: !params.serverName && 'Repository Server Name is required',
certData: !params.certData && 'TLS Certificate is required'
})}>
{formApiTLS => (
<form onSubmit={formApiTLS.submitForm} role='form' className='certs-list width-control' encType='multipart/form-data'>
<div className='white-box'>
<p>CREATE TLS REPOSITORY CERTIFICATE</p>
<div className='argo-form-row'>
<FormField formApi={formApiTLS} label='Repository Server Name' field='serverName' component={Text} />
</div>
<div className='argo-form-row'>
<FormField formApi={formApiTLS} label='TLS Certificate (PEM format)' field='certData' component={TextArea} />
</div>
</div>
</form>
)}
</Form>
</SlidingPanel>
<SlidingPanel
isShown={this.showAddSSHKnownHosts}
Expand All @@ -164,36 +164,33 @@ export class CertsList extends React.Component<RouteComponentProps<any>> {
</button>
</div>
}>
<div className='argo-container'>
<div className='certs-list white-box'>
<h4>Create SSH known host entries</h4>

<p>
Paste SSH known hosts data in the text area below, one entry per line. You can use output from <code>ssh-keyscan</code> or the contents on an{' '}
<code>ssh_known_hosts</code> file verbatim. Lines starting with <code>#</code> will be treated as comments and ignored.
</p>
<p>
<strong>Make sure there are no linebreaks in the keys.</strong>
</p>
<Form
onSubmit={params => this.addSSHKnownHosts(params as NewSSHKnownHostParams)}
getApi={api => (this.formApiSSH = api)}
preSubmit={(params: NewSSHKnownHostParams) => ({
certData: btoa(params.certData)
})}
validateError={(params: NewSSHKnownHostParams) => ({
certData: !params.certData && 'SSH known hosts data is required'
})}>
{formApiSSH => (
<form onSubmit={formApiSSH.submitForm} role='form' className='certs-list width-control' encType='multipart/form-data'>
<div className='argo-form-row'>
<FormField formApi={formApiSSH} label='SSH known hosts data' field='certData' component={TextArea} />
</div>
</form>
)}
</Form>
</div>
</div>
<Form
onSubmit={params => this.addSSHKnownHosts(params as NewSSHKnownHostParams)}
getApi={api => (this.formApiSSH = api)}
preSubmit={(params: NewSSHKnownHostParams) => ({
certData: btoa(params.certData)
})}
validateError={(params: NewSSHKnownHostParams) => ({
certData: !params.certData && 'SSH known hosts data is required'
})}>
{formApiSSH => (
<form onSubmit={formApiSSH.submitForm} role='form' className='certs-list width-control' encType='multipart/form-data'>
<div className='white-box'>
<p>CREATE SSH KNOWN HOST ENTRIES</p>
<p>
Paste SSH known hosts data in the text area below, one entry per line. You can use output from <code>ssh-keyscan</code> or the contents on
an <code>ssh_known_hosts</code> file verbatim. Lines starting with <code>#</code> will be treated as comments and ignored.
</p>
<p>
<strong>Make sure there are no linebreaks in the keys.</strong>
</p>
<div className='argo-form-row'>
<FormField formApi={formApiSSH} label='SSH known hosts data' field='certData' component={TextArea} />
</div>
</div>
</form>
)}
</Form>
</SlidingPanel>
</Page>
);
Expand Down
11 changes: 7 additions & 4 deletions ui/src/app/settings/components/gpgkeys-list/gpgkeys-list.tsx
Expand Up @@ -36,6 +36,7 @@ export class GpgKeysList extends React.Component<RouteComponentProps<any>> {
items: [
{
title: 'Add GnuPG key',
iconClassName: 'fa fa-plus',
action: () => (this.showAddGnuPGKey = true)
}
]
Expand Down Expand Up @@ -107,20 +108,22 @@ export class GpgKeysList extends React.Component<RouteComponentProps<any>> {
</button>
</div>
}>
<h4>Add GnuPG public key</h4>
<Form
onSubmit={params => this.addGnuPGPublicKey({keyData: params.keyData})}
getApi={api => (this.formApi = api)}
preSubmit={(params: NewGnuPGPublicKeyParams) => ({
keyData: params.keyData
})}
validateError={(params: NewGnuPGPublicKeyParams) => ({
keyData: !params.keyData && 'Key data is required'
keyData: !params.keyData && 'GnuPG public key data is required'
})}>
{formApi => (
<form onSubmit={formApi.submitForm} role='form' className='gpgkeys-list width-control' encType='multipart/form-data'>
<div className='argo-form-row'>
<FormField formApi={formApi} label='GnuPG public key data (ASCII-armored)' field='keyData' component={TextArea} />
<div className='white-box'>
<p>ADD GnuPG PUBLIC KEY</p>
<div className='argo-form-row'>
<FormField formApi={formApi} label='GnuPG public key data (ASCII-armored)' field='keyData' component={TextArea} />
</div>
</div>
</form>
)}
Expand Down

0 comments on commit 851ba53

Please sign in to comment.