Skip to content

Commit

Permalink
Merge pull request #295 from kube-tarian/crossplane-provider-fixes
Browse files Browse the repository at this point in the history
Crossplane provider fixes
  • Loading branch information
vramk23 committed Nov 4, 2023
2 parents 754a6b8 + 35db578 commit f371954
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 28 deletions.
16 changes: 0 additions & 16 deletions capten/config-worker/pkg/activities/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

type tektonPluginDS map[string]string
type crossplanePluginDS map[string]string
type crossplaneProviderPluginDS map[string]string

type Config struct {
GitDefaultCommiterName string `envconfig:"GIT_COMMIT_NAME" default:"capten-bot"`
Expand Down Expand Up @@ -58,18 +57,3 @@ func ReadCrossPlanePluginConfig(pluginFile string) (crossplanePluginDS, error) {

return pluginData, nil
}

func ReadCrossPlaneProviderPluginConfig(pluginFile string) (crossplaneProviderPluginDS, error) {
data, err := os.ReadFile(filepath.Clean(pluginFile))
if err != nil {
return nil, fmt.Errorf("failed to read pluginConfig File: %s, err: %w", pluginFile, err)
}

var pluginData crossplaneProviderPluginDS
err = json.Unmarshal(data, &pluginData)
if err != nil {
return nil, fmt.Errorf("%w", err)
}

return pluginData, nil
}
5 changes: 2 additions & 3 deletions capten/config-worker/pkg/activities/plugin_extracter.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package activities

type PluginConfigExtractor struct {
tektonPluginData tektonPluginDS
crossPlanePluginData crossplanePluginDS
crossplaneProviderPluginData crossplaneProviderPluginDS
tektonPluginData tektonPluginDS
crossPlanePluginData crossplanePluginDS
}

func NewPluginExtractor(tektonFileName, crossplaneFilename string) (*PluginConfigExtractor, error) {
Expand Down
19 changes: 14 additions & 5 deletions capten/config-worker/pkg/activities/provider_git_configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ func (hg *HandleGit) configureCrossplaneProvider(ctx context.Context, params *mo
return err
}

mapping := hg.pluginConfig.GetPluginMap(CrossPlane)
fmt.Printf("MAPPING: %+v\n", mapping)

if err := createProviderConfigs(
filepath.Join(tempDir, pathInRepo),
params,
hg.pluginConfig.GetPluginMap(CrossPlane)); err != nil {
return err
}

fmt.Printf("SRC: %s DEST: %s\n", filepath.Join(tempDir, pathInRepo),
filepath.Join(reqRepo, pathInRepo))

// copy the contents to the cloned repo and if dir exists, then replace it
err = cp.Copy(
filepath.Join(tempDir, pathInRepo),
Expand Down Expand Up @@ -82,7 +88,15 @@ func (hg *HandleGit) configureCrossplaneProvider(ctx context.Context, params *mo
func createProviderConfigs(dir string, params *model.CrossplaneUseCase, pluginMap map[string]string) error {
for _, provider := range params.CrossplaneProviders {
cloudType := provider.CloudType
providerConfigString, err := createProviderCrdString(provider, params, pluginMap)
if err != nil {
return fmt.Errorf("createProviderConfigs: err createProviderCrdString: %v", err)
}

// create and write to files
providerFile := filepath.Join(dir, fmt.Sprintf("%s-provider.yaml", cloudType))
fmt.Printf("PROVIDER FILE: %v\n", providerFile)

dir := filepath.Dir(providerFile)
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
return fmt.Errorf("err while creating directories: %v", dir)
Expand All @@ -93,11 +107,6 @@ func createProviderConfigs(dir string, params *model.CrossplaneUseCase, pluginMa
return fmt.Errorf("err while creating file for provider: %v", err)
}

providerConfigString, err := createProviderCrdString(provider, params, pluginMap)
if err != nil {
return fmt.Errorf("createProviderConfigs: err createProviderCrdString: %v", err)
}

if _, err := file.WriteString(providerConfigString); err != nil {
return fmt.Errorf("err while writing to controllerconfig: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions charts/kad/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.7
version: 0.2.9

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.18.0"
appVersion: "1.19.0"
4 changes: 2 additions & 2 deletions charts/server/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.24
version: 0.1.25

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.24.0"
appVersion: "1.25.0"

0 comments on commit f371954

Please sign in to comment.