-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into hack_k8s_1.22
- Loading branch information
Showing
24 changed files
with
915 additions
and
420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
# Maintain dependencies for GitHub Actions | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
- package-ecosystem: "gomod" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
allow: | ||
- dependency-type: "direct" | ||
ignore: | ||
- dependency-name: "k8s.io*" | ||
update-types: [ "version-update:semver-major", "version-update:semver-minor" ] | ||
- dependency-name: "*" | ||
update-types: ["version-update:semver-major"] | ||
- package-ecosystem: "docker" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
ignore: | ||
- dependency-name: "golang" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
|
||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
"github.com/keikoproj/iam-manager/pkg/logging" | ||
) | ||
|
||
/** | ||
* This function is used to retrieve all IAM-Roles from the cluster across all namespaces. | ||
* It will return a list of IAM-Roles in structured format. | ||
*/ | ||
func ListIamRoles(ctx context.Context, c client.Client) ([]*Iamrole, error) { | ||
log := logging.Logger(ctx, "k8s", "client", "ListIamRoles") | ||
|
||
var uRoleList *unstructured.UnstructuredList = &unstructured.UnstructuredList{} | ||
var iamRoles []*Iamrole = []*Iamrole{} | ||
var err error | ||
var b []byte | ||
var IamroleGroupVersionKind = schema.GroupVersionKind{ | ||
Group: "iammanager.keikoproj.io", | ||
Version: "v1alpha1", | ||
Kind: "Iamrole", | ||
} | ||
uRoleList.SetGroupVersionKind(IamroleGroupVersionKind) | ||
|
||
if err = c.List(ctx, uRoleList, &client.ListOptions{}); err != nil { | ||
log.Error(err, "unable to list iamroles resources") | ||
return iamRoles, err | ||
} | ||
|
||
if b, err = json.Marshal(uRoleList.Items); err != nil { | ||
log.Error(err, "unable to marshal iamroles resources") | ||
return iamRoles, err | ||
} | ||
|
||
if err = json.Unmarshal(b, &iamRoles); err != nil { | ||
log.Error(err, "unable to unmarshal iamroles resources") | ||
return iamRoles, err | ||
} | ||
|
||
return iamRoles, nil | ||
} | ||
|
||
func GetIamRole(ctx context.Context, c client.Client, name, namespace string) (*Iamrole, error) { | ||
log := logging.Logger(ctx, "k8s", "client", "GetIamRole") | ||
log.V(1).Info("get api call for iamrole") | ||
|
||
var uRole *unstructured.Unstructured = &unstructured.Unstructured{} | ||
var iamRole *Iamrole = &Iamrole{} | ||
var err error | ||
var b []byte | ||
var IamroleGroupVersionKind = schema.GroupVersionKind{ | ||
Group: "iammanager.keikoproj.io", | ||
Version: "v1alpha1", | ||
Kind: "Iamrole", | ||
} | ||
uRole.SetGroupVersionKind(IamroleGroupVersionKind) | ||
|
||
if err = c.Get(ctx, client.ObjectKey{Namespace: namespace, Name: name}, uRole); err != nil { | ||
log.Error(err, "unable to get iamrole resource") | ||
return iamRole, err | ||
} | ||
|
||
if b, err = json.Marshal(uRole); err != nil { | ||
log.Error(err, "unable to marshal iamrole resource") | ||
return iamRole, err | ||
} | ||
|
||
if err = json.Unmarshal(b, iamRole); err != nil { | ||
log.Error(err, "unable to unmarshal iamrole resource") | ||
return iamRole, err | ||
} | ||
|
||
return iamRole, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.