-
Notifications
You must be signed in to change notification settings - Fork 107
✨ Add AWS IAM support #677
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -421,6 +421,10 @@ type TestCert struct { | |
Key []byte | ||
} | ||
|
||
// TODO: Remove this struct once we have the function fully implemented for the AWSIRSADriver | ||
type TestIrsaRequest struct { | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might add some TODO or comment here, I am not quite sure why this is added. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are using the struct in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, I think we could add a //TODO here so we will not forget the followup task later :) |
||
|
||
func NewHubKubeconfigSecret(namespace, name, resourceVersion string, cert *TestCert, data map[string][]byte) *corev1.Secret { | ||
secret := &corev1.Secret{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package aws_irsa | ||
|
||
import ( | ||
"k8s.io/client-go/tools/cache" | ||
|
||
cluster "open-cluster-management.io/api/client/cluster/clientset/versioned" | ||
managedclusterv1client "open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1" | ||
managedclusterinformers "open-cluster-management.io/api/client/cluster/informers/externalversions/cluster" | ||
managedclusterv1lister "open-cluster-management.io/api/client/cluster/listers/cluster/v1" | ||
) | ||
|
||
type AWSIRSAControl interface { | ||
isApproved(name string) (bool, error) | ||
generateEKSKubeConfig(name string) ([]byte, error) | ||
|
||
// Informer is public so we can add indexer outside | ||
Informer() cache.SharedIndexInformer | ||
} | ||
|
||
var _ AWSIRSAControl = &v1AWSIRSAControl{} | ||
|
||
type v1AWSIRSAControl struct { | ||
hubManagedClusterInformer cache.SharedIndexInformer | ||
hubManagedClusterLister managedclusterv1lister.ManagedClusterLister | ||
hubManagedClusterClient managedclusterv1client.ManagedClusterInterface | ||
} | ||
|
||
func (v *v1AWSIRSAControl) isApproved(name string) (bool, error) { | ||
// TODO: check if the managedclusuter cr on hub has required condition and is approved | ||
approved := false | ||
|
||
return approved, nil | ||
} | ||
|
||
func (v *v1AWSIRSAControl) generateEKSKubeConfig(name string) ([]byte, error) { | ||
// TODO: generate and return kubeconfig | ||
return nil, nil | ||
} | ||
|
||
func (v *v1AWSIRSAControl) Informer() cache.SharedIndexInformer { | ||
return v.hubManagedClusterInformer | ||
} | ||
|
||
//TODO: Uncomment the below once required in the aws irsa authentication implementation | ||
/* | ||
func (v *v1AWSIRSAControl) get(name string) (metav1.Object, error) { | ||
managedcluster, err := v.hubManagedClusterLister.Get(name) | ||
switch { | ||
case apierrors.IsNotFound(err): | ||
// fallback to fetching managedcluster from hub apiserver in case it is not cached by informer yet | ||
managedcluster, err = v.hubManagedClusterClient.Get(context.Background(), name, metav1.GetOptions{}) | ||
if apierrors.IsNotFound(err) { | ||
return nil, fmt.Errorf("unable to get managedcluster %q. It might have already been deleted", name) | ||
} | ||
case err != nil: | ||
return nil, err | ||
} | ||
return managedcluster, nil | ||
} | ||
*/ | ||
|
||
func NewAWSIRSAControl(hubManagedClusterInformer managedclusterinformers.Interface, hubManagedClusterClient cluster.Interface) (AWSIRSAControl, error) { | ||
return &v1AWSIRSAControl{ | ||
hubManagedClusterInformer: hubManagedClusterInformer.V1().ManagedClusters().Informer(), | ||
hubManagedClusterLister: hubManagedClusterInformer.V1().ManagedClusters().Lister(), | ||
hubManagedClusterClient: hubManagedClusterClient.ClusterV1().ManagedClusters(), | ||
}, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add some comment for this func, it will be easier to understand what is the format for the arn.