-
Notifications
You must be signed in to change notification settings - Fork 9
/
configurations.go
67 lines (59 loc) · 2.36 KB
/
configurations.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* Copyright (C) 2022 Appvia Ltd <info@appvia.io>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fixtures
import (
"fmt"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
terraformv1alpha1 "github.com/appvia/terranetes-controller/pkg/apis/terraform/v1alpha1"
)
// NewValidBucketConfiguration returns a valid configuration for aws bucket
func NewValidBucketConfiguration(namespace, name string) *terraformv1alpha1.Configuration {
config := &terraformv1alpha1.Configuration{}
config.Annotations = map[string]string{}
config.Namespace = namespace
config.UID = types.UID("1234-122-1234-1234")
config.Name = name
config.Spec = terraformv1alpha1.ConfigurationSpec{
Module: "https://github.com/terraform-aws-modules/terraform-aws-s3-bucket.git",
ProviderRef: &terraformv1alpha1.ProviderReference{Name: "aws"},
Variables: &runtime.RawExtension{
Raw: []byte(`{"name": "test"}`),
},
WriteConnectionSecretToRef: &terraformv1alpha1.WriteConnectionSecret{
Name: "aws-secret",
},
}
return config
}
// NewConfigurationPodWatcher returns a new configuration pod
func NewConfigurationPodWatcher(resource client.Object, stage string) *v1.Pod {
pod := &v1.Pod{}
pod.Namespace = resource.GetNamespace()
pod.Name = "test-configuration-1234"
pod.Labels = map[string]string{
terraformv1alpha1.ConfigurationGenerationLabel: fmt.Sprintf("%d", resource.GetGeneration()),
terraformv1alpha1.ConfigurationNameLabel: resource.GetName(),
terraformv1alpha1.ConfigurationStageLabel: stage,
terraformv1alpha1.ConfigurationUIDLabel: string(resource.GetUID()),
}
pod.Status.Phase = v1.PodSucceeded
pod.Spec.Containers = []v1.Container{{Name: "terraform"}}
return pod
}