Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for file based secret #1159

Merged
merged 9 commits into from
Dec 1, 2019
Prev Previous commit
Next Next commit
Merge branch 'master' into secret-support
  • Loading branch information
hangyan authored Aug 2, 2018
commit 98fb34866237efb2f3aa863431136691b47e532e
12 changes: 8 additions & 4 deletions pkg/kobject/kobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package kobject

import (
cliTypes "github.com/docker/cli/cli/compose/types"
dockerCliTypes "github.com/docker/cli/cli/compose/types"
"github.com/docker/libcompose/yaml"
"k8s.io/kubernetes/pkg/api"
)
Expand Down Expand Up @@ -109,9 +109,13 @@ type ServiceConfig struct {
Replicas int `compose:"replicas"`
GroupAdd []int64 `compose:"group_add"`
Volumes []Volumes `compose:""`
Secrets []cliTypes.ServiceSecretConfig
HealthChecks HealthCheck `compose:""`
Placement map[string]string `compose:""`
Secrets []dockercliTypes.ServiceSecretConfig
HealthChecks HealthCheck `compose:""`
Placement map[string]string `compose:""`
//This is for long LONG SYNTAX link(https://docs.docker.com/compose/compose-file/#long-syntax)
Configs []dockerCliTypes.ServiceConfigObjConfig `compose:""`
//This is for SHORT SYNTAX link(https://docs.docker.com/compose/compose-file/#configs)
ConfigsMetaData map[string]dockerCliTypes.ConfigObjConfig `compose:""`
}

// HealthCheck the healthcheck configuration for a service
Expand Down
16 changes: 16 additions & 0 deletions pkg/transformer/kubernetes/k8sutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ func GetEnvsFromFile(file string, opt kobject.ConvertOptions) (map[string]string
return envLoad, nil
}


// GetSecretDataFromFile load secret content data
func GetSecretDataFromFile(file string, opt kobject.ConvertOptions) ([]byte, error) {
composeDir, err := transformer.GetComposeFileDir(opt.InputFiles)
Expand All @@ -616,6 +617,21 @@ func GetSecretDataFromFile(file string, opt kobject.ConvertOptions) ([]byte, err
}
fileLocation := path.Join(composeDir, file)
return ioutil.ReadFile(fileLocation)

// GetContentFromFile get content from file
// TODO(hang): merge these two functions
func GetContentFromFile(file string, opt kobject.ConvertOptions) (string, error) {
// Get the correct file context / directory
composeDir, err := transformer.GetComposeFileDir(opt.InputFiles)
if err != nil {
return "", errors.Wrap(err, "Unable to load file context")
}
fileLocation := path.Join(composeDir, file)
fileBytes, err := ioutil.ReadFile(fileLocation)
if err != nil {
return "", errors.Wrap(err, "Unable to read file")
}
return string(fileBytes), nil
}

// FormatEnvName format env name
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.