Skip to content

Commit

Permalink
eksconfig: fix ECR repos
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <[email protected]>
  • Loading branch information
gyuho committed May 15, 2020
1 parent 347b69f commit 1ae0938
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 9 deletions.
2 changes: 1 addition & 1 deletion eksconfig/add-on-cluster-loader-remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (cfg *Config) validateAddOnClusterLoaderRemote() error {
if cfg.AddOnClusterLoaderRemote.RepositoryURI == "" {
return errors.New("AddOnClusterLoaderRemote.RepositoryURI empty")
}
if strings.Contains(cfg.AddOnClusterLoaderRemote.RepositoryURI, cfg.AddOnClusterLoaderRemote.RepositoryAccountID) {
if !strings.Contains(cfg.AddOnClusterLoaderRemote.RepositoryURI, cfg.AddOnClusterLoaderRemote.RepositoryAccountID) {
return fmt.Errorf("AddOnClusterLoaderRemote.RepositoryURI %q does not have AddOnClusterLoaderRemote.RepositoryAccountID %q", cfg.AddOnClusterLoaderRemote.RepositoryURI, cfg.AddOnClusterLoaderRemote.RepositoryAccountID)
}
if cfg.AddOnClusterLoaderRemote.RepositoryImageTag == "" {
Expand Down
2 changes: 1 addition & 1 deletion eksconfig/add-on-fargate.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (cfg *Config) validateAddOnFargate() error {
if cfg.AddOnFargate.RepositoryName == "" {
return errors.New("AddOnFargate.RepositoryName empty")
}
if strings.Contains(cfg.AddOnFargate.RepositoryURI, cfg.AddOnFargate.RepositoryAccountID) {
if !strings.Contains(cfg.AddOnFargate.RepositoryURI, cfg.AddOnFargate.RepositoryAccountID) {
return fmt.Errorf("AddOnFargate.RepositoryURI %q does not have AddOnFargate.RepositoryAccountID %q", cfg.AddOnFargate.RepositoryURI, cfg.AddOnFargate.RepositoryAccountID)
}
if cfg.AddOnFargate.RepositoryImageTag == "" {
Expand Down
3 changes: 1 addition & 2 deletions eksconfig/add-on-hollow-nodes-remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ type AddOnHollowNodesRemote struct {
// "cmd/kubelet/app.rlimit.SetNumFiles(MaxOpenFiles)" sets this for the host.
MaxOpenFiles int64 `json:"max-open-files"`


// RepositoryAccountID is the account ID for tester ECR image.
// e.g. "aws/aws-k8s-tester" for "[ACCOUNT_ID].dkr.ecr.us-west-2.amazonaws.com/aws/aws-k8s-tester"
RepositoryAccountID string `json:"repository-account-id,omitempty"`
Expand Down Expand Up @@ -132,7 +131,7 @@ func (cfg *Config) validateAddOnHollowNodesRemote() error {
if cfg.AddOnHollowNodesRemote.RepositoryURI == "" {
return errors.New("AddOnHollowNodesRemote.RepositoryURI empty")
}
if strings.Contains(cfg.AddOnHollowNodesRemote.RepositoryURI, cfg.AddOnHollowNodesRemote.RepositoryAccountID) {
if !strings.Contains(cfg.AddOnHollowNodesRemote.RepositoryURI, cfg.AddOnHollowNodesRemote.RepositoryAccountID) {
return fmt.Errorf("AddOnHollowNodesRemote.RepositoryURI %q does not have AddOnHollowNodesRemote.RepositoryAccountID %q", cfg.AddOnHollowNodesRemote.RepositoryURI, cfg.AddOnHollowNodesRemote.RepositoryAccountID)
}
if cfg.AddOnHollowNodesRemote.RepositoryImageTag == "" {
Expand Down
2 changes: 1 addition & 1 deletion eksconfig/add-on-irsa-fargate.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (cfg *Config) validateAddOnIRSAFargate() error {
if cfg.AddOnIRSAFargate.RepositoryURI == "" {
return errors.New("AddOnIRSAFargate.RepositoryURI empty")
}
if strings.Contains(cfg.AddOnIRSAFargate.RepositoryURI, cfg.AddOnIRSAFargate.RepositoryAccountID) {
if !strings.Contains(cfg.AddOnIRSAFargate.RepositoryURI, cfg.AddOnIRSAFargate.RepositoryAccountID) {
return fmt.Errorf("AddOnIRSAFargate.RepositoryURI %q does not have AddOnIRSAFargate.RepositoryAccountID %q", cfg.AddOnIRSAFargate.RepositoryURI, cfg.AddOnIRSAFargate.RepositoryAccountID)
}
if cfg.AddOnIRSAFargate.RepositoryImageTag == "" {
Expand Down
2 changes: 1 addition & 1 deletion eksconfig/add-on-irsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (cfg *Config) validateAddOnIRSA() error {
if cfg.AddOnIRSA.RepositoryURI == "" {
return errors.New("AddOnIRSA.RepositoryURI empty")
}
if strings.Contains(cfg.AddOnIRSA.RepositoryURI, cfg.AddOnIRSA.RepositoryAccountID) {
if !strings.Contains(cfg.AddOnIRSA.RepositoryURI, cfg.AddOnIRSA.RepositoryAccountID) {
return fmt.Errorf("AddOnIRSA.RepositoryURI %q does not have AddOnIRSA.RepositoryAccountID %q", cfg.AddOnIRSA.RepositoryURI, cfg.AddOnIRSA.RepositoryAccountID)
}
if cfg.AddOnIRSA.RepositoryImageTag == "" {
Expand Down
6 changes: 3 additions & 3 deletions eksconfig/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ log-level: info
log-outputs:
- stderr
- /home/ANT.AMAZON.COM/leegyuho/go/src/github.com/aws/aws-k8s-tester/eksconfig/default.log
name: eks-2020051515-icyz2siqheib
name: eks-2020051516-reinventplqq
on-failure-delete: true
on-failure-delete-wait-seconds: 120
parameters:
Expand All @@ -38,7 +38,7 @@ parameters:
role-cfn-stack-id: ""
role-create: true
role-managed-policy-arns: null
role-name: eks-2020051515-icyz2siqheib-role
role-name: eks-2020051516-reinventplqq-role
role-service-principals: null
signing-name: eks
tags: null
Expand All @@ -51,7 +51,7 @@ partition: aws
region: us-west-2
remote-access-commands-output-path: /home/ANT.AMAZON.COM/leegyuho/go/src/github.com/aws/aws-k8s-tester/eksconfig/default.ssh.sh
remote-access-key-create: true
remote-access-key-name: eks-2020051515-icyz2siqheib-key-nodes
remote-access-key-name: eks-2020051516-reinventplqq-key-nodes
remote-access-private-key-path: /home/ANT.AMAZON.COM/leegyuho/.ssh/kube_aws_rsa
s3-bucket-create: false
s3-bucket-create-keep: false
Expand Down
25 changes: 25 additions & 0 deletions eksconfig/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ func TestEnv(t *testing.T) {
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_FARGATE_ROLE_MANAGED_POLICY_ARNS")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_FARGATE_PROFILE_NAME", "hello")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_FARGATE_PROFILE_NAME")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_FARGATE_REPOSITORY_ACCOUNT_ID", "uri")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_FARGATE_REPOSITORY_ACCOUNT_ID")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_FARGATE_REPOSITORY_NAME", "fargate-repo-name")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_FARGATE_REPOSITORY_NAME")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_FARGATE_REPOSITORY_URI", "fargate-repo-uri")
Expand All @@ -285,6 +287,8 @@ func TestEnv(t *testing.T) {
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_ROLE_MANAGED_POLICY_ARNS")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_S3_KEY", "hello")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_S3_KEY")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_REPOSITORY_ACCOUNT_ID", "uri")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_REPOSITORY_ACCOUNT_ID")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_REPOSITORY_NAME", "irsa-repo-name")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_REPOSITORY_NAME")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_REPOSITORY_URI", "irsa-repo-uri")
Expand All @@ -308,6 +312,8 @@ func TestEnv(t *testing.T) {
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_FARGATE_S3_KEY")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_FARGATE_PROFILE_NAME", "hello")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_FARGATE_PROFILE_NAME")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_FARGATE_REPOSITORY_ACCOUNT_ID", "uri")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_FARGATE_REPOSITORY_ACCOUNT_ID")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_FARGATE_REPOSITORY_NAME", "irsa-fargate-repo-name")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_FARGATE_REPOSITORY_NAME")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_IRSA_FARGATE_REPOSITORY_URI", "irsa-fargate-repo-uri")
Expand Down Expand Up @@ -336,6 +342,8 @@ func TestEnv(t *testing.T) {
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_HOLLOW_NODES_REMOTE_NAMESPACE")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_HOLLOW_NODES_REMOTE_NODES", "333")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_HOLLOW_NODES_REMOTE_NODES")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_HOLLOW_NODES_REMOTE_REPOSITORY_ACCOUNT_ID", "uri")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_HOLLOW_NODES_REMOTE_REPOSITORY_ACCOUNT_ID")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_HOLLOW_NODES_REMOTE_REPOSITORY_NAME", "hollow-nodes-repo-name")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_HOLLOW_NODES_REMOTE_REPOSITORY_NAME")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_HOLLOW_NODES_REMOTE_REPOSITORY_URI", "hollow-nodes-repo-uri")
Expand All @@ -352,6 +360,8 @@ func TestEnv(t *testing.T) {
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_CLUSTER_LOADER_REMOTE_ENABLE")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_CLUSTER_LOADER_REMOTE_DURATION", "7m30s")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_CLUSTER_LOADER_REMOTE_DURATION")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_CLUSTER_LOADER_REMOTE_REPOSITORY_ACCOUNT_ID", "uri")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_CLUSTER_LOADER_REMOTE_REPOSITORY_ACCOUNT_ID")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_CLUSTER_LOADER_REMOTE_REPOSITORY_NAME", "cluster-loader-repo-name")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_CLUSTER_LOADER_REMOTE_REPOSITORY_NAME")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_CLUSTER_LOADER_REMOTE_REPOSITORY_URI", "cluster-loader-repo-uri")
Expand Down Expand Up @@ -829,6 +839,9 @@ func TestEnv(t *testing.T) {
if cfg.AddOnFargate.ProfileName != "hello" {
t.Fatalf("unexpected cfg.AddOnFargate.ProfileName %q", cfg.AddOnFargate.ProfileName)
}
if cfg.AddOnFargate.RepositoryAccountID != "uri" {
t.Fatalf("unexpected cfg.AddOnFargate.RepositoryAccountID %v", cfg.AddOnFargate.RepositoryAccountID)
}
if cfg.AddOnFargate.RepositoryName != "fargate-repo-name" {
t.Fatalf("unexpected cfg.AddOnFargate.RepositoryName %v", cfg.AddOnFargate.RepositoryName)
}
Expand Down Expand Up @@ -858,6 +871,9 @@ func TestEnv(t *testing.T) {
if cfg.AddOnIRSA.S3Key != "hello" {
t.Fatalf("unexpected cfg.AddOnIRSA.S3Key %q", cfg.AddOnIRSA.S3Key)
}
if cfg.AddOnIRSA.RepositoryAccountID != "uri" {
t.Fatalf("unexpected cfg.AddOnIRSA.RepositoryAccountID %v", cfg.AddOnIRSA.RepositoryAccountID)
}
if cfg.AddOnIRSA.RepositoryName != "irsa-repo-name" {
t.Fatalf("unexpected cfg.AddOnIRSA.RepositoryName %v", cfg.AddOnIRSA.RepositoryName)
}
Expand Down Expand Up @@ -894,6 +910,9 @@ func TestEnv(t *testing.T) {
if cfg.AddOnIRSAFargate.ProfileName != "hello" {
t.Fatalf("unexpected cfg.AddOnIRSAFargate.ProfileName %q", cfg.AddOnIRSAFargate.ProfileName)
}
if cfg.AddOnIRSAFargate.RepositoryAccountID != "uri" {
t.Fatalf("unexpected cfg.AddOnIRSAFargate.RepositoryAccountID %v", cfg.AddOnIRSAFargate.RepositoryAccountID)
}
if cfg.AddOnIRSAFargate.RepositoryName != "irsa-fargate-repo-name" {
t.Fatalf("unexpected cfg.AddOnIRSAFargate.RepositoryName %v", cfg.AddOnIRSAFargate.RepositoryName)
}
Expand Down Expand Up @@ -933,6 +952,9 @@ func TestEnv(t *testing.T) {
if cfg.AddOnHollowNodesRemote.Namespace != "test-hollow-nodes-namespace" {
t.Fatalf("unexpected cfg.AddOnHollowNodesRemote.Namespace %v", cfg.AddOnHollowNodesRemote.Namespace)
}
if cfg.AddOnHollowNodesRemote.RepositoryAccountID != "uri" {
t.Fatalf("unexpected cfg.AddOnHollowNodesRemote.RepositoryAccountID %v", cfg.AddOnHollowNodesRemote.RepositoryAccountID)
}
if cfg.AddOnHollowNodesRemote.RepositoryName != "hollow-nodes-repo-name" {
t.Fatalf("unexpected cfg.AddOnHollowNodesRemote.RepositoryName %v", cfg.AddOnHollowNodesRemote.RepositoryName)
}
Expand All @@ -956,6 +978,9 @@ func TestEnv(t *testing.T) {
if cfg.AddOnClusterLoaderRemote.Duration != 7*time.Minute+30*time.Second {
t.Fatalf("unexpected cfg.AddOnClusterLoaderRemote.Duration %v", cfg.AddOnClusterLoaderRemote.Duration)
}
if cfg.AddOnClusterLoaderRemote.RepositoryAccountID != "uri" {
t.Fatalf("unexpected cfg.AddOnClusterLoaderRemote.RepositoryAccountID %v", cfg.AddOnClusterLoaderRemote.RepositoryAccountID)
}
if cfg.AddOnClusterLoaderRemote.RepositoryName != "cluster-loader-repo-name" {
t.Fatalf("unexpected cfg.AddOnClusterLoaderRemote.RepositoryName %v", cfg.AddOnClusterLoaderRemote.RepositoryName)
}
Expand Down

0 comments on commit 1ae0938

Please sign in to comment.