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 authored Nov 4, 2023
2 parents 754a6b8 + 35db578 commit 6e927e3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 25 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
2 changes: 1 addition & 1 deletion charts/kad/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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.8

# 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
Expand Down

0 comments on commit 6e927e3

Please sign in to comment.