Skip to content

Commit

Permalink
Unique pull secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
dzsak committed Mar 25, 2024
1 parent b45de7a commit 250003f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
3 changes: 1 addition & 2 deletions pkg/dashboard/worker/gitops.go
Original file line number Diff line number Diff line change
Expand Up @@ -1269,12 +1269,11 @@ func imagepullSecretTemplate(
encryptedConfigString = encryptedConfig.(string)
}

secretName := fmt.Sprintf("%s-pullsecret", strings.ToLower(registryString))
return sync.GenerateImagePullSecret(
manifest.Env,
manifest.App,
manifest.Namespace,
secretName,
strings.ToLower(registryString),
encryptedConfigString,
repoPerEnv,
)
Expand Down
5 changes: 3 additions & 2 deletions pkg/gitops/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func GenerateKustomizationForApp(
}

func GenerateImagePullSecret(
env, app, namespace, name string,
env, app, namespace, registry string,
encryptedDockerconfigjson string,
singleEnv bool,
) (*manifestgen.Manifest, error) {
Expand All @@ -273,13 +273,14 @@ func GenerateImagePullSecret(
secretPath = app
}

secretName := fmt.Sprintf("%s-%s-pullsecret", app, registry)
secret := ssv1alpha1.SealedSecret{
TypeMeta: metav1.TypeMeta{
Kind: "SealedSecret",
APIVersion: "bitnami.com/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Name: secretName,
Namespace: namespace,
Annotations: map[string]string{
"sealedsecrets.bitnami.com/cluster-wide": "true",
Expand Down
8 changes: 7 additions & 1 deletion web/dashboard/src/views/envConfig/envConfig.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,13 @@ class EnvConfig extends Component {
// };

imageWidget(props) {
return <ImageWidget {...props} setImagePullSecret={this.setImagePullSecret} registry={filterRegistry(this.state.stackConfig, this.state.stackDefinition)} />
return (
<ImageWidget
{...props}
app={this.state.configFile.app}
setImagePullSecret={this.setImagePullSecret}
registry={filterRegistry(this.state.stackConfig, this.state.stackDefinition)}
/>)
}

render() {
Expand Down
6 changes: 3 additions & 3 deletions web/dashboard/src/views/envConfig/imageWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ class ImageWidget extends Component {

selectOnChange(name) {
return (event) => {
const { registry } = this.props;
const { registry, app } = this.props;
const login = registry[event.target.value].login ?? "your-company"

switch (event.target.value) {
case 'dockerhubRegistry':
this.setState({ repository: `${login}/{{ .APP }}` })
this.props.setImagePullSecret("dockerhubregistry-pullsecret")
this.props.setImagePullSecret(`${app}-dockerhubregistry-pullsecret`)
break;
case 'ghcrRegistry':
this.setState({ repository: `ghcr.io/${login}/{{ .APP }}` })
this.props.setImagePullSecret("ghcrregistry-pullsecret")
this.props.setImagePullSecret(`${app}-ghcrregistry-pullsecret`)
break;
default:
this.setState({ repository: "127.0.0.1:32447/{{ .APP }}" })
Expand Down

0 comments on commit 250003f

Please sign in to comment.