Skip to content

Commit

Permalink
Merge branch 'master' into k8-describe-package-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip-21 authored Apr 12, 2023
2 parents 6e9756d + 3f37557 commit e9d6281
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ require (
github.com/novln/docker-parser v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/opencontainers/runc v1.1.2 // indirect
github.com/opencontainers/runc v1.1.5 // indirect
github.com/openshift/api v0.0.0-20200803131051-87466835fcc0 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
Expand Down
6 changes: 3 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -924,8 +924,8 @@ github.com/opencontainers/runc v1.0.0-rc8.0.20190926000215-3e425f80a8c9/go.mod h
github.com/opencontainers/runc v1.0.0-rc9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
github.com/opencontainers/runc v1.0.0-rc93/go.mod h1:3NOsor4w32B2tC0Zbl8Knk4Wg84SM2ImC1fxBuqJ/H0=
github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0=
github.com/opencontainers/runc v1.1.2 h1:2VSZwLx5k/BfsBxMMipG/LYUnmqOD/BPkIVgQUcTlLw=
github.com/opencontainers/runc v1.1.2/go.mod h1:Tj1hFw6eFWp/o33uxGf5yF2BX5yz2Z6iptFpuvbbKqc=
github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/GDEs=
github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg=
github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-spec v1.0.1/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-spec v1.0.2-0.20190207185410-29686dbc5559/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
Expand Down Expand Up @@ -1025,7 +1025,7 @@ github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdh
github.com/sclevine/spec v1.2.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24q7p+U=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo=
github.com/seccomp/libseccomp-golang v0.9.2-0.20210429002308-3879420cc921/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
Expand Down
11 changes: 10 additions & 1 deletion utils/component/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type CuePathConfig struct {
GroupPath string
VersionPath string
SpecPath string
ScopePath string
// identifiers are the values that uniquely identify a CRD (in most of the cases, it is the 'Name' field)
IdentifierPath string
}
Expand All @@ -25,6 +26,7 @@ var DefaultPathConfig = CuePathConfig{
IdentifierPath: "spec.names.kind",
VersionPath: "spec.versions[0].name",
GroupPath: "spec.group",
ScopePath: "spec.scope",
SpecPath: "spec.versions[0].schema.openAPIV3Schema.properties.spec",
}

Expand All @@ -33,6 +35,7 @@ var DefaultPathConfig2 = CuePathConfig{
IdentifierPath: "spec.names.kind",
VersionPath: "spec.versions[0].name",
GroupPath: "spec.group",
ScopePath: "spec.scope",
SpecPath: "spec.validation.openAPIV3Schema.properties.spec",
}

Expand Down Expand Up @@ -65,7 +68,13 @@ func Generate(crd string) (v1alpha1.ComponentDefinition, error) {
if err != nil {
return component, err
}

// return component, err Ignore error if scope isn't found
scope, _ := extractCueValueFromPath(crdCue, DefaultPathConfig.ScopePath)
if scope == "Cluster" {
component.Metadata["isNamespaced"] = false
} else if scope == "Namespaced" {
component.Metadata["isNamespaced"] = true
}
component.Kind = name
if group != "" {
component.APIVersion = fmt.Sprintf("%s/%s", group, version)
Expand Down
8 changes: 6 additions & 2 deletions utils/kubernetes/apply-helm-chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,15 +404,19 @@ func checkIfInstallable(ch *chart.Chart) error {
func createHelmActionConfig(c *Client, cfg ApplyHelmChartConfig) (*action.Configuration, error) {
// Set the environment variable needed by the Init methods
os.Setenv("HELM_DRIVER_SQL_CONNECTION_STRING", cfg.SQLConnectionString)
os.Setenv("HELM_KUBEAPISERVER", c.RestConfig.Host)

// KubeConfig setup
cafile, err := setDataAndReturnFileHandler(c.RestConfig.CAData)
if err != nil {
return nil, err
}
cafilename := cafile.Name()
os.Setenv("HELM_KUBECAFILE", cafilename)

kubeConfig := genericclioptions.NewConfigFlags(false)
kubeConfig.APIServer = &c.RestConfig.Host
kubeConfig.CAFile = &cafilename
kubeConfig.BearerToken = &c.RestConfig.BearerToken

actionConfig := new(action.Configuration)
if err := actionConfig.Init(kubeConfig, cfg.Namespace, string(cfg.HelmDriver), cfg.Logger); err != nil {
return nil, ErrApplyHelmChart(err)
Expand Down

0 comments on commit e9d6281

Please sign in to comment.