diff --git a/.gitignore b/.gitignore index c9f550f4..047a88e1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ __debug* .vscode .idea adhar -.history \ No newline at end of file +.history +.lsp/.cache/db.transit.json diff --git a/.lsp/.cache/db.transit.json b/.lsp/.cache/db.transit.json index 193845aa..b031471a 100644 --- a/.lsp/.cache/db.transit.json +++ b/.lsp/.cache/db.transit.json @@ -1 +1 @@ -["^ ","~:classpath",["~#set",[]],"~:project-hash","","~:project-root","/Users/tapas-pc/Documents/Work/Adhar/AdharWS/adhar","~:kondo-config-hash","b18d1aa6389a0016f7344c84c6dca52a5f83566473c6cfe1da6a46ecc1ecbd6e","~:dependency-scheme","jar","~:analysis",null,"~:analysis-checksums",["^ "],"~:project-analysis-type","~:project-and-full-dependencies","~:version",12,"~:stubs-generation-namespaces",["^1",[]]] \ No newline at end of file +["^ ","~:classpath",["~#set",[]],"~:project-hash","","~:project-root","/Users/tapas-pc/Documents/Work/Adhar/AdharWS/adhar","~:kondo-config-hash","909284ad5303cef2b91fa048de5dc6df67aaa9f8e6796afaa63365a8609c635f","~:dependency-scheme","jar","~:analysis",null,"~:analysis-checksums",["^ "],"~:project-analysis-type","~:project-and-full-dependencies","~:version",12,"~:stubs-generation-namespaces",["^1",[]]] \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4f7924f8..213e1f40 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -50,9 +50,9 @@ This command creates a kind cluster, expose associated endpoints to your local m They are deployed as ArgoCD Applications with the Gitea repositories set as their sources. UIs for Backstage, Gitea, and ArgoCD are accessible on the machine: -* Gitea: https://gitea.cnoe.localtest.me:8443/explore/repos -* Backstage: https://backstage.cnoe.localtest.me:8443/ -* ArgoCD: https://argocd.cnoe.localtest.me:8443/applications +* Gitea: https://gitea.adhar.localtest.me:8443/explore/repos +* Backstage: https://backstage.adhar.localtest.me:8443/ +* ArgoCD: https://argocd.adhar.localtest.me:8443/applications #### Getting credentials for packages diff --git a/api/v1alpha1/localbuild_types.go b/api/v1alpha1/localbuild_types.go index 94898aeb..05da5b02 100644 --- a/api/v1alpha1/localbuild_types.go +++ b/api/v1alpha1/localbuild_types.go @@ -45,8 +45,19 @@ type PackageConfigsSpec struct { CorePackageCustomization map[string]PackageCustomization `json:"packageCustomization,omitempty"` } +// BuildCustomizationSpec fields cannot change once a cluster is created +type BuildCustomizationSpec struct { + Protocol string `json:"protocol,omitempty"` + Host string `json:"host,omitempty"` + IngressHost string `json:"ingressHost,omitempty"` + Port string `json:"port,omitempty"` + UsePathRouting bool `json:"usePathRouting,omitempty"` + SelfSignedCert string `json:"selfSignedCert,omitempty"` +} + type LocalbuildSpec struct { - PackageConfigs PackageConfigsSpec `json:"packageConfigs,omitempty"` + PackageConfigs PackageConfigsSpec `json:"packageConfigs,omitempty"` + BuildCustomization BuildCustomizationSpec `json:"buildCustomization,omitempty"` } // PackageCustomization defines how packages are customized diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index db881cb3..9ef62b7c 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -69,6 +69,21 @@ func (in *ArgoPackageConfigSpec) DeepCopy() *ArgoPackageConfigSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BuildCustomizationSpec) DeepCopyInto(out *BuildCustomizationSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildCustomizationSpec. +func (in *BuildCustomizationSpec) DeepCopy() *BuildCustomizationSpec { + if in == nil { + return nil + } + out := new(BuildCustomizationSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Commit) DeepCopyInto(out *Commit) { *out = *in @@ -384,6 +399,7 @@ func (in *LocalbuildList) DeepCopyObject() runtime.Object { func (in *LocalbuildSpec) DeepCopyInto(out *LocalbuildSpec) { *out = *in in.PackageConfigs.DeepCopyInto(&out.PackageConfigs) + out.BuildCustomization = in.BuildCustomization } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LocalbuildSpec. diff --git a/go.mod b/go.mod index ebd34b9d..d1c6cd99 100644 --- a/go.mod +++ b/go.mod @@ -5,10 +5,10 @@ go 1.22.0 require ( code.gitea.io/sdk/gitea v0.16.0 github.com/cnoe-io/argocd-api v0.0.0-20240530220153-91a5bf06f21d - github.com/docker/docker v24.0.9+incompatible + github.com/docker/docker v25.0.6+incompatible github.com/go-git/go-billy/v5 v5.5.0 github.com/go-git/go-git/v5 v5.12.0 - github.com/go-logr/logr v1.4.1 + github.com/go-logr/logr v1.4.2 github.com/google/go-cmp v0.6.0 github.com/google/go-github/v61 v61.0.0 github.com/spf13/cobra v1.8.0 @@ -31,22 +31,25 @@ require ( github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/alessio/shellescape v1.4.1 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cloudflare/circl v1.3.7 // indirect + github.com/containerd/log v0.1.0 // indirect github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/davidmz/go-pageant v1.0.2 // indirect - github.com/docker/distribution v2.8.2+incompatible // indirect + github.com/distribution/reference v0.6.0 // indirect github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/evanphx/json-patch v5.7.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.8.0 // indirect + github.com/felixge/httpsnoop v1.0.3 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-errors/errors v1.4.2 // indirect github.com/go-fed/httpsig v1.1.0 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect + github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect github.com/go-openapi/jsonreference v0.21.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect @@ -94,21 +97,27 @@ require ( github.com/stretchr/objx v0.5.2 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xlab/treeprint v1.2.0 // indirect - golang.org/x/crypto v0.21.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.44.0 // indirect + go.opentelemetry.io/otel v1.31.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 // indirect + go.opentelemetry.io/otel/metric v1.31.0 // indirect + go.opentelemetry.io/otel/sdk v1.31.0 // indirect + go.opentelemetry.io/otel/trace v1.31.0 // indirect + golang.org/x/crypto v0.28.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect - golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/oauth2 v0.16.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/term v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/net v0.30.0 // indirect + golang.org/x/oauth2 v0.22.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/term v0.25.0 // indirect + golang.org/x/text v0.19.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.17.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect - google.golang.org/grpc v1.62.0 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 // indirect + google.golang.org/grpc v1.67.1 // indirect + google.golang.org/protobuf v1.35.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect @@ -119,4 +128,4 @@ require ( k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect -) \ No newline at end of file +) diff --git a/go.sum b/go.sum index 73c2398c..822e294f 100644 --- a/go.sum +++ b/go.sum @@ -20,13 +20,17 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkY github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/cnoe-io/argocd-api v0.0.0-20240530220153-91a5bf06f21d h1:rJ1qqRUpEnF8ch+0izhYKnCKdatykDJCmpW0eff7Sxg= github.com/cnoe-io/argocd-api v0.0.0-20240530220153-91a5bf06f21d/go.mod h1:vc5mQ/ctD9dFYbWrYHyOclTdbbYU5p+QoFgJBG21RQQ= +github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= +github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= @@ -35,10 +39,10 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davidmz/go-pageant v1.0.2 h1:bPblRCh5jGU+Uptpz6LgMZGD5hJoOt7otgT454WvHn0= github.com/davidmz/go-pageant v1.0.2/go.mod h1:P2EDDnMqIwG5Rrp05dTRITj9z2zpGcD9efWSkTNKLIE= -github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= -github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v24.0.9+incompatible h1:HPGzNmwfLZWdxHqK9/II92pyi1EpYKsAqcl4G0Of9v0= -github.com/docker/docker v24.0.9+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= +github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= +github.com/docker/docker v25.0.6+incompatible h1:5cPwbwriIcsua2REJe8HqQV+6WlWc1byg2QSXzBxBGg= +github.com/docker/docker v25.0.6+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -53,6 +57,8 @@ github.com/evanphx/json-patch v5.7.0+incompatible h1:vgGkfT/9f8zE6tvSCe74nfpAVDQ github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.8.0 h1:lRj6N9Nci7MvzrXuX6HFzU8XjmhPiXPlsKEy1u0KQro= github.com/evanphx/json-patch/v5 v5.8.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= +github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= +github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= @@ -69,8 +75,11 @@ github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMj github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= @@ -85,14 +94,11 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -109,6 +115,9 @@ github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 h1:SJ+NtwL6QaZ21U+ github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2/go.mod h1:Tv1PlzqC9t8wNnpPdctvtSUOPUUg4SHeE6vR1Ir2hmg= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I= github.com/hashicorp/go-version v1.5.0 h1:O293SZ2Eg+AAYijkVK3jR786Am1bhDEh2GHT0tIVE5E= github.com/hashicorp/go-version v1.5.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= @@ -205,6 +214,22 @@ github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.44.0 h1:KfYpVmrjI7JuToy5k8XV3nkapjWx48k4E4JOtVstzQI= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.44.0/go.mod h1:SeQhzAEccGVZVEy7aH87Nh0km+utSpo1pTv6eMMop48= +go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY= +go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 h1:K0XaT3DwHAcV4nKLzcQvwAgSyisUghWoY20I7huthMk= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0/go.mod h1:B5Ki776z/MBnVha1Nzwp5arlzBbE3+1jk+pGmaP5HME= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 h1:lUsI2TYsQw2r1IASwoROaCnjdj2cvC2+Jbxvk6nHnWU= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0/go.mod h1:2HpZxxQurfGxJlJDblybejHB6RX6pmExPNe517hREw4= +go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE= +go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY= +go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk= +go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0= +go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys= +go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A= +go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= +go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -220,16 +245,16 @@ golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -240,17 +265,17 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= -golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= +golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -266,25 +291,24 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= -golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= +golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -293,24 +317,23 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= -google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= -google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk= -google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 h1:L6iMMGrtzgHsWofoFcihmDEMYeDR9KN/ThbPWGrh++g= +google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 h1:T6rh4haD3GVYsgEfWExoCZA2o2FmbNyKpTuAxbEFPTg= +google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9/go.mod h1:wp2WsuBYj6j8wUdo3ToZsdxxixbvQNAHqVJrTgi5E5M= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 h1:QCqS/PdaHTSWGvupk2F/ehwHtGc0/GYkT+3GAcR1CCc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/pkg/build/build.go b/pkg/build/build.go index 954a231b..34293b4e 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -10,7 +10,7 @@ import ( "github.com/adhar-io/adhar/globals" "github.com/adhar-io/adhar/pkg/controllers" "github.com/adhar-io/adhar/pkg/kind" - "github.com/adhar-io/adhar/pkg/util" + k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/rest" @@ -28,7 +28,7 @@ var ( type Build struct { name string - cfg util.CorePackageTemplateConfig + cfg v1alpha1.BuildCustomizationSpec kindConfigPath string kubeConfigPath string kubeVersion string @@ -43,7 +43,7 @@ type Build struct { type NewBuildOptions struct { Name string - TemplateData util.CorePackageTemplateConfig + TemplateData v1alpha1.BuildCustomizationSpec KindConfigPath string KubeConfigPath string KubeVersion string @@ -126,6 +126,36 @@ func (b *Build) RunControllers(ctx context.Context, mgr manager.Manager, exitCh return controllers.RunControllers(ctx, mgr, exitCh, b.CancelFunc, b.exitOnSync, b.cfg, tmpDir) } +func (b *Build) isCompatible(ctx context.Context, kubeClient client.Client) (bool, error) { + localBuild := v1alpha1.Localbuild{ + ObjectMeta: metav1.ObjectMeta{ + Name: b.name, + }, + } + + err := kubeClient.Get(ctx, client.ObjectKeyFromObject(&localBuild), &localBuild) + if err != nil { + if k8serrors.IsNotFound(err) { + return true, nil + } + return false, err + } + + ok := isBuildCustomizationSpecEqual(b.cfg, localBuild.Spec.BuildCustomization) + + if ok { + return ok, nil + } + + existing, given := localBuild.Spec.BuildCustomization, b.cfg + existing.SelfSignedCert = "" + given.SelfSignedCert = "" + + return false, fmt.Errorf("provided command flags and existing configurations are incompatible. please recreate the cluster. "+ + "existing: %+v, given: %+v", + existing, given) +} + func (b *Build) Run(ctx context.Context, recreateCluster bool) error { managerExit := make(chan error) @@ -185,6 +215,16 @@ func (b *Build) Run(ctx context.Context, recreateCluster bool) error { } b.cfg.SelfSignedCert = string(cert) + setupLog.V(1).Info("Checking for incompatible options from a previous run") + ok, err := b.isCompatible(ctx, kubeClient) + if err != nil { + setupLog.Error(err, "Error while checking incompatible flags") + return err + } + if !ok { + return err + } + setupLog.V(1).Info("Running controllers") if err := b.RunControllers(ctx, mgr, managerExit, dir); err != nil { setupLog.Error(err, "Error running controllers") @@ -206,6 +246,7 @@ func (b *Build) Run(ctx context.Context, recreateCluster bool) error { } localBuild.ObjectMeta.Annotations[v1alpha1.CliStartTimeAnnotation] = cliStartTime localBuild.Spec = v1alpha1.LocalbuildSpec{ + BuildCustomization: b.cfg, PackageConfigs: v1alpha1.PackageConfigsSpec{ Argo: v1alpha1.ArgoPackageConfigSpec{ Enabled: true, @@ -229,3 +270,13 @@ func (b *Build) Run(ctx context.Context, recreateCluster bool) error { close(managerExit) return err } + +func isBuildCustomizationSpecEqual(s1, s2 v1alpha1.BuildCustomizationSpec) bool { + // probably ok to use cmp.Equal but keeping it simple for now + return s1.Protocol == s2.Protocol && + s1.Host == s2.Host && + s1.IngressHost == s2.IngressHost && + s1.Port == s2.Port && + s1.UsePathRouting == s2.UsePathRouting && + s1.SelfSignedCert == s2.SelfSignedCert +} diff --git a/pkg/build/build_test.go b/pkg/build/build_test.go new file mode 100644 index 00000000..e36dfff2 --- /dev/null +++ b/pkg/build/build_test.go @@ -0,0 +1,67 @@ +package build + +import ( + "context" + "testing" + + "github.com/adhar-io/adhar/api/v1alpha1" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + k8serrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +func TestIsCompatible(t *testing.T) { + cfg := v1alpha1.BuildCustomizationSpec{ + Protocol: "http", + Host: "adhar.localtest.me", + IngressHost: "string", + Port: "8443", + UsePathRouting: false, + SelfSignedCert: "some-cert", + } + + b := Build{ + name: "test", + cfg: cfg, + } + + ctx := context.Background() + fClient := new(fakeKubeClient) + fClient.On("Get", ctx, client.ObjectKey{Name: "test"}, mock.Anything, mock.Anything).Run(func(args mock.Arguments) { + arg := args.Get(2).(*v1alpha1.Localbuild) + arg.Spec.BuildCustomization = cfg + }).Return(nil) + + ok, err := b.isCompatible(ctx, fClient) + + assert.NoError(t, err) + fClient.AssertExpectations(t) + require.True(t, ok) + + fClient = new(fakeKubeClient) + fClient.On("Get", ctx, client.ObjectKey{Name: "test"}, mock.Anything, mock.Anything).Run(func(args mock.Arguments) { + arg := args.Get(2).(*v1alpha1.Localbuild) + c := cfg + c.Host = "not-right" + arg.Spec.BuildCustomization = c + }).Return(nil) + + ok, err = b.isCompatible(ctx, fClient) + + assert.Error(t, err) + fClient.AssertExpectations(t) + require.False(t, ok) + + fClient = new(fakeKubeClient) + fClient.On("Get", ctx, client.ObjectKey{Name: "test"}, mock.Anything, mock.Anything). + Return(k8serrors.NewNotFound(schema.GroupResource{}, "name")) + + ok, err = b.isCompatible(ctx, fClient) + + assert.NoError(t, err) + fClient.AssertExpectations(t) + require.True(t, ok) +} diff --git a/pkg/build/coredns.go b/pkg/build/coredns.go index 3ccc2453..21279feb 100644 --- a/pkg/build/coredns.go +++ b/pkg/build/coredns.go @@ -5,8 +5,8 @@ import ( "embed" "fmt" + "github.com/adhar-io/adhar/api/v1alpha1" "github.com/adhar-io/adhar/pkg/k8s" - "github.com/adhar-io/adhar/pkg/util" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -22,7 +22,7 @@ const ( //go:embed templates var templates embed.FS -func setupCoreDNS(ctx context.Context, kubeClient client.Client, scheme *runtime.Scheme, templateData util.CorePackageTemplateConfig) error { +func setupCoreDNS(ctx context.Context, kubeClient client.Client, scheme *runtime.Scheme, templateData v1alpha1.BuildCustomizationSpec) error { checkCM := &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: "coredns-conf-default", diff --git a/pkg/build/templates/coredns/cm-coredns-default.yaml.tmpl b/pkg/build/templates/coredns/cm-coredns-default.yaml.tmpl index 5c9f0f3f..f9f12dad 100644 --- a/pkg/build/templates/coredns/cm-coredns-default.yaml.tmpl +++ b/pkg/build/templates/coredns/cm-coredns-default.yaml.tmpl @@ -7,7 +7,7 @@ data: default.conf: | # Goal: Rewrite rules for in-cluster access to a service: gitea, argocd, etc using the same FQDN as for external access - # subdomain names e.g. gitea.cnoe.localtest.me resolves to the IP address of the kubernetes ingress service and then will become ingress-nginx-controller.ingress-nginx.svc.cluster.local + # subdomain names e.g. gitea.adhar.localtest.me resolves to the IP address of the kubernetes ingress service and then will become ingress-nginx-controller.ingress-nginx.svc.cluster.local rewrite stop { name regex (.*).{{ .Host }} ingress-nginx-controller.ingress-nginx.svc.cluster.local answer auto } diff --git a/pkg/build/tls.go b/pkg/build/tls.go index 3b08c37d..4380c232 100644 --- a/pkg/build/tls.go +++ b/pkg/build/tls.go @@ -14,9 +14,9 @@ import ( "math/big" "time" + "github.com/adhar-io/adhar/api/v1alpha1" "github.com/adhar-io/adhar/globals" "github.com/adhar-io/adhar/pkg/k8s" - "github.com/adhar-io/adhar/pkg/util" "github.com/go-logr/logr" corev1 "k8s.io/api/core/v1" k8serrors "k8s.io/apimachinery/pkg/api/errors" @@ -182,7 +182,7 @@ func createSelfSignedCertificate(sans []string) ([]byte, []byte, error) { return certOut, privateKeyOut, nil } -func setupSelfSignedCertificate(ctx context.Context, logger logr.Logger, kubeclient client.Client, config util.CorePackageTemplateConfig) ([]byte, error) { +func setupSelfSignedCertificate(ctx context.Context, logger logr.Logger, kubeclient client.Client, config v1alpha1.BuildCustomizationSpec) ([]byte, error) { if err := k8s.EnsureNamespace(ctx, kubeclient, globals.NginxNamespace); err != nil { return nil, err } diff --git a/pkg/cmd/create/root.go b/pkg/cmd/create/root.go index 28ce7e86..e5f2983a 100644 --- a/pkg/cmd/create/root.go +++ b/pkg/cmd/create/root.go @@ -12,7 +12,6 @@ import ( "github.com/adhar-io/adhar/pkg/build" "github.com/adhar-io/adhar/pkg/cmd/helpers" "github.com/adhar-io/adhar/pkg/k8s" - "github.com/adhar-io/adhar/pkg/util" "github.com/spf13/cobra" "k8s.io/client-go/util/homedir" ctrl "sigs.k8s.io/controller-runtime" @@ -120,7 +119,7 @@ func create(cmd *cobra.Command, args []string) error { KindConfigPath: kindConfigPath, ExtraPortsMapping: extraPortsMapping, - TemplateData: util.CorePackageTemplateConfig{ + TemplateData: v1alpha1.BuildCustomizationSpec{ Protocol: protocol, Host: host, IngressHost: ingressHost, diff --git a/pkg/controllers/custompackage/controller.go b/pkg/controllers/custompackage/controller.go index 2a390887..a40df010 100644 --- a/pkg/controllers/custompackage/controller.go +++ b/pkg/controllers/custompackage/controller.go @@ -32,7 +32,7 @@ type Reconciler struct { client.Client Recorder record.EventRecorder Scheme *runtime.Scheme - Config util.CorePackageTemplateConfig + Config v1alpha1.BuildCustomizationSpec TempDir string RepoMap *util.RepoMap } diff --git a/pkg/controllers/gitrepository/controller.go b/pkg/controllers/gitrepository/controller.go index c05ee4ef..2989edcc 100644 --- a/pkg/controllers/gitrepository/controller.go +++ b/pkg/controllers/gitrepository/controller.go @@ -43,13 +43,13 @@ type RepositoryReconciler struct { client.Client Recorder record.EventRecorder Scheme *runtime.Scheme - Config util.CorePackageTemplateConfig + Config v1alpha1.BuildCustomizationSpec GitProviderFunc gitProviderFunc TempDir string RepoMap *util.RepoMap } -type gitProviderFunc func(context.Context, *v1alpha1.GitRepository, client.Client, *runtime.Scheme, util.CorePackageTemplateConfig) (gitProvider, error) +type gitProviderFunc func(context.Context, *v1alpha1.GitRepository, client.Client, *runtime.Scheme, v1alpha1.BuildCustomizationSpec) (gitProvider, error) type notFoundError struct{} @@ -69,7 +69,7 @@ func getFallbackRepositoryURL(repo *v1alpha1.GitRepository, info repoInfo) strin return fmt.Sprintf("%s/%s.git", repo.Spec.Provider.GitURL, info.fullName) } -func GetGitProvider(ctx context.Context, repo *v1alpha1.GitRepository, kubeClient client.Client, scheme *runtime.Scheme, tmplConfig util.CorePackageTemplateConfig) (gitProvider, error) { +func GetGitProvider(ctx context.Context, repo *v1alpha1.GitRepository, kubeClient client.Client, scheme *runtime.Scheme, tmplConfig v1alpha1.BuildCustomizationSpec) (gitProvider, error) { switch repo.Spec.Provider.Name { case v1alpha1.GitProviderGitea: giteaClient, err := NewGiteaClient(repo.Spec.Provider.GitURL, gitea.SetHTTPClient(util.GetHttpClient())) @@ -227,7 +227,7 @@ func pushToRemote(ctx context.Context, remoteRepo *git.Repository, creds gitProv } // add files from local fs to target repository (gitea for now) -func reconcileLocalRepoContent(ctx context.Context, repo *v1alpha1.GitRepository, tgtRepo repoInfo, creds gitProviderCredentials, scheme *runtime.Scheme, tmplConfig util.CorePackageTemplateConfig, tmpDir string, repoMap *util.RepoMap) error { +func reconcileLocalRepoContent(ctx context.Context, repo *v1alpha1.GitRepository, tgtRepo repoInfo, creds gitProviderCredentials, scheme *runtime.Scheme, tmplConfig v1alpha1.BuildCustomizationSpec, tmpDir string, repoMap *util.RepoMap) error { logger := log.FromContext(ctx) tgtCloneDir := util.RepoDir(tgtRepo.cloneUrl, tmpDir) diff --git a/pkg/controllers/gitrepository/controller_test.go b/pkg/controllers/gitrepository/controller_test.go index bb37b8fb..0a931472 100644 --- a/pkg/controllers/gitrepository/controller_test.go +++ b/pkg/controllers/gitrepository/controller_test.go @@ -63,7 +63,7 @@ type testCase struct { expect expect } -func (t testCase) giteaProvider(ctx context.Context, repo *v1alpha1.GitRepository, kubeClient client.Client, scheme *runtime.Scheme, tmplConfig util.CorePackageTemplateConfig) (gitProvider, error) { +func (t testCase) giteaProvider(ctx context.Context, repo *v1alpha1.GitRepository, kubeClient client.Client, scheme *runtime.Scheme, tmplConfig v1alpha1.BuildCustomizationSpec) (gitProvider, error) { return &giteaProvider{ Client: kubeClient, Scheme: scheme, diff --git a/pkg/controllers/gitrepository/gitea.go b/pkg/controllers/gitrepository/gitea.go index 37283fe3..16593fac 100644 --- a/pkg/controllers/gitrepository/gitea.go +++ b/pkg/controllers/gitrepository/gitea.go @@ -28,7 +28,7 @@ type giteaProvider struct { client.Client Scheme *runtime.Scheme giteaClient GiteaClient - config util.CorePackageTemplateConfig + config v1alpha1.BuildCustomizationSpec } func (g *giteaProvider) createRepository(ctx context.Context, repo *v1alpha1.GitRepository) (repoInfo, error) { @@ -116,7 +116,7 @@ func (g *giteaProvider) updateRepoContent( } } -func writeRepoContents(repo *v1alpha1.GitRepository, dstPath string, config util.CorePackageTemplateConfig, scheme *runtime.Scheme) error { +func writeRepoContents(repo *v1alpha1.GitRepository, dstPath string, config v1alpha1.BuildCustomizationSpec, scheme *runtime.Scheme) error { if repo.Spec.Source.EmbeddedAppName != "" { resources, err := localbuild.GetEmbeddedRawInstallResources( repo.Spec.Source.EmbeddedAppName, config, diff --git a/pkg/controllers/gitrepository/github.go b/pkg/controllers/gitrepository/github.go index 586b1ec2..ed76c7a4 100644 --- a/pkg/controllers/gitrepository/github.go +++ b/pkg/controllers/gitrepository/github.go @@ -39,7 +39,7 @@ type gitHubProvider struct { client.Client Scheme *runtime.Scheme gitHubClient gitHubClient - config util.CorePackageTemplateConfig + config v1alpha1.BuildCustomizationSpec } func (g *gitHubProvider) createRepository(ctx context.Context, repo *v1alpha1.GitRepository) (repoInfo, error) { diff --git a/pkg/controllers/localbuild/argo_test.go b/pkg/controllers/localbuild/argo_test.go index cd9e833c..28c009da 100644 --- a/pkg/controllers/localbuild/argo_test.go +++ b/pkg/controllers/localbuild/argo_test.go @@ -44,7 +44,7 @@ func TestGetRawInstallResources(t *testing.T) { resourcePath: "resources/argo", } resources, err := util.ConvertFSToBytes(e.resourceFS, e.resourcePath, - util.CorePackageTemplateConfig{ + v1alpha1.BuildCustomizationSpec{ Protocol: "", Host: "", Port: "", @@ -70,7 +70,7 @@ func TestGetK8sInstallResources(t *testing.T) { resourceFS: installArgoFS, resourcePath: "resources/argo", } - objs, err := e.installResources(k8s.GetScheme(), util.CorePackageTemplateConfig{ + objs, err := e.installResources(k8s.GetScheme(), v1alpha1.BuildCustomizationSpec{ Protocol: "", Host: "", Port: "", diff --git a/pkg/controllers/localbuild/controller.go b/pkg/controllers/localbuild/controller.go index f425f5fe..86b45a56 100644 --- a/pkg/controllers/localbuild/controller.go +++ b/pkg/controllers/localbuild/controller.go @@ -46,7 +46,7 @@ type LocalbuildReconciler struct { CancelFunc context.CancelFunc ExitOnSync bool shouldShutdown bool - Config util.CorePackageTemplateConfig + Config v1alpha1.BuildCustomizationSpec TempDir string RepoMap *util.RepoMap } diff --git a/pkg/controllers/localbuild/gitea.go b/pkg/controllers/localbuild/gitea.go index 741c36c8..759ca8c1 100644 --- a/pkg/controllers/localbuild/gitea.go +++ b/pkg/controllers/localbuild/gitea.go @@ -210,12 +210,12 @@ func getGiteaToken(ctx context.Context, baseUrl, username, password string) (str return token.Token, nil } -func giteaBaseUrl(config util.CorePackageTemplateConfig) string { +func giteaBaseUrl(config v1alpha1.BuildCustomizationSpec) string { return fmt.Sprintf(giteaIngressURL, config.Protocol, config.Port) } // gitea URL reachable within the cluster with proper coredns config. Mainly for argocd -func giteaInternalBaseUrl(config util.CorePackageTemplateConfig) string { +func giteaInternalBaseUrl(config v1alpha1.BuildCustomizationSpec) string { if config.UsePathRouting { return fmt.Sprintf(giteaSvcURL, config.Protocol, "", config.Host, config.Port, "/gitea") } diff --git a/pkg/controllers/localbuild/gitea_test.go b/pkg/controllers/localbuild/gitea_test.go index 35aefabd..0df2cf53 100644 --- a/pkg/controllers/localbuild/gitea_test.go +++ b/pkg/controllers/localbuild/gitea_test.go @@ -3,12 +3,12 @@ package localbuild import ( "testing" - "github.com/adhar-io/adhar/pkg/util" + "github.com/adhar-io/adhar/api/v1alpha1" "github.com/stretchr/testify/assert" ) func TestGiteaInternalBaseUrl(t *testing.T) { - c := util.CorePackageTemplateConfig{ + c := v1alpha1.BuildCustomizationSpec{ Protocol: "http", Port: "8080", Host: "adhar.localtest.me", diff --git a/pkg/controllers/localbuild/installer.go b/pkg/controllers/localbuild/installer.go index 3a873fca..2b31c03e 100644 --- a/pkg/controllers/localbuild/installer.go +++ b/pkg/controllers/localbuild/installer.go @@ -10,7 +10,6 @@ import ( "github.com/adhar-io/adhar/api/v1alpha1" "github.com/adhar-io/adhar/pkg/k8s" - "github.com/adhar-io/adhar/pkg/util" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -53,7 +52,7 @@ func (e *EmbeddedInstallation) newNamespace(namespace string) *corev1.Namespace } } -func (e *EmbeddedInstallation) Install(ctx context.Context, resource *v1alpha1.Localbuild, cli client.Client, sc *runtime.Scheme, cfg util.CorePackageTemplateConfig) (ctrl.Result, error) { +func (e *EmbeddedInstallation) Install(ctx context.Context, resource *v1alpha1.Localbuild, cli client.Client, sc *runtime.Scheme, cfg v1alpha1.BuildCustomizationSpec) (ctrl.Result, error) { logger := log.FromContext(ctx) nsClient := client.NewNamespacedClient(cli, e.namespace) diff --git a/pkg/controllers/resources/idpbuilder.cnoe.io_localbuilds.yaml b/pkg/controllers/resources/idpbuilder.cnoe.io_localbuilds.yaml index 0aca820d..ab98210f 100644 --- a/pkg/controllers/resources/idpbuilder.cnoe.io_localbuilds.yaml +++ b/pkg/controllers/resources/idpbuilder.cnoe.io_localbuilds.yaml @@ -37,6 +37,23 @@ spec: type: object spec: properties: + buildCustomization: + description: BuildCustomizationSpec fields cannot change once a cluster + is created + properties: + host: + type: string + ingressHost: + type: string + port: + type: string + protocol: + type: string + selfSignedCert: + type: string + usePathRouting: + type: boolean + type: object packageConfigs: properties: argoPackageConfigs: diff --git a/pkg/controllers/run.go b/pkg/controllers/run.go index a4f4d042..4a7eca0a 100644 --- a/pkg/controllers/run.go +++ b/pkg/controllers/run.go @@ -3,6 +3,7 @@ package controllers import ( "context" + "github.com/adhar-io/adhar/api/v1alpha1" "github.com/adhar-io/adhar/pkg/controllers/custompackage" "github.com/adhar-io/adhar/pkg/util" @@ -18,7 +19,7 @@ func RunControllers( exitCh chan error, ctxCancel context.CancelFunc, exitOnSync bool, - cfg util.CorePackageTemplateConfig, + cfg v1alpha1.BuildCustomizationSpec, tmpDir string, ) error { logger := log.FromContext(ctx) diff --git a/pkg/k8s/util_test.go b/pkg/k8s/util_test.go index 4ec16b87..e62b8929 100644 --- a/pkg/k8s/util_test.go +++ b/pkg/k8s/util_test.go @@ -6,7 +6,7 @@ import ( "os" "testing" - "github.com/adhar-io/adhar/pkg/util" + "github.com/adhar-io/adhar/api/v1alpha1" "github.com/stretchr/testify/assert" ) @@ -38,7 +38,7 @@ func TestBuildCustomizedManifests(t *testing.T) { for key := range cases { c := cases[key] - b, err := BuildCustomizedManifests(c.filePath, c.fsPath, testDataFS, GetScheme(), util.CorePackageTemplateConfig{ + b, err := BuildCustomizedManifests(c.filePath, c.fsPath, testDataFS, GetScheme(), v1alpha1.BuildCustomizationSpec{ Protocol: "http", Host: "adhar.localtest.me", IngressHost: "localhost", diff --git a/pkg/kind/cluster.go b/pkg/kind/cluster.go index 83a893f4..b4b8f07e 100644 --- a/pkg/kind/cluster.go +++ b/pkg/kind/cluster.go @@ -9,6 +9,7 @@ import ( "strconv" "strings" + "github.com/adhar-io/adhar/api/v1alpha1" "github.com/adhar-io/adhar/pkg/runtime" "github.com/adhar-io/adhar/pkg/util" "sigs.k8s.io/controller-runtime/pkg/log" @@ -36,7 +37,7 @@ type Cluster struct { kubeConfigPath string kindConfigPath string extraPortsMapping string - cfg util.CorePackageTemplateConfig + cfg v1alpha1.BuildCustomizationSpec } type PortMapping struct { @@ -54,7 +55,7 @@ type IProvider interface { } type TemplateConfig struct { - util.CorePackageTemplateConfig + v1alpha1.BuildCustomizationSpec KubernetesVersion string ExtraPortsMapping []PortMapping } @@ -94,9 +95,9 @@ func (c *Cluster) getConfig() ([]byte, error) { var retBuff []byte if retBuff, err = util.ApplyTemplate(rawConfigTempl, TemplateConfig{ - CorePackageTemplateConfig: c.cfg, - KubernetesVersion: c.kubeVersion, - ExtraPortsMapping: portMappingPairs, + BuildCustomizationSpec: c.cfg, + KubernetesVersion: c.kubeVersion, + ExtraPortsMapping: portMappingPairs, }); err != nil { return nil, err } @@ -117,7 +118,7 @@ func (c *Cluster) getConfig() ([]byte, error) { return retBuff, nil } -func NewCluster(name, kubeVersion, kubeConfigPath, kindConfigPath, extraPortsMapping string, cfg util.CorePackageTemplateConfig) (*Cluster, error) { +func NewCluster(name, kubeVersion, kubeConfigPath, kindConfigPath, extraPortsMapping string, cfg v1alpha1.BuildCustomizationSpec) (*Cluster, error) { detectOpt, err := cluster.DetectNodeProvider() if err != nil { diff --git a/pkg/kind/cluster_test.go b/pkg/kind/cluster_test.go index f496543f..743a3155 100644 --- a/pkg/kind/cluster_test.go +++ b/pkg/kind/cluster_test.go @@ -6,8 +6,8 @@ import ( "os" "testing" + "github.com/adhar-io/adhar/api/v1alpha1" runtime "github.com/adhar-io/adhar/pkg/runtime" - "github.com/adhar-io/adhar/pkg/util" "github.com/docker/docker/api/types" "github.com/docker/docker/client" "github.com/stretchr/testify/assert" @@ -18,20 +18,20 @@ import ( ) func TestGetConfig(t *testing.T) { - cluster, err := NewCluster("testcase", "v1.30.0", "", "", "", util.CorePackageTemplateConfig{ - Host: "adhar.localtest.me", - Port: "8443", - }) - if err != nil { - t.Fatalf("Initializing cluster resource: %v", err) - } - cfg, err := cluster.getConfig() - if err != nil { - t.Errorf("Error getting kind config: %v", err) + type tc struct { + host string + port string + usePathRouting bool + expectConfig string } - expectConfig := `# Kind kubernetes release images https://github.com/kubernetes-sigs/kind/releases + tcs := []tc{ + { + host: "adhar.localtest.me", + port: "8443", + usePathRouting: false, + expectConfig: ` kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 nodes: @@ -48,13 +48,52 @@ containerdConfigPatches: [plugins."io.containerd.grpc.v1.cri".registry.mirrors."gitea.adhar.localtest.me:8443"] endpoint = ["https://gitea.adhar.localtest.me"] [plugins."io.containerd.grpc.v1.cri".registry.configs."gitea.adhar.localtest.me".tls] - insecure_skip_verify = true` - assert.YAMLEq(t, expectConfig, string(cfg)) + insecure_skip_verify = true`, + }, + { + host: "adhar.localtest.me", + port: "8443", + usePathRouting: true, + expectConfig: ` +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: +- role: control-plane + image: "kindest/node:v1.30.0" + labels: + ingress-ready: "true" + extraPortMappings: + - containerPort: 443 + hostPort: 8443 + protocol: TCP + +containerdConfigPatches: +- |- + [plugins."io.containerd.grpc.v1.cri".registry.mirrors."adhar.localtest.me:8443"] + endpoint = ["https://adhar.localtest.me"] + [plugins."io.containerd.grpc.v1.cri".registry.configs."adhar.localtest.me".tls] + insecure_skip_verify = true`, + }, + } + + for i := range tcs { + c := tcs[i] + cluster, err := NewCluster("testcase", "v1.30.0", "", "", "", v1alpha1.BuildCustomizationSpec{ + Host: c.host, + Port: c.port, + UsePathRouting: c.usePathRouting, + }) + assert.NoError(t, err) + + cfg, err := cluster.getConfig() + assert.NoError(t, err) + assert.YAMLEq(t, c.expectConfig, string(cfg)) + } } func TestExtraPortMappings(t *testing.T) { - cluster, err := NewCluster("testcase", "v1.30.0", "", "", "22:32222", util.CorePackageTemplateConfig{ + cluster, err := NewCluster("testcase", "v1.30.0", "", "", "22:32222", v1alpha1.BuildCustomizationSpec{ Host: "adhar.localtest.me", Port: "8443", }) @@ -134,7 +173,7 @@ func TestGetConfigCustom(t *testing.T) { } for _, v := range cases { - c, _ := NewCluster("testcase", "v1.30.0", "", v.inputPath, "", util.CorePackageTemplateConfig{ + c, _ := NewCluster("testcase", "v1.30.0", "", v.inputPath, "", v1alpha1.BuildCustomizationSpec{ Host: "adhar.localtest.me", Port: v.hostPort, Protocol: v.protocol, @@ -235,7 +274,7 @@ func TestRunsOnWrongPort(t *testing.T) { cluster := &Cluster{ name: "test-cluster", provider: mockProvider, - cfg: util.CorePackageTemplateConfig{ + cfg: v1alpha1.BuildCustomizationSpec{ Port: "8080", }, } diff --git a/pkg/kind/resources/kind.yaml.tmpl b/pkg/kind/resources/kind.yaml.tmpl index 7ca1a875..58f1d39c 100644 --- a/pkg/kind/resources/kind.yaml.tmpl +++ b/pkg/kind/resources/kind.yaml.tmpl @@ -1,4 +1,3 @@ -# Kind kubernetes release images https://github.com/kubernetes-sigs/kind/releases kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 nodes: @@ -20,7 +19,14 @@ nodes: #kubeProxyMode: none # do not run kube-proxy containerdConfigPatches: - |- + {{ if .UsePathRouting -}} + [plugins."io.containerd.grpc.v1.cri".registry.mirrors."{{ .Host }}:{{ .Port }}"] + endpoint = ["https://{{ .Host }}"] + [plugins."io.containerd.grpc.v1.cri".registry.configs."{{ .Host }}".tls] + insecure_skip_verify = true + {{- else -}} [plugins."io.containerd.grpc.v1.cri".registry.mirrors."gitea.{{ .Host }}:{{ .Port }}"] endpoint = ["https://gitea.{{ .Host }}"] [plugins."io.containerd.grpc.v1.cri".registry.configs."gitea.{{ .Host }}".tls] insecure_skip_verify = true + {{- end -}} diff --git a/pkg/util/build_config.go b/pkg/util/build_config.go deleted file mode 100644 index 9300bd64..00000000 --- a/pkg/util/build_config.go +++ /dev/null @@ -1,10 +0,0 @@ -package util - -type CorePackageTemplateConfig struct { - Protocol string - Host string - IngressHost string - Port string - UsePathRouting bool - SelfSignedCert string -} diff --git a/pkg/util/git_repository.go b/pkg/util/git_repository.go index 0919c6bb..89c7e83d 100644 --- a/pkg/util/git_repository.go +++ b/pkg/util/git_repository.go @@ -160,8 +160,9 @@ func CloneRemoteRepoToDir(ctx context.Context, remote v1alpha1.RemoteRepositoryS if err != nil { return nil, nil, fmt.Errorf("cloning repo with fall back url: %w", err) } + } else { + return nil, nil, fmt.Errorf("cloning repo: %w", err) } - return nil, nil, fmt.Errorf("cloning repo: %w", err) } } else { return nil, nil, fmt.Errorf("opening repo at %s %w", dir, err) diff --git a/platform/stack/environments/local/config.yaml b/platform/stack/environments/local/config.yaml index e7c7db0f..2d2fe827 100644 --- a/platform/stack/environments/local/config.yaml +++ b/platform/stack/environments/local/config.yaml @@ -13,12 +13,12 @@ packages: isChart: "false" - name: cnpg namespace: cnpg-system - install: "true" + install: "false" manifestPath: "data/cnpg/manifests" isChart: "false" - name: headlamp namespace: adhar-system - install: "true" + install: "false" manifestPath: "observability/headlamp/manifests" isChart: "false" - name: keycloak diff --git a/platform/stack/packages/application/Kargo/.gitkeep b/platform/stack/packages/application/Kargo/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/platform/stack/packages/application/adhar-templates/app-with-bucket/template.yaml b/platform/stack/packages/application/adhar-templates/app-with-bucket/template.yaml index fdf1ef6d..8528a13e 100644 --- a/platform/stack/packages/application/adhar-templates/app-with-bucket/template.yaml +++ b/platform/stack/packages/application/adhar-templates/app-with-bucket/template.yaml @@ -100,7 +100,7 @@ spec: input: description: This is an example app # Hard coded value for this demo purposes only. - repoUrl: cnoe.localtest.me:8443/gitea?repo=${{parameters.name}} + repoUrl: adhar.localtest.me:8443/gitea?repo=${{parameters.name}} defaultBranch: main - id: create-argocd-app name: Create ArgoCD App diff --git a/platform/stack/packages/core/adhar-console/templates/backstage/deployment.yaml b/platform/stack/packages/core/adhar-console/templates/backstage/deployment.yaml index ed547162..cfc77e5a 100644 --- a/platform/stack/packages/core/adhar-console/templates/backstage/deployment.yaml +++ b/platform/stack/packages/core/adhar-console/templates/backstage/deployment.yaml @@ -33,8 +33,8 @@ spec: name: gitea-credentials - secretRef: name: argocd-credentials - image: public.ecr.aws/cnoe-io/backstage:rc1 - name: backstage + image: ghcr.io/adhar-io/adhar-console:latest + name: adhar-console ports: - containerPort: 7007 name: http diff --git a/tests/e2e/docker/docker_test.go b/tests/e2e/docker/docker_test.go index 9a1ccf42..dffef929 100644 --- a/tests/e2e/docker/docker_test.go +++ b/tests/e2e/docker/docker_test.go @@ -69,6 +69,8 @@ func testCreate(t *testing.T) { argoBaseUrl := fmt.Sprintf("https://%s:%s/argocd", e2e.DefaultBaseDomain, e2e.DefaultPort) giteaBaseUrl := fmt.Sprintf("https://%s:%s/gitea", e2e.DefaultBaseDomain, e2e.DefaultPort) e2e.TestCoreEndpoints(ctx, t, argoBaseUrl, giteaBaseUrl) + + e2e.TestGiteaRegistry(ctx, t, "docker", fmt.Sprintf("gitea.%s", e2e.DefaultBaseDomain), e2e.DefaultPort) } // test adhar up --use-path-routing @@ -90,6 +92,8 @@ func testCreatePath(t *testing.T) { argoBaseUrl := fmt.Sprintf("https://%s:%s/argocd", e2e.DefaultBaseDomain, e2e.DefaultPort) giteaBaseUrl := fmt.Sprintf("https://%s:%s/gitea", e2e.DefaultBaseDomain, e2e.DefaultPort) e2e.TestCoreEndpoints(ctx, t, argoBaseUrl, giteaBaseUrl) + + e2e.TestGiteaRegistry(ctx, t, "docker", e2e.DefaultBaseDomain, e2e.DefaultPort) } func testCreatePort(t *testing.T) { diff --git a/tests/e2e/docker/test-dockerfile b/tests/e2e/docker/test-dockerfile new file mode 100644 index 00000000..e65c3a9d --- /dev/null +++ b/tests/e2e/docker/test-dockerfile @@ -0,0 +1,2 @@ +FROM scratch +COPY test-dockerfile . diff --git a/tests/e2e/e2e.go b/tests/e2e/e2e.go index 471588ee..63bb2eea 100644 --- a/tests/e2e/e2e.go +++ b/tests/e2e/e2e.go @@ -21,6 +21,7 @@ import ( "github.com/adhar-io/adhar/pkg/k8s" argov1alpha1 "github.com/cnoe-io/argocd-api/api/argo/application/v1alpha1" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/util/homedir" "sigs.k8s.io/controller-runtime/pkg/client" @@ -248,7 +249,7 @@ func TestArgoCDEndpoints(ctx context.Context, t *testing.T, baseUrl string) { err = SendAndParse(ctx, &appResp, httpClient, req) assert.Nil(t, err, fmt.Sprintf("getting argocd applications: %s", err)) - assert.Equal(t, 11, len(appResp.Items), fmt.Sprintf("number of apps do not match: %v", appResp.Items)) + assert.Equal(t, 9, len(appResp.Items), fmt.Sprintf("number of apps do not match: %v", appResp.Items)) } func GetBasicAuth(ctx context.Context, name string) (BasicAuth, error) { @@ -363,3 +364,32 @@ func GetKubeClient() (client.Client, error) { } return client.New(conf, client.Options{Scheme: k8s.GetScheme()}) } + +// login, build a test image, push, then pull. +func TestGiteaRegistry(ctx context.Context, t *testing.T, cmd, giteaHost, giteaPort string) { + t.Log("testing gitea container registry") + b, err := RunCommand(ctx, fmt.Sprintf("%s get secrets -o json -p gitea", IdpbuilderBinaryLocation), 10*time.Second) + assert.NoError(t, err) + + secs := make([]get.TemplateData, 2) + err = json.Unmarshal(b, &secs) + assert.NoError(t, err) + + sec := secs[0] + user := sec.Data["username"] + pass := sec.Data["password"] + + login, err := RunCommand(ctx, fmt.Sprintf("%s login %s:%s -u %s -p %s", cmd, giteaHost, giteaPort, user, pass), 10*time.Second) + require.NoErrorf(t, err, "%s login err: %s", cmd, login) + + tag := fmt.Sprintf("%s:%s/giteaadmin/test:latest", giteaHost, giteaPort) + + build, err := RunCommand(ctx, fmt.Sprintf("%s build -f test-dockerfile -t %s .", cmd, tag), 10*time.Second) + require.NoErrorf(t, err, "%s build err: %s", cmd, build) + + push, err := RunCommand(ctx, fmt.Sprintf("%s push %s", cmd, tag), 10*time.Second) + require.NoErrorf(t, err, "%s push err: %s", cmd, push) + + pull, err := RunCommand(ctx, fmt.Sprintf("%s pull %s", cmd, tag), 10*time.Second) + require.NoErrorf(t, err, "%s pull err: %s", cmd, pull) +}