Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
7a341f86
Unverified
Commit
7a341f86
authored
Jul 07, 2025
by
julienmancuso
Committed by
GitHub
Jul 08, 2025
Browse files
feat: simplify k8s deployment (#1708)
parent
5505507b
Changes
84
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
455 additions
and
1075 deletions
+455
-1075
deploy/cloud/operator/internal/dynamo/graph_test.go
deploy/cloud/operator/internal/dynamo/graph_test.go
+288
-1074
deploy/cloud/operator/internal/secrets/docker.go
deploy/cloud/operator/internal/secrets/docker.go
+72
-0
deploy/cloud/operator/internal/secrets/docker_test.go
deploy/cloud/operator/internal/secrets/docker_test.go
+95
-0
pyproject.toml
pyproject.toml
+0
-1
No files found.
deploy/cloud/operator/internal/dynamo/graph_test.go
View file @
7a341f86
...
...
@@ -37,7 +37,6 @@ import (
func
TestGenerateDynamoComponentsDeployments
(
t
*
testing
.
T
)
{
type
args
struct
{
parentDynamoGraphDeployment
*
v1alpha1
.
DynamoGraphDeployment
config
*
DynamoGraphConfig
ingressSpec
*
v1alpha1
.
IngressSpec
}
tests
:=
[]
struct
{
...
...
@@ -47,7 +46,7 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
wantErr
bool
}{
{
name
:
"Test GenerateDynamoComponentsDeployments
http dependency
"
,
name
:
"Test GenerateDynamoComponentsDeployments"
,
args
:
args
{
parentDynamoGraphDeployment
:
&
v1alpha1
.
DynamoGraphDeployment
{
ObjectMeta
:
metav1
.
ObjectMeta
{
...
...
@@ -55,40 +54,34 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
Namespace
:
"default"
,
},
Spec
:
v1alpha1
.
DynamoGraphDeploymentSpec
{
DynamoGraph
:
"dynamocomponent:ac4e234"
,
},
Services
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeploymentOverridesSpec
{
"service1"
:
{
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
DynamoNamespace
:
&
[]
string
{
"default"
}[
0
],
ComponentType
:
"main"
,
Replicas
:
&
[]
int32
{
3
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
config
:
&
DynamoGraphConfig
{
DynamoTag
:
"dynamocomponent:MyService1"
,
Services
:
[]
ServiceConfig
{
{
Name
:
"service1"
,
Dependencies
:
[]
map
[
string
]
string
{{
"service"
:
"service2"
}},
Config
:
Config
{
Dynamo
:
&
DynamoConfig
{
Enabled
:
true
,
Namespace
:
"default"
,
Name
:
"service1"
,
},
Resources
:
&
Resources
{
CPU
:
&
[]
string
{
"1"
}[
0
],
Memory
:
&
[]
string
{
"1Gi"
}[
0
],
GPU
:
&
[]
string
{
"0"
}[
0
],
Custom
:
map
[
string
]
string
{},
},
Autoscaling
:
&
Autoscaling
{
MinReplicas
:
1
,
MaxReplicas
:
5
,
},
Workers
:
&
[]
int32
{
3
}[
0
],
"service2"
:
{
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
DynamoNamespace
:
&
[]
string
{
"default"
}[
0
],
Replicas
:
&
[]
int32
{
3
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
},
{
Name
:
"service2"
,
Dependencies
:
[]
map
[
string
]
string
{},
Config
:
Config
{
Dynamo
:
&
DynamoConfig
{
Enabled
:
false
,
},
},
},
...
...
@@ -107,11 +100,10 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
},
},
Spec
:
v1alpha1
.
DynamoComponentDeploymentSpec
{
DynamoComponent
:
"dynamocomponent:ac4e234"
,
DynamoTag
:
"dynamocomponent:MyService1"
,
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
ServiceName
:
"service1"
,
DynamoNamespace
:
&
[]
string
{
"default"
}[
0
],
ComponentType
:
"main"
,
Replicas
:
&
[]
int32
{
3
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
...
...
@@ -120,28 +112,12 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
Limits
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
},
Autoscaling
:
&
v1alpha1
.
Autoscaling
{
Enabled
:
true
,
MinReplicas
:
1
,
MaxReplicas
:
5
,
},
ExternalServices
:
map
[
string
]
v1alpha1
.
ExternalService
{
"service2"
:
{
DeploymentSelectorKey
:
"name"
,
DeploymentSelectorValue
:
"service2"
,
},
},
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"default"
,
},
Autoscaling
:
nil
,
},
},
},
...
...
@@ -151,19 +127,27 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
Namespace
:
"default"
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service2"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"default"
,
},
},
Spec
:
v1alpha1
.
DynamoComponentDeploymentSpec
{
DynamoComponent
:
"dynamocomponent:ac4e234"
,
DynamoTag
:
"dynamocomponent:MyService1"
,
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
ServiceName
:
"service2"
,
Autoscaling
:
&
v1alpha1
.
Autoscaling
{
Enabled
:
false
,
},
DynamoNamespace
:
&
[]
string
{
"default"
}[
0
],
Replicas
:
&
[]
int32
{
3
}[
0
],
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service2"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"default"
,
},
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
},
Autoscaling
:
nil
,
},
},
},
...
...
@@ -171,7 +155,7 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
wantErr
:
false
,
},
{
name
:
"Test GenerateDynamoComponentsDeployments
dynamo dependency
"
,
name
:
"Test GenerateDynamoComponentsDeployments
with default dynamo namespace
"
,
args
:
args
{
parentDynamoGraphDeployment
:
&
v1alpha1
.
DynamoGraphDeployment
{
ObjectMeta
:
metav1
.
ObjectMeta
{
...
...
@@ -179,48 +163,41 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
Namespace
:
"default"
,
},
Spec
:
v1alpha1
.
DynamoGraphDeploymentSpec
{
DynamoGraph
:
"dynamocomponent:ac4e234"
,
},
},
config
:
&
DynamoGraphConfig
{
DynamoTag
:
"dynamocomponent:MyService2"
,
EntryService
:
"service1"
,
Services
:
[]
ServiceConfig
{
{
Name
:
"service1"
,
Dependencies
:
[]
map
[
string
]
string
{{
"service"
:
"service2"
}},
Config
:
Config
{
HttpExposed
:
true
,
Resources
:
&
Resources
{
CPU
:
&
[]
string
{
"1"
}[
0
],
Memory
:
&
[]
string
{
"1Gi"
}[
0
],
GPU
:
&
[]
string
{
"0"
}[
0
],
Services
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeploymentOverridesSpec
{
"service1"
:
{
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
DynamoNamespace
:
nil
,
ComponentType
:
"main"
,
Replicas
:
&
[]
int32
{
3
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
Autoscaling
:
&
Autoscaling
{
MinReplicas
:
1
,
MaxReplicas
:
5
,
},
},
},
{
Name
:
"service2"
,
Dependencies
:
[]
map
[
string
]
string
{},
Config
:
Config
{
Dynamo
:
&
DynamoConfig
{
Enabled
:
true
,
Namespace
:
"default"
,
Name
:
"service2"
,
"service2"
:
{
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
DynamoNamespace
:
nil
,
Replicas
:
&
[]
int32
{
3
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
},
},
},
},
ingressSpec
:
&
v1alpha1
.
IngressSpec
{
Enabled
:
true
,
Host
:
"test-dynamographdeployment"
,
},
},
ingressSpec
:
&
v1alpha1
.
IngressSpec
{},
},
want
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeployment
{
"service1"
:
{
ObjectMeta
:
metav1
.
ObjectMeta
{
...
...
@@ -228,13 +205,15 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
Namespace
:
"default"
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"dynamo-test-dynamographdeployment"
,
},
},
Spec
:
v1alpha1
.
DynamoComponentDeploymentSpec
{
DynamoComponent
:
"dynamocomponent:ac4e234"
,
DynamoTag
:
"dynamocomponent:MyService2"
,
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
ServiceName
:
"service1"
,
DynamoNamespace
:
&
[]
string
{
"dynamo-test-dynamographdeployment"
}[
0
],
ComponentType
:
"main"
,
Replicas
:
&
[]
int32
{
3
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
...
...
@@ -242,37 +221,14 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
Limits
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
},
Autoscaling
:
&
v1alpha1
.
Autoscaling
{
Enabled
:
true
,
MinReplicas
:
1
,
MaxReplicas
:
5
,
},
ExternalServices
:
map
[
string
]
v1alpha1
.
ExternalService
{
"service2"
:
{
DeploymentSelectorKey
:
"dynamo"
,
DeploymentSelectorValue
:
"service2/default"
,
},
},
Ingress
:
v1alpha1
.
IngressSpec
{
Enabled
:
true
,
Host
:
"test-dynamographdeployment"
,
},
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"dynamo-test-dynamographdeployment"
,
},
Autoscaling
:
nil
,
},
},
Status
:
v1alpha1
.
DynamoComponentDeploymentStatus
{
Conditions
:
nil
,
PodSelector
:
nil
,
},
},
"service2"
:
{
ObjectMeta
:
metav1
.
ObjectMeta
{
...
...
@@ -280,34 +236,27 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
Namespace
:
"default"
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service2"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"d
efaul
t"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"d
ynamo-test-dynamographdeploymen
t"
,
},
},
Spec
:
v1alpha1
.
DynamoComponentDeploymentSpec
{
DynamoComponent
:
"dynamocomponent:ac4e234"
,
DynamoTag
:
"dynamocomponent:MyService2"
,
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
ServiceName
:
"service2"
,
DynamoNamespace
:
&
[]
string
{
"default"
}[
0
],
Autoscaling
:
&
v1alpha1
.
Autoscaling
{
Enabled
:
false
,
},
DynamoNamespace
:
&
[]
string
{
"dynamo-test-dynamographdeployment"
}[
0
],
Replicas
:
&
[]
int32
{
3
}[
0
],
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service2"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"default"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"dynamo-test-dynamographdeployment"
,
},
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
Ingress
:
v1alpha1
.
IngressSpec
{
Enabled
:
false
,
Host
:
""
,
UseVirtualService
:
false
,
VirtualServiceGateway
:
nil
,
HostPrefix
:
nil
,
Annotations
:
nil
,
Labels
:
nil
,
TLS
:
nil
,
HostSuffix
:
nil
,
IngressControllerClassName
:
nil
,
},
Autoscaling
:
nil
,
},
},
},
...
...
@@ -315,7 +264,7 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
wantErr
:
false
,
},
{
name
:
"Test GenerateDynamoComponentsDeployments
dynamo dependency, defaul
t namespace"
,
name
:
"Test GenerateDynamoComponentsDeployments
with differen
t namespace
s
"
,
args
:
args
{
parentDynamoGraphDeployment
:
&
v1alpha1
.
DynamoGraphDeployment
{
ObjectMeta
:
metav1
.
ObjectMeta
{
...
...
@@ -323,37 +272,34 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
Namespace
:
"default"
,
},
Spec
:
v1alpha1
.
DynamoGraphDeploymentSpec
{
DynamoGraph
:
"dynamocomponent:ac4e234"
,
Services
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeploymentOverridesSpec
{
"service1"
:
{
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
DynamoNamespace
:
&
[]
string
{
"default"
}[
0
],
ComponentType
:
"main"
,
Replicas
:
&
[]
int32
{
3
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
},
config
:
&
DynamoGraphConfig
{
DynamoTag
:
"dynamocomponent:MyService2"
,
EntryService
:
"service1"
,
Services
:
[]
ServiceConfig
{
{
Name
:
"service1"
,
Dependencies
:
[]
map
[
string
]
string
{{
"service"
:
"service2"
}},
Config
:
Config
{
HttpExposed
:
true
,
Resources
:
&
Resources
{
CPU
:
&
[]
string
{
"1"
}[
0
],
Memory
:
&
[]
string
{
"1Gi"
}[
0
],
GPU
:
&
[]
string
{
"0"
}[
0
],
Custom
:
map
[
string
]
string
{},
},
Autoscaling
:
&
Autoscaling
{
MinReplicas
:
1
,
MaxReplicas
:
5
,
},
"service2"
:
{
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
DynamoNamespace
:
&
[]
string
{
"another"
}[
0
],
Replicas
:
&
[]
int32
{
3
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
},
{
Name
:
"service2"
,
Dependencies
:
[]
map
[
string
]
string
{},
Config
:
Config
{
Dynamo
:
&
DynamoConfig
{
Enabled
:
true
,
Name
:
"service2"
,
},
},
},
...
...
@@ -361,20 +307,24 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
},
ingressSpec
:
&
v1alpha1
.
IngressSpec
{},
},
want
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeployment
{
"service1"
:
{
want
:
nil
,
wantErr
:
true
,
},
{
name
:
"Test GenerateDynamoComponentsDeployments with ingress enabled"
,
args
:
args
{
parentDynamoGraphDeployment
:
&
v1alpha1
.
DynamoGraphDeployment
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test-dynamographdeployment
-service1
"
,
Name
:
"test-dynamographdeployment"
,
Namespace
:
"default"
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
},
},
Spec
:
v1alpha1
.
Dynamo
Component
DeploymentSpec
{
DynamoComponent
:
"dynamocomponent:ac4e234"
,
DynamoTag
:
"dynamocomponent:MyS
ervice
2"
,
Spec
:
v1alpha1
.
Dynamo
Graph
DeploymentSpec
{
Services
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeploymentOverridesSpec
{
"s
ervice
1"
:
{
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
ServiceName
:
"service1"
,
DynamoNamespace
:
nil
,
ComponentType
:
"main"
,
Replicas
:
&
[]
int32
{
3
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
...
...
@@ -382,44 +332,65 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
Limits
:
&
compounaiCommon
.
ResourceItem
{
},
},
},
"service2"
:
{
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
DynamoNamespace
:
nil
,
Replicas
:
&
[]
int32
{
3
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
},
Autoscaling
:
&
v1alpha1
.
Autoscaling
{
},
},
},
},
},
ingressSpec
:
&
v1alpha1
.
IngressSpec
{
Enabled
:
true
,
MinReplicas
:
1
,
MaxReplicas
:
5
,
Host
:
"test-dynamographdeployment"
,
},
ExternalServices
:
map
[
string
]
v1alpha1
.
ExternalService
{
"service2"
:
{
DeploymentSelectorKey
:
"dynamo"
,
DeploymentSelectorValue
:
"service2/dynamo-test-dynamographdeployment"
,
},
want
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeployment
{
"service1"
:
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test-dynamographdeployment-service1"
,
Namespace
:
"default"
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"dynamo-test-dynamographdeployment"
,
},
},
Spec
:
v1alpha1
.
DynamoComponentDeploymentSpec
{
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
ServiceName
:
"service1"
,
DynamoNamespace
:
&
[]
string
{
"dynamo-test-dynamographdeployment"
}[
0
],
ComponentType
:
"main"
,
Replicas
:
&
[]
int32
{
3
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
Ingress
:
v1alpha1
.
IngressSpec
{
Enabled
:
false
,
Host
:
""
,
UseVirtualService
:
false
,
VirtualServiceGateway
:
nil
,
HostPrefix
:
nil
,
Annotations
:
nil
,
Labels
:
nil
,
TLS
:
nil
,
HostSuffix
:
nil
,
IngressControllerClassName
:
nil
,
},
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"dynamo-test-dynamographdeployment"
,
},
Autoscaling
:
nil
,
Ingress
:
v1alpha1
.
IngressSpec
{
Enabled
:
true
,
Host
:
"test-dynamographdeployment"
,
},
},
Status
:
v1alpha1
.
DynamoComponentDeploymentStatus
{
Conditions
:
nil
,
PodSelector
:
nil
,
},
},
"service2"
:
{
...
...
@@ -432,38 +403,31 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
},
},
Spec
:
v1alpha1
.
DynamoComponentDeploymentSpec
{
DynamoComponent
:
"dynamocomponent:ac4e234"
,
DynamoTag
:
"dynamocomponent:MyService2"
,
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
ServiceName
:
"service2"
,
Autoscaling
:
&
v1alpha1
.
Autoscaling
{
Enabled
:
false
,
},
DynamoNamespace
:
&
[]
string
{
"dynamo-test-dynamographdeployment"
}[
0
],
Replicas
:
&
[]
int32
{
3
}[
0
],
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service2"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"dynamo-test-dynamographdeployment"
,
},
Ingress
:
v1alpha1
.
IngressSpec
{
Enabled
:
false
,
Host
:
""
,
UseVirtualService
:
false
,
VirtualServiceGateway
:
nil
,
HostPrefix
:
nil
,
Annotations
:
nil
,
Labels
:
nil
,
TLS
:
nil
,
HostSuffix
:
nil
,
IngressControllerClassName
:
nil
,
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
},
Autoscaling
:
nil
,
},
},
},
},
wantErr
:
false
,
},
{
name
:
"Test GenerateDynamoComponentsDeployments
dependency not found
"
,
name
:
"Test GenerateDynamoComponentsDeployments
with config from DYN_DEPLOYMENT_CONFIG env var
"
,
args
:
args
{
parentDynamoGraphDeployment
:
&
v1alpha1
.
DynamoGraphDeployment
{
ObjectMeta
:
metav1
.
ObjectMeta
{
...
...
@@ -471,654 +435,46 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
Namespace
:
"default"
,
},
Spec
:
v1alpha1
.
DynamoGraphDeploymentSpec
{
DynamoGraph
:
"dynamocomponent:ac4e234"
,
},
},
config
:
&
DynamoGraphConfig
{
DynamoTag
:
"dynamocomponent:MyService3"
,
Services
:
[]
ServiceConfig
{
Envs
:
[]
corev1
.
EnvVar
{
{
Name
:
"service1"
,
Dependencies
:
[]
map
[
string
]
string
{{
"service"
:
"service2"
}},
Config
:
Config
{
Dynamo
:
&
DynamoConfig
{
Enabled
:
true
,
Namespace
:
"default"
,
Name
:
"service1"
,
Name
:
"DYN_DEPLOYMENT_CONFIG"
,
Value
:
`{"service1":{"port":8080,"ServiceArgs":{"Workers":2, "Resources":{"CPU":"2", "Memory":"2Gi", "GPU":"2"}}}}`
,
},
Resources
:
&
Resources
{
CPU
:
&
[]
string
{
"1"
}[
0
],
Memory
:
&
[]
string
{
"1Gi"
}[
0
],
GPU
:
&
[]
string
{
"0"
}[
0
],
},
Services
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeploymentOverridesSpec
{
"service1"
:
{
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
DynamoNamespace
:
nil
,
ComponentType
:
"main"
,
Replicas
:
&
[]
int32
{
3
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
Autoscaling
:
&
Autoscaling
{
MinReplicas
:
1
,
MaxReplicas
:
5
,
},
},
},
{
Name
:
"service3"
,
Dependencies
:
[]
map
[
string
]
string
{},
Config
:
Config
{
Dynamo
:
&
DynamoConfig
{
Enabled
:
true
,
Namespace
:
"default"
,
Name
:
"service3"
,
"service2"
:
{
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
DynamoNamespace
:
nil
,
Replicas
:
&
[]
int32
{
3
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
},
},
},
},
ingressSpec
:
&
v1alpha1
.
IngressSpec
{},
},
wantErr
:
true
,
},
{
name
:
"Test GenerateDynamoComponentsDeployments planner"
,
args
:
args
{
parentDynamoGraphDeployment
:
&
v1alpha1
.
DynamoGraphDeployment
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test-dynamographdeployment"
,
Namespace
:
"default"
,
},
Spec
:
v1alpha1
.
DynamoGraphDeploymentSpec
{
DynamoGraph
:
"dynamocomponent:ac4e234"
,
},
},
config
:
&
DynamoGraphConfig
{
DynamoTag
:
"dynamocomponent:MyService1"
,
Services
:
[]
ServiceConfig
{
{
Name
:
"service1"
,
Config
:
Config
{
Dynamo
:
&
DynamoConfig
{
Enabled
:
true
,
Namespace
:
"default"
,
Name
:
"service1"
,
ComponentType
:
ComponentTypePlanner
,
},
Resources
:
&
Resources
{
CPU
:
&
[]
string
{
"1"
}[
0
],
Memory
:
&
[]
string
{
"1Gi"
}[
0
],
GPU
:
&
[]
string
{
"0"
}[
0
],
Custom
:
map
[
string
]
string
{},
},
},
},
},
},
ingressSpec
:
&
v1alpha1
.
IngressSpec
{},
},
want
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeployment
{
"service1"
:
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test-dynamographdeployment-service1"
,
Namespace
:
"default"
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"default"
,
},
},
Spec
:
v1alpha1
.
DynamoComponentDeploymentSpec
{
DynamoComponent
:
"dynamocomponent:ac4e234"
,
DynamoTag
:
"dynamocomponent:MyService1"
,
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
ServiceName
:
"service1"
,
DynamoNamespace
:
&
[]
string
{
"default"
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
Limits
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
},
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"default"
,
},
ExtraPodSpec
:
&
compounaiCommon
.
ExtraPodSpec
{
ServiceAccountName
:
PlannerServiceAccountName
,
},
Autoscaling
:
&
v1alpha1
.
Autoscaling
{},
},
},
},
},
wantErr
:
false
,
},
{
name
:
"Test GenerateDynamoComponentsDeployments dynamo dependency, different namespace"
,
args
:
args
{
parentDynamoGraphDeployment
:
&
v1alpha1
.
DynamoGraphDeployment
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test-dynamographdeployment"
,
Namespace
:
"default"
,
},
Spec
:
v1alpha1
.
DynamoGraphDeploymentSpec
{
DynamoGraph
:
"dynamocomponent:ac4e234"
,
},
},
config
:
&
DynamoGraphConfig
{
DynamoTag
:
"dynamocomponent:MyService2"
,
EntryService
:
"service1"
,
Services
:
[]
ServiceConfig
{
{
Name
:
"service1"
,
Dependencies
:
[]
map
[
string
]
string
{{
"service"
:
"service2"
}},
Config
:
Config
{
Dynamo
:
&
DynamoConfig
{
Enabled
:
true
,
Namespace
:
"namespace1"
,
Name
:
"service1"
,
},
Resources
:
&
Resources
{
CPU
:
&
[]
string
{
"1"
}[
0
],
Memory
:
&
[]
string
{
"1Gi"
}[
0
],
GPU
:
&
[]
string
{
"0"
}[
0
],
Custom
:
map
[
string
]
string
{},
},
Autoscaling
:
&
Autoscaling
{
MinReplicas
:
1
,
MaxReplicas
:
5
,
},
},
},
{
Name
:
"service2"
,
Dependencies
:
[]
map
[
string
]
string
{},
Config
:
Config
{
Dynamo
:
&
DynamoConfig
{
Enabled
:
true
,
Namespace
:
"namespace2"
,
Name
:
"service2"
,
},
},
},
},
},
ingressSpec
:
&
v1alpha1
.
IngressSpec
{},
},
want
:
nil
,
wantErr
:
true
,
},
{
name
:
"Test GenerateDynamoComponentsDeployments ingress enabled by default"
,
args
:
args
{
parentDynamoGraphDeployment
:
&
v1alpha1
.
DynamoGraphDeployment
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test-dynamographdeployment"
,
Namespace
:
"default"
,
},
Spec
:
v1alpha1
.
DynamoGraphDeploymentSpec
{
DynamoGraph
:
"dynamocomponent:ac4e234"
,
},
},
config
:
&
DynamoGraphConfig
{
DynamoTag
:
"dynamocomponent:MyServiceIngressEnabled"
,
EntryService
:
"service1"
,
Services
:
[]
ServiceConfig
{
{
Name
:
"service1"
,
Config
:
Config
{
HttpExposed
:
true
,
},
},
},
},
ingressSpec
:
&
v1alpha1
.
IngressSpec
{
Enabled
:
true
,
Host
:
"test-dynamographdeployment"
,
},
},
want
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeployment
{
"service1"
:
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test-dynamographdeployment-service1"
,
Namespace
:
"default"
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
},
},
Spec
:
v1alpha1
.
DynamoComponentDeploymentSpec
{
DynamoComponent
:
"dynamocomponent:ac4e234"
,
DynamoTag
:
"dynamocomponent:MyServiceIngressEnabled"
,
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
Annotations
:
nil
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
},
ServiceName
:
"service1"
,
DynamoNamespace
:
nil
,
Resources
:
nil
,
Autoscaling
:
&
v1alpha1
.
Autoscaling
{
Enabled
:
false
,
MinReplicas
:
0
,
MaxReplicas
:
0
,
Behavior
:
nil
,
Metrics
:
nil
,
},
Envs
:
nil
,
EnvFromSecret
:
nil
,
PVC
:
nil
,
RunMode
:
nil
,
ExternalServices
:
nil
,
Ingress
:
v1alpha1
.
IngressSpec
{
Enabled
:
true
,
Host
:
"test-dynamographdeployment"
,
},
ExtraPodMetadata
:
nil
,
ExtraPodSpec
:
nil
,
LivenessProbe
:
nil
,
ReadinessProbe
:
nil
,
Replicas
:
nil
,
},
},
Status
:
v1alpha1
.
DynamoComponentDeploymentStatus
{
Conditions
:
nil
,
PodSelector
:
nil
,
},
},
},
wantErr
:
false
,
},
{
name
:
"Test GenerateDynamoComponentsDeployments ingress explicitly disabled"
,
args
:
args
{
parentDynamoGraphDeployment
:
&
v1alpha1
.
DynamoGraphDeployment
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test-dynamographdeployment"
,
Namespace
:
"default"
,
},
Spec
:
v1alpha1
.
DynamoGraphDeploymentSpec
{
DynamoGraph
:
"dynamocomponent:ac4e234"
,
},
},
config
:
&
DynamoGraphConfig
{
DynamoTag
:
"dynamocomponent:MyServiceIngressDisabled"
,
Services
:
[]
ServiceConfig
{
{
Name
:
"service1"
,
Config
:
Config
{},
},
},
},
ingressSpec
:
&
v1alpha1
.
IngressSpec
{
Enabled
:
false
,
},
},
want
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeployment
{
"service1"
:
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test-dynamographdeployment-service1"
,
Namespace
:
"default"
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
},
},
Spec
:
v1alpha1
.
DynamoComponentDeploymentSpec
{
DynamoComponent
:
"dynamocomponent:ac4e234"
,
DynamoTag
:
"dynamocomponent:MyServiceIngressDisabled"
,
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
Annotations
:
nil
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
},
ServiceName
:
"service1"
,
DynamoNamespace
:
nil
,
Resources
:
nil
,
Autoscaling
:
&
v1alpha1
.
Autoscaling
{
Enabled
:
false
,
MinReplicas
:
0
,
MaxReplicas
:
0
,
Behavior
:
nil
,
Metrics
:
nil
,
},
Envs
:
nil
,
EnvFromSecret
:
nil
,
PVC
:
nil
,
RunMode
:
nil
,
ExternalServices
:
nil
,
Ingress
:
v1alpha1
.
IngressSpec
{
Enabled
:
false
,
Host
:
""
,
UseVirtualService
:
false
,
VirtualServiceGateway
:
nil
,
HostPrefix
:
nil
,
Annotations
:
nil
,
Labels
:
nil
,
TLS
:
nil
,
HostSuffix
:
nil
,
IngressControllerClassName
:
nil
,
},
ExtraPodMetadata
:
nil
,
ExtraPodSpec
:
nil
,
LivenessProbe
:
nil
,
ReadinessProbe
:
nil
,
Replicas
:
nil
,
},
},
Status
:
v1alpha1
.
DynamoComponentDeploymentStatus
{
Conditions
:
nil
,
PodSelector
:
nil
,
},
},
},
wantErr
:
false
,
},
{
name
:
"Test GenerateDynamoComponentsDeployments ingress custom host"
,
args
:
args
{
parentDynamoGraphDeployment
:
&
v1alpha1
.
DynamoGraphDeployment
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test-dynamographdeployment"
,
Namespace
:
"default"
,
},
Spec
:
v1alpha1
.
DynamoGraphDeploymentSpec
{
DynamoGraph
:
"dynamocomponent:ac4e234"
,
},
},
config
:
&
DynamoGraphConfig
{
DynamoTag
:
"dynamocomponent:MyServiceIngressCustomHost"
,
EntryService
:
"service1"
,
Services
:
[]
ServiceConfig
{
{
Name
:
"service1"
,
Config
:
Config
{
HttpExposed
:
true
,
},
},
},
},
ingressSpec
:
&
v1alpha1
.
IngressSpec
{
Enabled
:
true
,
Host
:
"custom-host"
,
},
},
want
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeployment
{
"service1"
:
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test-dynamographdeployment-service1"
,
Namespace
:
"default"
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
},
},
Spec
:
v1alpha1
.
DynamoComponentDeploymentSpec
{
DynamoComponent
:
"dynamocomponent:ac4e234"
,
DynamoTag
:
"dynamocomponent:MyServiceIngressCustomHost"
,
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
Annotations
:
nil
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
},
ServiceName
:
"service1"
,
DynamoNamespace
:
nil
,
Resources
:
nil
,
Autoscaling
:
&
v1alpha1
.
Autoscaling
{
Enabled
:
false
,
MinReplicas
:
0
,
MaxReplicas
:
0
,
Behavior
:
nil
,
Metrics
:
nil
,
},
Envs
:
nil
,
EnvFromSecret
:
nil
,
PVC
:
nil
,
RunMode
:
nil
,
ExternalServices
:
nil
,
Ingress
:
v1alpha1
.
IngressSpec
{
Enabled
:
true
,
Host
:
"custom-host"
,
},
ExtraPodMetadata
:
nil
,
ExtraPodSpec
:
nil
,
LivenessProbe
:
nil
,
ReadinessProbe
:
nil
,
Replicas
:
nil
,
},
},
Status
:
v1alpha1
.
DynamoComponentDeploymentStatus
{
Conditions
:
nil
,
PodSelector
:
nil
,
},
},
},
wantErr
:
false
,
},
{
name
:
"Test GenerateDynamoComponentsDeployments with config override from parent deployment"
,
args
:
args
{
parentDynamoGraphDeployment
:
&
v1alpha1
.
DynamoGraphDeployment
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test-dynamographdeployment"
,
Namespace
:
"default"
,
},
Spec
:
v1alpha1
.
DynamoGraphDeploymentSpec
{
DynamoGraph
:
"dynamocomponent:ac4e234"
,
Services
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeploymentOverridesSpec
{
"service1"
:
{
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"10"
,
Memory
:
"10Gi"
,
},
},
},
},
},
},
},
config
:
&
DynamoGraphConfig
{
DynamoTag
:
"dynamocomponent:MyService2"
,
EntryService
:
"service1"
,
Services
:
[]
ServiceConfig
{
{
Name
:
"service1"
,
Dependencies
:
[]
map
[
string
]
string
{{
"service"
:
"service2"
}},
Config
:
Config
{
HttpExposed
:
true
,
Resources
:
&
Resources
{
CPU
:
&
[]
string
{
"1"
}[
0
],
Memory
:
&
[]
string
{
"1Gi"
}[
0
],
GPU
:
&
[]
string
{
"0"
}[
0
],
Custom
:
map
[
string
]
string
{},
},
Autoscaling
:
&
Autoscaling
{
MinReplicas
:
1
,
MaxReplicas
:
5
,
},
},
},
{
Name
:
"service2"
,
Dependencies
:
[]
map
[
string
]
string
{},
Config
:
Config
{
Dynamo
:
&
DynamoConfig
{
Enabled
:
true
,
Namespace
:
"default"
,
Name
:
"service2"
,
},
},
},
},
},
ingressSpec
:
&
v1alpha1
.
IngressSpec
{
Enabled
:
true
,
Host
:
"test-dynamographdeployment"
,
},
},
want
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeployment
{
"service1"
:
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test-dynamographdeployment-service1"
,
Namespace
:
"default"
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
},
},
Spec
:
v1alpha1
.
DynamoComponentDeploymentSpec
{
DynamoComponent
:
"dynamocomponent:ac4e234"
,
DynamoTag
:
"dynamocomponent:MyService2"
,
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
ServiceName
:
"service1"
,
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"10"
,
Memory
:
"10Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
Limits
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
},
Autoscaling
:
&
v1alpha1
.
Autoscaling
{
Enabled
:
true
,
MinReplicas
:
1
,
MaxReplicas
:
5
,
},
ExternalServices
:
map
[
string
]
v1alpha1
.
ExternalService
{
"service2"
:
{
DeploymentSelectorKey
:
"dynamo"
,
DeploymentSelectorValue
:
"service2/default"
,
},
},
Ingress
:
v1alpha1
.
IngressSpec
{
Enabled
:
true
,
Host
:
"test-dynamographdeployment"
,
},
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
},
},
},
Status
:
v1alpha1
.
DynamoComponentDeploymentStatus
{
Conditions
:
nil
,
PodSelector
:
nil
,
},
},
"service2"
:
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test-dynamographdeployment-service2"
,
Namespace
:
"default"
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service2"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"default"
,
},
},
Spec
:
v1alpha1
.
DynamoComponentDeploymentSpec
{
DynamoComponent
:
"dynamocomponent:ac4e234"
,
DynamoTag
:
"dynamocomponent:MyService2"
,
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
ServiceName
:
"service2"
,
DynamoNamespace
:
&
[]
string
{
"default"
}[
0
],
Autoscaling
:
&
v1alpha1
.
Autoscaling
{
Enabled
:
false
,
},
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service2"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"default"
,
},
Ingress
:
v1alpha1
.
IngressSpec
{
Enabled
:
false
,
Host
:
""
,
UseVirtualService
:
false
,
VirtualServiceGateway
:
nil
,
HostPrefix
:
nil
,
Annotations
:
nil
,
Labels
:
nil
,
TLS
:
nil
,
HostSuffix
:
nil
,
IngressControllerClassName
:
nil
,
},
},
},
},
},
wantErr
:
false
,
},
{
name
:
"Test GenerateDynamoComponentsDeployments generate config from DYN_DEPLOYMENT_CONFIG env var"
,
args
:
args
{
parentDynamoGraphDeployment
:
&
v1alpha1
.
DynamoGraphDeployment
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test-dynamographdeployment"
,
Namespace
:
"default"
,
},
Spec
:
v1alpha1
.
DynamoGraphDeploymentSpec
{
DynamoGraph
:
"dynamocomponent:ac4e234"
,
Envs
:
[]
corev1
.
EnvVar
{
{
Name
:
"DYN_DEPLOYMENT_CONFIG"
,
Value
:
`{"service1":{"port":8080,"ServiceArgs":{"Workers":3, "Resources":{"CPU":"2", "Memory":"2Gi", "GPU":"2"}}}}`
,
},
},
Services
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeploymentOverridesSpec
{
"service1"
:
{
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"10"
,
Memory
:
"10Gi"
,
},
},
},
},
},
},
},
config
:
&
DynamoGraphConfig
{
DynamoTag
:
"dynamocomponent:MyService2"
,
EntryService
:
"service1"
,
Services
:
[]
ServiceConfig
{
{
Name
:
"service1"
,
Dependencies
:
[]
map
[
string
]
string
{{
"service"
:
"service2"
}},
Config
:
Config
{
HttpExposed
:
true
,
Resources
:
&
Resources
{
CPU
:
&
[]
string
{
"1"
}[
0
],
Memory
:
&
[]
string
{
"1Gi"
}[
0
],
GPU
:
&
[]
string
{
"0"
}[
0
],
Custom
:
map
[
string
]
string
{},
},
Autoscaling
:
&
Autoscaling
{
MinReplicas
:
1
,
MaxReplicas
:
5
,
},
},
},
{
Name
:
"service2"
,
Dependencies
:
[]
map
[
string
]
string
{},
Config
:
Config
{
Dynamo
:
&
DynamoConfig
{
Enabled
:
true
,
Namespace
:
"default"
,
Name
:
"service2"
,
},
},
},
},
},
ingressSpec
:
&
v1alpha1
.
IngressSpec
{
Enabled
:
true
,
Host
:
"test-dynamographdeployment"
,
},
},
want
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeployment
{
"service1"
:
{
ObjectMeta
:
metav1
.
ObjectMeta
{
...
...
@@ -1126,19 +482,14 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
Namespace
:
"default"
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"dynamo-test-dynamographdeployment"
,
},
},
Spec
:
v1alpha1
.
DynamoComponentDeploymentSpec
{
DynamoComponent
:
"dynamocomponent:ac4e234"
,
DynamoTag
:
"dynamocomponent:MyService2"
,
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
Envs
:
[]
corev1
.
EnvVar
{
{
Name
:
"DYN_DEPLOYMENT_CONFIG"
,
Value
:
`{"service1":{"port":8080,"ServiceArgs":{"Workers":3, "Resources":{"CPU":"2", "Memory":"2Gi", "GPU":"2"}}}}`
,
},
},
ServiceName
:
"service1"
,
DynamoNamespace
:
&
[]
string
{
"dynamo-test-dynamographdeployment"
}[
0
],
ComponentType
:
"main"
,
Replicas
:
&
[]
int32
{
3
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
...
...
@@ -1151,32 +502,21 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
CPU
:
"2"
,
Memory
:
"2Gi"
,
GPU
:
"2"
,
Custom
:
map
[
string
]
string
{},
},
},
Autoscaling
:
&
v1alpha1
.
Autoscaling
{
Enabled
:
true
,
MinReplicas
:
1
,
MaxReplicas
:
5
,
},
ExternalServices
:
map
[
string
]
v1alpha1
.
ExternalService
{
"service2"
:
{
DeploymentSelectorKey
:
"dynamo"
,
DeploymentSelectorValue
:
"service2/default"
,
},
Custom
:
nil
,
},
Ingress
:
v1alpha1
.
IngressSpec
{
Enabled
:
true
,
Host
:
"test-dynamographdeployment"
,
},
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"dynamo-test-dynamographdeployment"
,
},
Autoscaling
:
nil
,
Envs
:
[]
corev1
.
EnvVar
{
{
Name
:
"DYN_DEPLOYMENT_CONFIG"
,
Value
:
`{"service1":{"ServiceArgs":{"Resources":{"CPU":"2","GPU":"2","Memory":"2Gi"},"Workers":2},"port":3000}}`
,
},
},
},
Status
:
v1alpha1
.
DynamoComponentDeploymentStatus
{
Conditions
:
nil
,
PodSelector
:
nil
,
},
},
"service2"
:
{
...
...
@@ -1185,39 +525,32 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
Namespace
:
"default"
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service2"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"d
efaul
t"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"d
ynamo-test-dynamographdeploymen
t"
,
},
},
Spec
:
v1alpha1
.
DynamoComponentDeploymentSpec
{
DynamoComponent
:
"dynamocomponent:ac4e234"
,
DynamoTag
:
"dynamocomponent:MyService2"
,
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
Envs
:
[]
corev1
.
EnvVar
{
{
Name
:
"DYN_DEPLOYMENT_CONFIG"
,
Value
:
`{"service1":{"port":8080,"ServiceArgs":{"Workers":3, "Resources":{"CPU":"2", "Memory":"2Gi", "GPU":"2"}}}}`
,
},
},
ServiceName
:
"service2"
,
DynamoNamespace
:
&
[]
string
{
"default"
}[
0
],
Autoscaling
:
&
v1alpha1
.
Autoscaling
{
Enabled
:
false
,
},
DynamoNamespace
:
&
[]
string
{
"dynamo-test-dynamographdeployment"
}[
0
],
Replicas
:
&
[]
int32
{
3
}[
0
],
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service2"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"default"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"dynamo-test-dynamographdeployment"
,
},
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
},
Autoscaling
:
nil
,
Envs
:
[]
corev1
.
EnvVar
{
{
Name
:
"DYN_DEPLOYMENT_CONFIG"
,
Value
:
`{"service1":{"port":8080,"ServiceArgs":{"Workers":2, "Resources":{"CPU":"2", "Memory":"2Gi", "GPU":"2"}}}}`
,
},
Ingress
:
v1alpha1
.
IngressSpec
{
Enabled
:
false
,
Host
:
""
,
UseVirtualService
:
false
,
VirtualServiceGateway
:
nil
,
HostPrefix
:
nil
,
Annotations
:
nil
,
Labels
:
nil
,
TLS
:
nil
,
HostSuffix
:
nil
,
IngressControllerClassName
:
nil
,
},
},
},
...
...
@@ -1226,7 +559,7 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
wantErr
:
false
,
},
{
name
:
"Test GenerateDynamoComponentsDeployments
, number of replicas always set by the parent CR
"
,
name
:
"Test GenerateDynamoComponentsDeployments
with ExtraPodSpec.MainContainer Command and Args
"
,
args
:
args
{
parentDynamoGraphDeployment
:
&
v1alpha1
.
DynamoGraphDeployment
{
ObjectMeta
:
metav1
.
ObjectMeta
{
...
...
@@ -1234,67 +567,46 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
Namespace
:
"default"
,
},
Spec
:
v1alpha1
.
DynamoGraphDeploymentSpec
{
DynamoGraph
:
"dynamocomponent:ac4e234"
,
Envs
:
[]
corev1
.
EnvVar
{
{
Name
:
"DYN_DEPLOYMENT_CONFIG"
,
Value
:
`{"service1":{"port":8080,"ServiceArgs":{"Workers":3, "Resources":{"CPU":"2", "Memory":"2Gi", "GPU":"2"}}}}`
,
},
},
Services
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeploymentOverridesSpec
{
"service1"
:
{
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
DynamoNamespace
:
&
[]
string
{
"default"
}[
0
],
ComponentType
:
"main"
,
Replicas
:
&
[]
int32
{
3
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"10"
,
Memory
:
"10Gi"
,
},
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
Replicas
:
&
[]
int32
{
10
}[
0
],
},
ExtraPodSpec
:
&
compounaiCommon
.
ExtraPodSpec
{
MainContainer
:
&
corev1
.
Container
{
Command
:
[]
string
{
"sh"
,
"-c"
},
Args
:
[]
string
{
"echo hello world"
,
"sleep 99999"
},
},
},
},
},
config
:
&
DynamoGraphConfig
{
DynamoTag
:
"dynamocomponent:MyService2"
,
EntryService
:
"service1"
,
Services
:
[]
ServiceConfig
{
{
Name
:
"service1"
,
Dependencies
:
[]
map
[
string
]
string
{{
"service"
:
"service2"
}},
Config
:
Config
{
HttpExposed
:
true
,
Resources
:
&
Resources
{
CPU
:
&
[]
string
{
"1"
}[
0
],
Memory
:
&
[]
string
{
"1Gi"
}[
0
],
GPU
:
&
[]
string
{
"0"
}[
0
],
"service2"
:
{
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
DynamoNamespace
:
&
[]
string
{
"default"
}[
0
],
Replicas
:
&
[]
int32
{
3
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
Autoscaling
:
&
Autoscaling
{
MinReplicas
:
1
,
MaxReplicas
:
5
,
},
Workers
:
&
[]
int32
{
2
}[
0
],
},
},
{
Name
:
"service2"
,
Dependencies
:
[]
map
[
string
]
string
{},
Config
:
Config
{
Dynamo
:
&
DynamoConfig
{
Enabled
:
true
,
Namespace
:
"default"
,
Name
:
"service2"
,
},
},
},
},
},
ingressSpec
:
&
v1alpha1
.
IngressSpec
{
Enabled
:
true
,
Host
:
"test-dynamographdeployment"
,
},
ingressSpec
:
&
v1alpha1
.
IngressSpec
{},
},
want
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeployment
{
"service1"
:
{
...
...
@@ -1303,57 +615,35 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
Namespace
:
"default"
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"default"
,
},
},
Spec
:
v1alpha1
.
DynamoComponentDeploymentSpec
{
DynamoComponent
:
"dynamocomponent:ac4e234"
,
DynamoTag
:
"dynamocomponent:MyService2"
,
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
Envs
:
[]
corev1
.
EnvVar
{
{
Name
:
"DYN_DEPLOYMENT_CONFIG"
,
Value
:
`{"service1":{"port":8080,"ServiceArgs":{"Workers":3, "Resources":{"CPU":"2", "Memory":"2Gi", "GPU":"2"}}}}`
,
},
},
ServiceName
:
"service1"
,
Replicas
:
&
[]
int32
{
10
}[
0
],
DynamoNamespace
:
&
[]
string
{
"default"
}[
0
],
ComponentType
:
"main"
,
Replicas
:
&
[]
int32
{
3
}[
0
],
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"2"
,
Memory
:
"2Gi"
,
GPU
:
"2"
,
Custom
:
map
[
string
]
string
{},
},
Limits
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"2"
,
Memory
:
"2Gi"
,
GPU
:
"2"
,
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
},
Autoscaling
:
&
v1alpha1
.
Autoscaling
{
Enabled
:
true
,
MinReplicas
:
1
,
MaxReplicas
:
5
,
},
ExternalServices
:
map
[
string
]
v1alpha1
.
ExternalService
{
"service2"
:
{
DeploymentSelectorKey
:
"dynamo"
,
DeploymentSelectorValue
:
"service2/default"
,
},
},
Ingress
:
v1alpha1
.
IngressSpec
{
Enabled
:
true
,
Host
:
"test-dynamographdeployment"
,
},
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"default"
,
},
Autoscaling
:
nil
,
ExtraPodSpec
:
&
compounaiCommon
.
ExtraPodSpec
{
MainContainer
:
&
corev1
.
Container
{
Command
:
[]
string
{
"sh"
,
"-c"
},
Args
:
[]
string
{
"echo hello world"
,
"sleep 99999"
},
},
},
},
Status
:
v1alpha1
.
DynamoComponentDeploymentStatus
{
Conditions
:
nil
,
PodSelector
:
nil
,
},
},
"service2"
:
{
...
...
@@ -1366,99 +656,23 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
},
},
Spec
:
v1alpha1
.
DynamoComponentDeploymentSpec
{
DynamoComponent
:
"dynamocomponent:ac4e234"
,
DynamoTag
:
"dynamocomponent:MyService2"
,
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
Envs
:
[]
corev1
.
EnvVar
{
{
Name
:
"DYN_DEPLOYMENT_CONFIG"
,
Value
:
`{"service1":{"port":8080,"ServiceArgs":{"Workers":3, "Resources":{"CPU":"2", "Memory":"2Gi", "GPU":"2"}}}}`
,
},
},
ServiceName
:
"service2"
,
DynamoNamespace
:
&
[]
string
{
"default"
}[
0
],
Autoscaling
:
&
v1alpha1
.
Autoscaling
{
Enabled
:
false
,
},
Replicas
:
&
[]
int32
{
3
}[
0
],
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service2"
,
commonconsts
.
KubeLabelDynamoNamespace
:
"default"
,
},
Ingress
:
v1alpha1
.
IngressSpec
{
Enabled
:
false
,
Host
:
""
,
UseVirtualService
:
false
,
VirtualServiceGateway
:
nil
,
HostPrefix
:
nil
,
Annotations
:
nil
,
Labels
:
nil
,
TLS
:
nil
,
HostSuffix
:
nil
,
IngressControllerClassName
:
nil
,
},
},
},
},
},
wantErr
:
false
,
},
{
name
:
"Test GenerateDynamoComponentsDeployments with ExtraPodSpec.MainContainer Command and Args"
,
args
:
args
{
parentDynamoGraphDeployment
:
&
v1alpha1
.
DynamoGraphDeployment
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test-dynamographdeployment"
,
Namespace
:
"default"
,
},
Spec
:
v1alpha1
.
DynamoGraphDeploymentSpec
{
DynamoGraph
:
"dynamocomponent:ac4e234"
,
},
},
config
:
&
DynamoGraphConfig
{
DynamoTag
:
"dynamocomponent:MyServiceWithOverrides"
,
Services
:
[]
ServiceConfig
{
{
Name
:
"service1"
,
Dependencies
:
[]
map
[
string
]
string
{},
Config
:
Config
{
ExtraPodSpec
:
&
compounaiCommon
.
ExtraPodSpec
{
MainContainer
:
&
corev1
.
Container
{
Command
:
[]
string
{
"sh"
,
"-c"
},
Args
:
[]
string
{
"echo hello world"
,
"sleep 99999"
},
},
},
},
},
},
},
ingressSpec
:
&
v1alpha1
.
IngressSpec
{},
},
want
:
map
[
string
]
*
v1alpha1
.
DynamoComponentDeployment
{
"service1"
:
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"test-dynamographdeployment-service1"
,
Namespace
:
"default"
,
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
},
},
Spec
:
v1alpha1
.
DynamoComponentDeploymentSpec
{
DynamoComponent
:
"dynamocomponent:ac4e234"
,
DynamoTag
:
"dynamocomponent:MyServiceWithOverrides"
,
DynamoComponentDeploymentSharedSpec
:
v1alpha1
.
DynamoComponentDeploymentSharedSpec
{
ServiceName
:
"service1"
,
Autoscaling
:
&
v1alpha1
.
Autoscaling
{
Enabled
:
false
,
},
Labels
:
map
[
string
]
string
{
commonconsts
.
KubeLabelDynamoComponent
:
"service1"
,
},
ExtraPodSpec
:
&
compounaiCommon
.
ExtraPodSpec
{
MainContainer
:
&
corev1
.
Container
{
Command
:
[]
string
{
"sh"
,
"-c"
},
Args
:
[]
string
{
"echo hello world"
,
"sleep 99999"
},
Resources
:
&
compounaiCommon
.
Resources
{
Requests
:
&
compounaiCommon
.
ResourceItem
{
CPU
:
"1"
,
Memory
:
"1Gi"
,
GPU
:
"0"
,
Custom
:
map
[
string
]
string
{},
},
},
Autoscaling
:
nil
,
},
},
},
...
...
@@ -1468,7 +682,7 @@ func TestGenerateDynamoComponentsDeployments(t *testing.T) {
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
got
,
err
:=
GenerateDynamoComponentsDeployments
(
context
.
Background
(),
tt
.
args
.
parentDynamoGraphDeployment
,
tt
.
args
.
config
,
tt
.
args
.
ingressSpec
)
got
,
err
:=
GenerateDynamoComponentsDeployments
(
context
.
Background
(),
tt
.
args
.
parentDynamoGraphDeployment
,
tt
.
args
.
ingressSpec
)
if
(
err
!=
nil
)
!=
tt
.
wantErr
{
t
.
Errorf
(
"GenerateDynamoComponentsDeployments() error = %v, wantErr %v"
,
err
,
tt
.
wantErr
)
return
...
...
deploy/cloud/operator/internal/secrets/docker.go
0 → 100644
View file @
7a341f86
package
secrets
import
(
"context"
"encoding/json"
"fmt"
"sync"
"github.com/ai-dynamo/dynamo/deploy/cloud/operator/internal/common"
corev1
"k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)
type
DockerSecretIndexer
struct
{
// maps for a namespace, a docker registry server to a list of secret names
secrets
map
[
string
]
map
[
string
][]
string
client
client
.
Client
mu
sync
.
RWMutex
}
func
NewDockerSecretIndexer
(
client
client
.
Client
)
*
DockerSecretIndexer
{
return
&
DockerSecretIndexer
{
secrets
:
make
(
map
[
string
]
map
[
string
][]
string
),
client
:
client
,
}
}
func
(
i
*
DockerSecretIndexer
)
RefreshIndex
(
ctx
context
.
Context
)
error
{
// scan for all secrets in the namespace
secrets
:=
&
corev1
.
SecretList
{}
if
err
:=
i
.
client
.
List
(
ctx
,
secrets
);
err
!=
nil
{
return
fmt
.
Errorf
(
"unable to list secrets: %w"
,
err
)
}
tmpSecrets
:=
make
(
map
[
string
]
map
[
string
][]
string
)
for
_
,
secret
:=
range
secrets
.
Items
{
if
secret
.
Type
==
corev1
.
SecretTypeDockerConfigJson
{
// unmarshal the secret data
dockerConfig
:=
&
struct
{
Auths
map
[
string
]
any
`json:"auths"`
}{}
if
err
:=
json
.
Unmarshal
(
secret
.
Data
[
corev1
.
DockerConfigJsonKey
],
dockerConfig
);
err
!=
nil
{
return
fmt
.
Errorf
(
"unable to unmarshal docker config json for secret %s: %w"
,
secret
.
Name
,
err
)
}
namespace
:=
secret
.
Namespace
if
_
,
ok
:=
tmpSecrets
[
namespace
];
!
ok
{
tmpSecrets
[
namespace
]
=
make
(
map
[
string
][]
string
)
}
for
auth
:=
range
dockerConfig
.
Auths
{
// retrieve the registry host
registry
,
err
:=
common
.
GetHost
(
auth
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"unable to get host for registry %s for secret %s: %w"
,
auth
,
secret
.
Name
,
err
)
}
tmpSecrets
[
namespace
][
registry
]
=
append
(
tmpSecrets
[
namespace
][
registry
],
secret
.
Name
)
}
}
}
i
.
mu
.
Lock
()
defer
i
.
mu
.
Unlock
()
i
.
secrets
=
tmpSecrets
return
nil
}
func
(
i
*
DockerSecretIndexer
)
GetSecrets
(
namespace
,
registry
string
)
([]
string
,
error
)
{
registry
,
err
:=
common
.
GetHost
(
registry
)
if
err
!=
nil
{
return
nil
,
err
}
i
.
mu
.
RLock
()
defer
i
.
mu
.
RUnlock
()
return
i
.
secrets
[
namespace
][
registry
],
nil
}
deploy/cloud/operator/internal/secrets/docker_test.go
0 → 100644
View file @
7a341f86
package
secrets
import
(
"context"
"testing"
corev1
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/scheme"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)
func
TestDockerSecretIndexer_RefreshIndex
(
t
*
testing
.
T
)
{
// Create mock secrets
mockSecrets
:=
[]
corev1
.
Secret
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"secret1"
,
Namespace
:
"default"
,
},
Type
:
corev1
.
SecretTypeDockerConfigJson
,
Data
:
map
[
string
][]
byte
{
".dockerconfigjson"
:
[]
byte
(
`{"auths":{"docker.io":{}, "my-registry.com:5005/registry1":{}}}`
),
},
},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"secret2"
,
Namespace
:
"default"
,
},
Type
:
corev1
.
SecretTypeDockerConfigJson
,
Data
:
map
[
string
][]
byte
{
".dockerconfigjson"
:
[]
byte
(
`{"auths":{"my-registry.com:5005/registry2":{}}}`
),
},
},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"secret3"
,
Namespace
:
"another-namespace"
,
},
Type
:
corev1
.
SecretTypeDockerConfigJson
,
Data
:
map
[
string
][]
byte
{
".dockerconfigjson"
:
[]
byte
(
`{"auths":{"my-registry.com:5005/registry2":{}}}`
),
},
},
}
// Create fake client with mock secrets
fakeClient
:=
fake
.
NewClientBuilder
()
.
WithScheme
(
scheme
.
Scheme
)
.
WithObjects
(
&
mockSecrets
[
0
],
&
mockSecrets
[
1
],
&
mockSecrets
[
2
])
.
Build
()
i
:=
NewDockerSecretIndexer
(
fakeClient
)
if
err
:=
i
.
RefreshIndex
(
context
.
Background
());
err
!=
nil
{
t
.
Errorf
(
"DockerSecretIndexer.RefreshIndex() error = %v, wantErr %v"
,
err
,
nil
)
}
secrets
,
err
:=
i
.
GetSecrets
(
"default"
,
"docker.io"
)
if
err
!=
nil
{
t
.
Errorf
(
"DockerSecretIndexer.GetSecrets() error = %v, wantErr %v"
,
err
,
nil
)
}
if
len
(
secrets
)
!=
1
{
t
.
Errorf
(
"DockerSecretIndexer.GetSecrets() = %v, want %v"
,
len
(
secrets
),
1
)
}
if
secrets
[
0
]
!=
"secret1"
{
t
.
Errorf
(
"DockerSecretIndexer.GetSecrets() = %v, want %v"
,
secrets
[
0
],
"secret1"
)
}
secrets
,
err
=
i
.
GetSecrets
(
"default"
,
"my-registry.com:5005"
)
if
err
!=
nil
{
t
.
Errorf
(
"DockerSecretIndexer.GetSecrets() error = %v, wantErr %v"
,
err
,
nil
)
}
if
len
(
secrets
)
!=
2
{
t
.
Errorf
(
"DockerSecretIndexer.GetSecrets() = %v, want %v"
,
len
(
secrets
),
2
)
}
if
secrets
[
0
]
!=
"secret1"
{
t
.
Errorf
(
"DockerSecretIndexer.GetSecrets() = %v, want %v"
,
secrets
[
0
],
"secret1"
)
}
if
secrets
[
1
]
!=
"secret2"
{
t
.
Errorf
(
"DockerSecretIndexer.GetSecrets() = %v, want %v"
,
secrets
[
1
],
"secret2"
)
}
secrets
,
err
=
i
.
GetSecrets
(
"another-namespace"
,
"my-registry.com:5005"
)
if
err
!=
nil
{
t
.
Errorf
(
"DockerSecretIndexer.GetSecrets() error = %v, wantErr %v"
,
err
,
nil
)
}
if
len
(
secrets
)
!=
1
{
t
.
Errorf
(
"DockerSecretIndexer.GetSecrets() = %v, want %v"
,
len
(
secrets
),
1
)
}
if
secrets
[
0
]
!=
"secret3"
{
t
.
Errorf
(
"DockerSecretIndexer.GetSecrets() = %v, want %v"
,
secrets
[
0
],
"secret3"
)
}
}
pyproject.toml
View file @
7a341f86
...
...
@@ -138,7 +138,6 @@ addopts = [
"--mypy"
,
"--ignore-glob=*model.py"
,
"--ignore-glob=*_inc.py"
,
"--ignore-glob=deploy/cloud/api-store/*"
,
"--ignore-glob=*/llm/tensorrtllm*"
,
"--ignore-glob=docs/*"
,
# FIXME: Get relative/generic blob paths to work here
...
...
Prev
1
2
3
4
5
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment