-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect and configure the replicated SDK chart
- Loading branch information
Showing
20 changed files
with
2,185 additions
and
36 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
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,62 @@ | ||
package k8sutil | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"gopkg.in/go-playground/assert.v1" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/kubernetes" | ||
"k8s.io/client-go/kubernetes/fake" | ||
) | ||
|
||
func TestGetKotsadmID(t *testing.T) { | ||
|
||
type args struct { | ||
clientset kubernetes.Interface | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
shouldCreateConfigMap bool | ||
}{ | ||
{ | ||
name: "configmap exists", | ||
args: args{ | ||
clientset: fake.NewSimpleClientset(&corev1.ConfigMap{ | ||
ObjectMeta: metav1.ObjectMeta{Name: KotsadmIDConfigMapName}, | ||
Data: map[string]string{"id": "cluster-id"}, | ||
}), | ||
}, | ||
want: "cluster-id", | ||
shouldCreateConfigMap: false, | ||
}, | ||
{ | ||
name: "configmap does not exist, should create", | ||
args: args{ | ||
clientset: fake.NewSimpleClientset(), | ||
}, | ||
want: "", | ||
shouldCreateConfigMap: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got := GetKotsadmID(tt.args.clientset) | ||
if tt.want != "" { | ||
assert.Equal(t, tt.want, got) | ||
} else { | ||
// a random uuid is generated | ||
assert.NotEqual(t, "", got) | ||
} | ||
|
||
if tt.shouldCreateConfigMap { | ||
// should have created the configmap if it didn't exist | ||
_, err := tt.args.clientset.CoreV1().ConfigMaps("").Get(context.TODO(), KotsadmIDConfigMapName, metav1.GetOptions{}) | ||
assert.Equal(t, nil, err) | ||
} | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.