Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/notification-basic-e2e' int…
Browse files Browse the repository at this point in the history
…o feat/notification-basic-e2e
  • Loading branch information
pasha-codefresh committed Oct 1, 2024
2 parents 85d73be + 5521d73 commit c6f44ef
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/image-reuse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:

- name: Build and push container image
id: image
uses: docker/build-push-action@32945a339266b759abcbdc89316275140b0fc960 #v6.8.0
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 #v6.9.0
with:
context: .
platforms: ${{ inputs.platforms }}
Expand Down
2 changes: 1 addition & 1 deletion applicationset/generators/pull_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (g *PullRequestGenerator) selectServiceProvider(ctx context.Context, genera
if err != nil {
return nil, fmt.Errorf("error fetching Secret Bearer token: %w", err)
}
return pullrequest.NewBitbucketServiceBearerToken(ctx, providerConfig.API, appToken, providerConfig.Project, providerConfig.Repo, g.scmRootCAPath, providerConfig.Insecure, caCerts)
return pullrequest.NewBitbucketServiceBearerToken(ctx, appToken, providerConfig.API, providerConfig.Project, providerConfig.Repo, g.scmRootCAPath, providerConfig.Insecure, caCerts)
} else if providerConfig.BasicAuth != nil {
password, err := utils.GetSecretRef(ctx, g.client, providerConfig.BasicAuth.PasswordRef, applicationSetInfo.Namespace)
if err != nil {
Expand Down
23 changes: 14 additions & 9 deletions cmd/argocd/commands/admin/redis_initial_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@ func NewRedisInitialPasswordCommand() *cobra.Command {
namespace, _, err := clientConfig.Namespace()
errors.CheckError(err)

redisInitialPasswordSecretName := common.DefaultRedisInitialPasswordSecretName
redisInitialPasswordKey := common.DefaultRedisInitialPasswordKey
fmt.Printf("Checking for initial Redis password in secret %s/%s at key %s. \n", namespace, redisInitialPasswordSecretName, redisInitialPasswordKey)
// redisInitialCredentials is the kubernetes secret containing
// the redis password
redisInitialCredentials := common.RedisInitialCredentials

// redisInitialCredentialsKey is the key in the redisInitialCredentials
// secret which maps to the redis password
redisInitialCredentialsKey := common.RedisInitialCredentialsKey
fmt.Printf("Checking for initial Redis password in secret %s/%s at key %s. \n", namespace, redisInitialCredentials, redisInitialCredentialsKey)

config, err := clientConfig.ClientConfig()
errors.CheckError(err)
Expand All @@ -59,11 +64,11 @@ func NewRedisInitialPasswordCommand() *cobra.Command {
errors.CheckError(err)

data := map[string][]byte{
redisInitialPasswordKey: []byte(randomPassword),
redisInitialCredentialsKey: []byte(randomPassword),
}
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: redisInitialPasswordSecretName,
Name: redisInitialCredentials,
Namespace: namespace,
},
Data: data,
Expand All @@ -74,14 +79,14 @@ func NewRedisInitialPasswordCommand() *cobra.Command {
errors.CheckError(err)
}

fmt.Println("Argo CD Redis secret state confirmed: secret name argocd-redis.")
secret, err = kubeClientset.CoreV1().Secrets(namespace).Get(context.Background(), redisInitialPasswordSecretName, v1.GetOptions{})
fmt.Printf("Argo CD Redis secret state confirmed: secret name %s.\n", redisInitialCredentials)
secret, err = kubeClientset.CoreV1().Secrets(namespace).Get(context.Background(), redisInitialCredentials, v1.GetOptions{})
errors.CheckError(err)

if _, ok := secret.Data[redisInitialPasswordKey]; ok {
if _, ok := secret.Data[redisInitialCredentialsKey]; ok {
fmt.Println("Password secret is configured properly.")
} else {
err := fmt.Errorf("key %s doesn't exist in secret %s. \n", redisInitialPasswordKey, redisInitialPasswordSecretName)
err := fmt.Errorf("key %s doesn't exist in secret %s. \n", redisInitialCredentialsKey, redisInitialCredentials)
errors.CheckError(err)
}
},
Expand Down
23 changes: 14 additions & 9 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,10 @@ const (
// Constants used by util/clusterauth package
const (
ClusterAuthRequestTimeout = 10 * time.Second
BearerTokenTimeout = 30 * time.Second
)

const (
BearerTokenTimeout = 30 * time.Second
)

const (
Expand Down Expand Up @@ -425,8 +428,10 @@ var PermissionDeniedAPIError = status.Error(codes.PermissionDenied, "permission

// Redis password consts
const (
DefaultRedisInitialPasswordSecretName = "argocd-redis"
DefaultRedisInitialPasswordKey = "auth"
// RedisInitialCredentials is the name for the argocd kubernetes secret which will have the redis password
RedisInitialCredentials = "argocd-redis"
// RedisInitialCredentialsKey is the key for the argocd kubernetes secret that maps to the redis password
RedisInitialCredentialsKey = "auth"
)

/*
Expand All @@ -435,17 +440,17 @@ SetOptionalRedisPasswordFromKubeConfig sets the optional Redis password if it ex
We specify kubeClient as kubernetes.Interface to allow for mocking in tests, but this should be treated as a kubernetes.Clientset param.
*/
func SetOptionalRedisPasswordFromKubeConfig(ctx context.Context, kubeClient kubernetes.Interface, namespace string, redisOptions *redis.Options) error {
secret, err := kubeClient.CoreV1().Secrets(namespace).Get(ctx, DefaultRedisInitialPasswordSecretName, v1.GetOptions{})
secret, err := kubeClient.CoreV1().Secrets(namespace).Get(ctx, RedisInitialCredentials, v1.GetOptions{})
if err != nil {
return fmt.Errorf("failed to get secret %s/%s: %w", namespace, DefaultRedisInitialPasswordSecretName, err)
return fmt.Errorf("failed to get secret %s/%s: %w", namespace, RedisInitialCredentials, err)
}
if secret == nil {
return fmt.Errorf("failed to get secret %s/%s: secret is nil", namespace, DefaultRedisInitialPasswordSecretName)
return fmt.Errorf("failed to get secret %s/%s: secret is nil", namespace, RedisInitialCredentials)
}
_, ok := secret.Data[DefaultRedisInitialPasswordKey]
_, ok := secret.Data[RedisInitialCredentialsKey]
if !ok {
return fmt.Errorf("secret %s/%s does not contain key %s", namespace, DefaultRedisInitialPasswordSecretName, DefaultRedisInitialPasswordKey)
return fmt.Errorf("secret %s/%s does not contain key %s", namespace, RedisInitialCredentials, RedisInitialCredentialsKey)
}
redisOptions.Password = string(secret.Data[DefaultRedisInitialPasswordKey])
redisOptions.Password = string(secret.Data[RedisInitialCredentialsKey])
return nil
}
10 changes: 5 additions & 5 deletions common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,24 @@ func TestSetOptionalRedisPasswordFromKubeConfig(t *testing.T) {
expectedPassword: "password123",
expectedErr: "",
secret: &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{Name: DefaultRedisInitialPasswordSecretName},
Data: map[string][]byte{DefaultRedisInitialPasswordKey: []byte("password123")},
ObjectMeta: metav1.ObjectMeta{Name: RedisInitialCredentials},
Data: map[string][]byte{RedisInitialCredentialsKey: []byte("password123")},
},
},
{
name: "Secret does not exist",
namespace: "default",
expectedPassword: "",
expectedErr: fmt.Sprintf("failed to get secret default/%s", DefaultRedisInitialPasswordSecretName),
expectedErr: fmt.Sprintf("failed to get secret default/%s", RedisInitialCredentials),
secret: nil,
},
{
name: "Secret exists without correct key",
namespace: "default",
expectedPassword: "",
expectedErr: fmt.Sprintf("secret default/%s does not contain key %s", DefaultRedisInitialPasswordSecretName, DefaultRedisInitialPasswordKey),
expectedErr: fmt.Sprintf("secret default/%s does not contain key %s", RedisInitialCredentials, RedisInitialCredentialsKey),
secret: &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{Name: DefaultRedisInitialPasswordSecretName},
ObjectMeta: metav1.ObjectMeta{Name: RedisInitialCredentials},
Data: map[string][]byte{},
},
},
Expand Down
13 changes: 6 additions & 7 deletions ui/src/app/settings/components/repo-details/repo-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export const RepoDetails = (props: {repo: models.Repository; save?: (params: New
title: 'Repository URL',
view: repository.repo
},
{
title: 'Name',
view: repository.name || '',
edit: (formApi: FormApi) => <FormField formApi={formApi} field='name' component={Text} />
},
{
title: 'Username (optional)',
view: repository.username || '',
Expand All @@ -29,13 +34,6 @@ export const RepoDetails = (props: {repo: models.Repository; save?: (params: New
}
];

if (repository.name) {
items.splice(1, 0, {
title: 'NAME',
view: repository.name
});
}

if (repository.project) {
items.splice(repository.name ? 2 : 1, 0, {
title: 'Project',
Expand Down Expand Up @@ -86,6 +84,7 @@ export const RepoDetails = (props: {repo: models.Repository; save?: (params: New
})}
save={async input => {
const params: NewHTTPSRepoParams = {...newRepo};
params.name = input.name || '';
params.username = input.username || '';
params.password = input.password || '';
save(params);
Expand Down
9 changes: 7 additions & 2 deletions ui/src/app/settings/components/repos-list/repos-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,14 @@ export class ReposList extends React.Component<
<div className='argo-form-row'>
<FormField formApi={formApi} label='Type' field='type' component={FormSelect} componentProps={{options: ['git', 'helm']}} />
</div>
{formApi.getFormState().values.type === 'helm' && (
{(formApi.getFormState().values.type === 'helm' || formApi.getFormState().values.type === 'git') && (
<div className='argo-form-row'>
<FormField formApi={formApi} label='Name' field='name' component={Text} />
<FormField
formApi={formApi}
label={`Name ${formApi.getFormState().values.type === 'git' ? '(optional)' : ''}`}
field='name'
component={Text}
/>
</div>
)}
<div className='argo-form-row'>
Expand Down

0 comments on commit c6f44ef

Please sign in to comment.