(ctx context.Context)
| 1094 | } |
| 1095 | |
| 1096 | func (rc *RunContext) handleCredentials(ctx context.Context) (string, string, error) { |
| 1097 | // TODO: remove below 2 lines when we can release act with breaking changes |
| 1098 | username := rc.Config.Secrets["DOCKER_USERNAME"] |
| 1099 | password := rc.Config.Secrets["DOCKER_PASSWORD"] |
| 1100 | |
| 1101 | container := rc.Run.Job().Container() |
| 1102 | if container == nil || container.Credentials == nil { |
| 1103 | return username, password, nil |
| 1104 | } |
| 1105 | |
| 1106 | if container.Credentials != nil && len(container.Credentials) != 2 { |
| 1107 | err := fmt.Errorf("invalid property count for key 'credentials:'") |
| 1108 | return "", "", err |
| 1109 | } |
| 1110 | |
| 1111 | ee := rc.NewExpressionEvaluator(ctx) |
| 1112 | if username = ee.Interpolate(ctx, container.Credentials["username"]); username == "" { |
| 1113 | err := fmt.Errorf("failed to interpolate container.credentials.username") |
| 1114 | return "", "", err |
| 1115 | } |
| 1116 | if password = ee.Interpolate(ctx, container.Credentials["password"]); password == "" { |
| 1117 | err := fmt.Errorf("failed to interpolate container.credentials.password") |
| 1118 | return "", "", err |
| 1119 | } |
| 1120 | |
| 1121 | if container.Credentials["username"] == "" || container.Credentials["password"] == "" { |
| 1122 | err := fmt.Errorf("container.credentials cannot be empty") |
| 1123 | return "", "", err |
| 1124 | } |
| 1125 | |
| 1126 | return username, password, nil |
| 1127 | } |
| 1128 | |
| 1129 | func (rc *RunContext) handleServiceCredentials(ctx context.Context, creds map[string]string) (username, password string, err error) { |
| 1130 | if creds == nil { |
no test coverage detected