Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: connection config.toml in connection details #100

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions internal/controller/accesskey/accesskey.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package accesskey

import (
"context"
"fmt"

"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -174,9 +175,7 @@ func (c *external) Observe(ctx context.Context, mg resource.Managed) (managed.Ex

// Return any details that may be required to connect to the external
// resource. These will be stored as the connection secret.
ConnectionDetails: managed.ConnectionDetails{
"secretKey": []byte(creds.SecretKey),
},
ConnectionDetails: connectionDetails(creds),
}, nil
}

Expand All @@ -201,9 +200,7 @@ func (c *external) Create(ctx context.Context, mg resource.Managed) (managed.Ext
return managed.ExternalCreation{
// Optionally return any details that may be required to connect to the
// external resource. These will be stored as the connection secret.
ConnectionDetails: managed.ConnectionDetails{
"secretKey": []byte(creds.SecretKey),
},
ConnectionDetails: connectionDetails(creds),
}, nil
}

Expand Down Expand Up @@ -241,3 +238,16 @@ func (c *external) Delete(ctx context.Context, mg resource.Managed) (managed.Ext
func (c *external) Disconnect(ctx context.Context) error {
return nil
}

func connectionDetails(creds *cloudian.SecurityInfo) managed.ConnectionDetails {
return managed.ConnectionDetails{
"secretKey": []byte(creds.SecretKey),
"config.toml": []byte(fmt.Sprintf(
`[default]
erikgb marked this conversation as resolved.
Show resolved Hide resolved
aws_access_key_id = %s
aws_secret_access_key = %s`,
creds.AccessKey,
creds.SecretKey,
)),
}
}
Loading